Commit 407b153f authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Update FilesApp UI tests to use async functions with await.

Bug: 955920
Change-Id: I0e35c812be6a9566159efd064698429cf5263fdf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1587576Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654789}
parent 06a39730
......@@ -4,100 +4,80 @@
const checkselect = {};
checkselect.testCancelCheckSelectModeAfterAction = (done) => {
test.setupAndWaitUntilReady()
.then(() => {
// Click 2nd last file on checkmark to start check-select-mode.
assertTrue(test.fakeMouseClick(
'#file-list li.table-row:nth-of-type(4) .detail-checkmark'));
return test.waitForElement(
'#file-list li[selected].table-row:nth-of-type(4)');
})
.then(result => {
// Click last file on checkmark, adds to selection.
assertTrue(test.fakeMouseClick(
'#file-list li.table-row:nth-of-type(5) .detail-checkmark'));
return test.waitForElement(
'#file-list li[selected].table-row:nth-of-type(5)');
})
.then(result => {
assertEquals(
2, document.querySelectorAll('#file-list li[selected]').length);
// Click selection menu (3-dots).
assertTrue(test.fakeMouseClick('#selection-menu-button'));
return test.waitForElement(
'#file-context-menu:not([hidden]) ' +
'cr-menu-item[command="#cut"]:not([disabled])');
})
.then(result => {
// Click 'cut'.
test.fakeMouseClick('#file-context-menu cr-menu-item[command="#cut"]');
return test.waitForElement('#file-context-menu[hidden]');
})
.then(result => {
// Click first photos dir in checkmark and make sure 4 and 5 not
// selected.
assertTrue(test.fakeMouseClick(
'#file-list li.table-row:nth-of-type(1) .detail-checkmark'));
return test.waitForElement(
'#file-list li[selected].table-row:nth-of-type(1)');
})
.then(result => {
assertEquals(
1, document.querySelectorAll('#file-list li[selected]').length);
done();
});
checkselect.testCancelCheckSelectModeAfterAction = async (done) => {
await test.setupAndWaitUntilReady();
// Click 2nd last file on checkmark to start check-select-mode.
assertTrue(test.fakeMouseClick(
'#file-list li.table-row:nth-of-type(4) .detail-checkmark'));
await test.waitForElement('#file-list li[selected].table-row:nth-of-type(4)');
// Click last file on checkmark, adds to selection.
assertTrue(test.fakeMouseClick(
'#file-list li.table-row:nth-of-type(5) .detail-checkmark'));
await test.waitForElement('#file-list li[selected].table-row:nth-of-type(5)');
assertEquals(2, document.querySelectorAll('#file-list li[selected]').length);
// Click selection menu (3-dots).
assertTrue(test.fakeMouseClick('#selection-menu-button'));
await test.waitForElement(
'#file-context-menu:not([hidden]) ' +
'cr-menu-item[command="#cut"]:not([disabled])');
// Click 'cut'.
test.fakeMouseClick('#file-context-menu cr-menu-item[command="#cut"]');
await test.waitForElement('#file-context-menu[hidden]');
// Click first photos dir in checkmark and make sure 4 and 5 not
// selected.
assertTrue(test.fakeMouseClick(
'#file-list li.table-row:nth-of-type(1) .detail-checkmark'));
await test.waitForElement('#file-list li[selected].table-row:nth-of-type(1)');
assertEquals(1, document.querySelectorAll('#file-list li[selected]').length);
done();
};
checkselect.testCheckSelectModeAfterSelectAllOneFile = (done) => {
checkselect.testCheckSelectModeAfterSelectAllOneFile = async (done) => {
const gearMenu = document.querySelector('#gear-menu');
const cancel = document.querySelector('#cancel-selection-button-wrapper');
const selectAll =
'#gear-menu:not([hidden]) #gear-menu-select-all:not([disabled])';
// Load a single file.
test.setupAndWaitUntilReady([test.ENTRIES.hello])
.then(() => {
// Click gear menu, ensure 'Select all' is shown.
assertTrue(test.fakeMouseClick('#gear-button'));
return test.waitForElement(selectAll);
})
.then(result => {
// Click 'Select all', gear menu now replaced with file context menu.
assertTrue(test.fakeMouseClick('#gear-menu-select-all'));
return test.repeatUntil(() => {
return getComputedStyle(gearMenu).opacity == 0 &&
getComputedStyle(cancel).display == 'block' ||
test.pending('waiting for check select mode from click');
});
})
.then(result => {
// Cancel selection, ensure no items selected.
assertTrue(test.fakeMouseClick('#cancel-selection-button'));
return test.repeatUntil(() => {
return document.querySelectorAll('#file-list li[selected]').length ==
0 ||
test.pending('waiting for no files selected after click');
});
})
.then(result => {
// 'Ctrl+a' to select all.
assertTrue(test.fakeKeyDown('#file-list', 'a', true, false, false));
return test.repeatUntil(() => {
return getComputedStyle(cancel).display == 'block' ||
test.pending('waiting for check select mode from key');
});
})
.then(result => {
// Cancel selection, ensure no items selected.
assertTrue(test.fakeMouseClick('#cancel-selection-button'));
return test.repeatUntil(() => {
return document.querySelectorAll('#file-list li[selected]').length ==
0 ||
test.pending('waiting for no files selected after key');
});
})
.then(result => {
done();
});
await test.setupAndWaitUntilReady([test.ENTRIES.hello]);
// Click gear menu, ensure 'Select all' is shown.
assertTrue(test.fakeMouseClick('#gear-button'));
await test.waitForElement(selectAll);
// Click 'Select all', gear menu now replaced with file context menu.
assertTrue(test.fakeMouseClick('#gear-menu-select-all'));
await test.repeatUntil(() => {
return getComputedStyle(gearMenu).opacity == 0 &&
getComputedStyle(cancel).display == 'block' ||
test.pending('waiting for check select mode from click');
});
// Cancel selection, ensure no items selected.
assertTrue(test.fakeMouseClick('#cancel-selection-button'));
await test.repeatUntil(() => {
return document.querySelectorAll('#file-list li[selected]').length == 0 ||
test.pending('waiting for no files selected after click');
});
// 'Ctrl+a' to select all.
assertTrue(test.fakeKeyDown('#file-list', 'a', true, false, false));
await test.repeatUntil(() => {
return getComputedStyle(cancel).display == 'block' ||
test.pending('waiting for check select mode from key');
});
// Cancel selection, ensure no items selected.
assertTrue(test.fakeMouseClick('#cancel-selection-button'));
await test.repeatUntil(() => {
return document.querySelectorAll('#file-list li[selected]').length == 0 ||
test.pending('waiting for no files selected after key');
});
done();
};
......@@ -18,60 +18,53 @@ crostiniMount.testCrostiniNotEnabled = async (done) => {
done();
};
crostiniMount.testMountCrostiniSuccess = (done) => {
crostiniMount.testMountCrostiniSuccess = async (done) => {
const fakeRoot = '#directory-tree [root-type-icon="crostini"]';
const oldMount = chrome.fileManagerPrivate.mountCrostini;
let mountCallback = null;
chrome.fileManagerPrivate.mountCrostini = (callback) => {
mountCallback = callback;
};
test.setupAndWaitUntilReady()
.then(() => {
// Linux files fake root is shown.
return test.waitForElement(fakeRoot);
})
.then(() => {
// Click on Linux files.
assertTrue(test.fakeMouseClick(fakeRoot, 'click linux files'));
return test.waitForElement('paper-progress:not([hidden])');
})
.then(() => {
// Ensure mountCrostini is called.
return test.repeatUntil(() => {
if (!mountCallback) {
return test.pending('Waiting for mountCrostini');
}
return mountCallback;
});
})
.then(() => {
// Intercept the fileManagerPrivate.mountCrostini call
// and add crostini disk mount.
test.mountCrostini();
// Continue from fileManagerPrivate.mountCrostini callback
// and ensure expected files are shown.
mountCallback();
return test.waitForFiles(
test.TestEntryInfo.getExpectedRows(test.BASIC_CROSTINI_ENTRY_SET));
})
.then(() => {
// Reset fileManagerPrivate.mountCrostini and remove mount.
chrome.fileManagerPrivate.mountCrostini = oldMount;
chrome.fileManagerPrivate.removeMount('crostini');
// Linux Files fake root is shown.
return test.waitForElement(fakeRoot);
})
.then(() => {
// Downloads folder should be shown when crostini goes away.
return test.waitForFiles(
test.TestEntryInfo.getExpectedRows(test.BASIC_LOCAL_ENTRY_SET));
})
.then(() => {
done();
});
await test.setupAndWaitUntilReady();
// Linux files fake root is shown.
await test.waitForElement(fakeRoot);
// Click on Linux files.
assertTrue(test.fakeMouseClick(fakeRoot, 'click linux files'));
await test.waitForElement('paper-progress:not([hidden])');
// Ensure mountCrostini is called.
await test.repeatUntil(() => {
if (!mountCallback) {
return test.pending('Waiting for mountCrostini');
}
return mountCallback;
});
// Intercept the fileManagerPrivate.mountCrostini call
// and add crostini disk mount.
test.mountCrostini();
// Continue from fileManagerPrivate.mountCrostini callback
// and ensure expected files are shown.
mountCallback();
await test.waitForFiles(
test.TestEntryInfo.getExpectedRows(test.BASIC_CROSTINI_ENTRY_SET));
// Reset fileManagerPrivate.mountCrostini and remove mount.
chrome.fileManagerPrivate.mountCrostini = oldMount;
chrome.fileManagerPrivate.removeMount('crostini');
// Linux Files fake root is shown.
await test.waitForElement(fakeRoot);
// Downloads folder should be shown when crostini goes away.
await test.waitForFiles(
test.TestEntryInfo.getExpectedRows(test.BASIC_LOCAL_ENTRY_SET));
done();
};
crostiniMount.testMountCrostiniError = (done) => {
crostiniMount.testMountCrostiniError = async (done) => {
const fakeRoot = '#directory-tree [root-type-icon="crostini"]';
const oldMount = chrome.fileManagerPrivate.mountCrostini;
// Override fileManagerPrivate.mountCrostini to return error.
......@@ -80,47 +73,32 @@ crostiniMount.testMountCrostiniError = (done) => {
callback();
delete chrome.runtime.lastError;
};
test.setupAndWaitUntilReady()
.then(() => {
return test.waitForElement(fakeRoot);
})
.then(() => {
// Click on Linux Files, ensure error dialog is shown.
assertTrue(test.fakeMouseClick(fakeRoot));
return test.waitForElement('.cr-dialog-container.shown');
})
.then(() => {
// Click OK button to close.
assertTrue(test.fakeMouseClick('button.cr-dialog-ok'));
return test.waitForElementLost('.cr-dialog-container');
})
.then(() => {
// Reset chrome.fileManagerPrivate.mountCrostini.
chrome.fileManagerPrivate.mountCrostini = oldMount;
done();
});
await test.setupAndWaitUntilReady();
await test.waitForElement(fakeRoot);
// Click on Linux Files, ensure error dialog is shown.
assertTrue(test.fakeMouseClick(fakeRoot));
await test.waitForElement('.cr-dialog-container.shown');
// Click OK button to close.
assertTrue(test.fakeMouseClick('button.cr-dialog-ok'));
await test.waitForElementLost('.cr-dialog-container');
// Reset chrome.fileManagerPrivate.mountCrostini.
chrome.fileManagerPrivate.mountCrostini = oldMount;
done();
};
crostiniMount.testCrostiniMountOnDrag = (done) => {
crostiniMount.testCrostiniMountOnDrag = async (done) => {
const fakeRoot = '#directory-tree [root-type-icon="crostini"]';
chrome.fileManagerPrivate.mountCrostiniDelay_ = 0;
test.setupAndWaitUntilReady()
.then(() => {
return test.waitForElement(fakeRoot);
})
.then(() => {
assertTrue(
test.sendEvent(fakeRoot, new Event('dragenter', {bubbles: true})));
assertTrue(
test.sendEvent(fakeRoot, new Event('dragleave', {bubbles: true})));
return test.waitForFiles(
test.TestEntryInfo.getExpectedRows(test.BASIC_CROSTINI_ENTRY_SET));
})
.then(() => {
chrome.fileManagerPrivate.removeMount('crostini');
return test.waitForElement(fakeRoot);
})
.then(() => {
done();
});
await test.setupAndWaitUntilReady();
await test.waitForElement(fakeRoot);
assertTrue(test.sendEvent(fakeRoot, new Event('dragenter', {bubbles: true})));
assertTrue(test.sendEvent(fakeRoot, new Event('dragleave', {bubbles: true})));
await test.waitForFiles(
test.TestEntryInfo.getExpectedRows(test.BASIC_CROSTINI_ENTRY_SET));
chrome.fileManagerPrivate.removeMount('crostini');
await test.waitForElement(fakeRoot);
done();
};
......@@ -4,7 +4,7 @@
const crostiniTasks = {};
crostiniTasks.testShareBeforeOpeningDownloadsWithCrostiniApp = (done) => {
crostiniTasks.testShareBeforeOpeningDownloadsWithCrostiniApp = async (done) => {
// Save old fmp.getFileTasks and replace with version that returns
// crostini app and chrome Text app.
let oldGetFileTasks = chrome.fileManagerPrivate.getFileTasks;
......@@ -44,69 +44,59 @@ crostiniTasks.testShareBeforeOpeningDownloadsWithCrostiniApp = (done) => {
};
chrome.metricsPrivate.values_ = [];
test.setupAndWaitUntilReady([], [], [])
.then(() => {
// Add '/A', and '/A/hello.txt', refresh, 'A' is shown.
test.addEntries(
[test.ENTRIES.directoryA, test.ENTRIES.helloInA], [], []);
assertTrue(test.fakeMouseClick('#refresh-button'), 'click refresh');
return test.waitForFiles(
test.TestEntryInfo.getExpectedRows([test.ENTRIES.directoryA]));
})
.then(() => {
// Change to 'A' directory, hello.txt is shown.
assertTrue(test.fakeMouseDoubleClick('[file-name="A"]'));
return test.waitForFiles(
test.TestEntryInfo.getExpectedRows([test.ENTRIES.hello]));
})
.then(() => {
// Right click on 'hello.txt' file, wait for dialog with 'Open with'.
assertTrue(test.fakeMouseRightClick('[file-name="hello.txt"]'));
return test.waitForElement(
'cr-menu-item[command="#open-with"]:not([hidden]');
})
.then(() => {
// Click 'Open with', wait for picker.
assertTrue(test.fakeMouseClick('cr-menu-item[command="#open-with"]'));
return test.waitForElement('#default-tasks-list');
})
.then(() => {
// Ensure that the default tasks label is shown correctly.
const item = document.querySelector('#default-task-menu-item span');
assertEquals('Open with Crostini App', item.innerText);
})
.then(() => {
// Ensure picker shows both options. Click on 'Crostini App'. Ensure
// share path dialog is shown.
const list = document.querySelectorAll('#default-tasks-list li div');
assertEquals(2, list.length);
assertEquals('Crostini App (default)', list[0].innerText);
assertEquals('Open with Text', list[1].innerText);
assertTrue(test.fakeMouseClick('#default-tasks-list li'));
// Ensure fmp.sharePathsWithCrostini, fmp.executeTask called.
return test.repeatUntil(() => {
return sharePathsCalled && executeTaskCalled ||
test.pending('Waiting to share and open');
});
})
.then(() => {
// Share should not persist as a result of open with crostini app.
assertFalse(sharePathsPersist);
// Validate UMAs.
const lastEnumUma = chrome.metricsPrivate.values_.pop();
assertEquals(
'FileBrowser.CrostiniShareDialog', lastEnumUma[0].metricName);
assertEquals(1 /* ShareBeforeOpen */, lastEnumUma[1]);
// Restore fmp.*.
chrome.fileManagerPrivate.getFileTasks = oldGetFileTasks;
chrome.fileManagerPrivate.sharePathsWithCrostini = oldSharePaths;
chrome.fileManagerPrivate.executeTask = oldExecuteTask;
done();
});
await test.setupAndWaitUntilReady([], [], []);
// Add '/A', and '/A/hello.txt', refresh, 'A' is shown.
test.addEntries([test.ENTRIES.directoryA, test.ENTRIES.helloInA], [], []);
assertTrue(test.fakeMouseClick('#refresh-button'), 'click refresh');
await test.waitForFiles(
test.TestEntryInfo.getExpectedRows([test.ENTRIES.directoryA]));
// Change to 'A' directory, hello.txt is shown.
assertTrue(test.fakeMouseDoubleClick('[file-name="A"]'));
await test.waitForFiles(
test.TestEntryInfo.getExpectedRows([test.ENTRIES.hello]));
// Right click on 'hello.txt' file, wait for dialog with 'Open with'.
assertTrue(test.fakeMouseRightClick('[file-name="hello.txt"]'));
await test.waitForElement('cr-menu-item[command="#open-with"]:not([hidden]');
// Click 'Open with', wait for picker.
assertTrue(test.fakeMouseClick('cr-menu-item[command="#open-with"]'));
await test.waitForElement('#default-tasks-list');
// Ensure that the default tasks label is shown correctly.
const item = document.querySelector('#default-task-menu-item span');
assertEquals('Open with Crostini App', item.innerText);
// Ensure picker shows both options. Click on 'Crostini App'. Ensure
// share path dialog is shown.
const list = document.querySelectorAll('#default-tasks-list li div');
assertEquals(2, list.length);
assertEquals('Crostini App (default)', list[0].innerText);
assertEquals('Open with Text', list[1].innerText);
assertTrue(test.fakeMouseClick('#default-tasks-list li'));
// Ensure fmp.sharePathsWithCrostini, fmp.executeTask called.
await test.repeatUntil(() => {
return sharePathsCalled && executeTaskCalled ||
test.pending('Waiting to share and open');
});
// Share should not persist as a result of open with crostini app.
assertFalse(sharePathsPersist);
// Validate UMAs.
const lastEnumUma = chrome.metricsPrivate.values_.pop();
assertEquals('FileBrowser.CrostiniShareDialog', lastEnumUma[0].metricName);
assertEquals(1 /* ShareBeforeOpen */, lastEnumUma[1]);
// Restore fmp.*.
chrome.fileManagerPrivate.getFileTasks = oldGetFileTasks;
chrome.fileManagerPrivate.sharePathsWithCrostini = oldSharePaths;
chrome.fileManagerPrivate.executeTask = oldExecuteTask;
done();
};
crostiniTasks.testErrorLoadingLinuxPackageInfo = (done) => {
crostiniTasks.testErrorLoadingLinuxPackageInfo = async (done) => {
const linuxFiles = '#directory-tree .tree-item [root-type-icon="crostini"]';
const dialog = '#install-linux-package-dialog';
const detailsFrame = '.install-linux-package-details-frame';
......@@ -132,48 +122,41 @@ crostiniTasks.testErrorLoadingLinuxPackageInfo = (done) => {
packageInfoCallback = callback;
};
test.setupAndWaitUntilReady([], [], [test.ENTRIES.debPackage])
.then(() => {
return test.waitForElement(linuxFiles);
})
.then(() => {
// Select 'Linux files' in directory tree.
assertTrue(test.fakeMouseClick(linuxFiles), 'click Linux files');
return test.waitForFiles(
test.TestEntryInfo.getExpectedRows([test.ENTRIES.debPackage]));
})
.then(() => {
// Double click on 'package.deb' file to open the install dialog.
assertTrue(test.fakeMouseDoubleClick('[file-name="package.deb"]'));
return test.waitForElement(dialog);
})
.then(() => {
// Verify the loading state is shown.
assertEquals(
'Details\nLoading information...',
document.querySelector(detailsFrame).innerText);
return test.repeatUntil(() => {
return packageInfoCallback ||
test.pending('Waiting for package info request');
});
})
.then(() => {
// Call the callback with an error.
chrome.runtime.lastError = {message: 'error message'};
packageInfoCallback(undefined);
delete chrome.runtime.lastError;
assertEquals(
'Details\nFailed to retrieve app info.',
document.querySelector(detailsFrame).innerText);
// Click 'cancel' to close. Ensure dialog closes.
assertTrue(test.fakeMouseClick('button.cr-dialog-cancel'));
return test.waitForElementLost(dialog);
})
.then(() => {
// Restore fmp.getFileTasks, fmp.getLinuxPackageInfo.
chrome.fileManagerPrivate.getFileTasks = oldGetFileTasks;
chrome.fileManagerPrivate.getLinuxPackageInfo = oldGetLinuxPackageInfo;
done();
});
await test.setupAndWaitUntilReady([], [], [test.ENTRIES.debPackage]);
await test.waitForElement(linuxFiles);
// Select 'Linux files' in directory tree.
assertTrue(test.fakeMouseClick(linuxFiles), 'click Linux files');
await test.waitForFiles(
test.TestEntryInfo.getExpectedRows([test.ENTRIES.debPackage]));
// Double click on 'package.deb' file to open the install dialog.
assertTrue(test.fakeMouseDoubleClick('[file-name="package.deb"]'));
await test.waitForElement(dialog);
// Verify the loading state is shown.
assertEquals(
'Details\nLoading information...',
document.querySelector(detailsFrame).innerText);
await test.repeatUntil(() => {
return packageInfoCallback ||
test.pending('Waiting for package info request');
});
// Call the callback with an error.
chrome.runtime.lastError = {message: 'error message'};
packageInfoCallback(undefined);
delete chrome.runtime.lastError;
assertEquals(
'Details\nFailed to retrieve app info.',
document.querySelector(detailsFrame).innerText);
// Click 'cancel' to close. Ensure dialog closes.
assertTrue(test.fakeMouseClick('button.cr-dialog-cancel'));
await test.waitForElementLost(dialog);
// Restore fmp.getFileTasks, fmp.getLinuxPackageInfo.
chrome.fileManagerPrivate.getFileTasks = oldGetFileTasks;
chrome.fileManagerPrivate.getLinuxPackageInfo = oldGetLinuxPackageInfo;
done();
};
......@@ -538,7 +538,8 @@ test.waitForFiles = function(expected, opt_options) {
* @return {Promise} Promise to be fulfilled with the result object, which
* contains the file list.
*/
test.setupAndWaitUntilReady = function(opt_downloads, opt_drive, opt_crostini) {
test.setupAndWaitUntilReady =
async function(opt_downloads, opt_drive, opt_crostini) {
const entriesDownloads = opt_downloads || test.BASIC_LOCAL_ENTRY_SET;
const entriesDrive = opt_drive || test.BASIC_DRIVE_ENTRY_SET;
const entriesCrostini = opt_crostini || test.BASIC_CROSTINI_ENTRY_SET;
......@@ -557,20 +558,17 @@ test.setupAndWaitUntilReady = function(opt_downloads, opt_drive, opt_crostini) {
const downloadsElement = '#directory-tree [volume-type-icon="downloads"]';
return test.loadData()
.then(() => {
test.addEntries(entriesDownloads, entriesDrive, entriesCrostini);
return test.waitForElement(downloadsElement);
})
.then((downloadsIcon) => {
// Click Downloads if not already on Downloads, then refresh button.
if (!downloadsIcon.parentElement.hasAttribute('selected')) {
assertTrue(test.fakeMouseClick(downloadsElement), 'click downloads');
}
assertTrue(test.fakeMouseClick('#refresh-button'), 'click refresh');
return test.waitForFiles(
test.TestEntryInfo.getExpectedRows(entriesDownloads));
});
await test.loadData();
test.addEntries(entriesDownloads, entriesDrive, entriesCrostini);
const downloadsIcon = await test.waitForElement(downloadsElement);
// Click Downloads if not already on Downloads, then refresh button.
if (!downloadsIcon.parentElement.hasAttribute('selected')) {
assertTrue(test.fakeMouseClick(downloadsElement), 'click downloads');
}
assertTrue(test.fakeMouseClick('#refresh-button'), 'click refresh');
return test.waitForFiles(
test.TestEntryInfo.getExpectedRows(entriesDownloads));
};
/**
......
......@@ -16,7 +16,7 @@ progressCenter.createItem = function(id, message) {
return item;
};
progressCenter.testScrollWhenManyMessages = (done) => {
progressCenter.testScrollWhenManyMessages = async (done) => {
const visibleClosed = '#progress-center:not([hidden]):not(.opened)';
const visibleOpen = '#progress-center:not([hidden]).opened';
const openIcon = '#progress-center-close-view .open';
......@@ -25,32 +25,29 @@ progressCenter.testScrollWhenManyMessages = (done) => {
const items = [];
const center = fileManager.fileBrowserBackground_.progressCenter;
// Load a single file.
test.setupAndWaitUntilReady()
.then(() => {
// Add lots of messages.
for (let i = 0; i < 100; i++) {
const item = progressCenter.createItem('id' + i, 'msg ' + i);
items.push(item);
center.updateItem(item);
}
// Wait for notification expand icon.
return test.waitForElement(visibleClosed);
})
.then(result => {
// Click open icon, ensure progress center is open.
assertTrue(test.fakeMouseClick(openIcon));
return test.waitForElement(visibleOpen);
})
.then(result => {
// Ensure progress center is scrollable.
const footer = document.querySelector(navListFooter);
assertTrue(footer.scrollHeight > footer.clientHeight);
// Clear items.
items.forEach((item) => {
item.state = ProgressItemState.COMPLETED;
center.updateItem(item);
});
done();
});
await test.setupAndWaitUntilReady();
// Add lots of messages.
for (let i = 0; i < 100; i++) {
const item = progressCenter.createItem('id' + i, 'msg ' + i);
items.push(item);
center.updateItem(item);
}
// Wait for notification expand icon.
await test.waitForElement(visibleClosed);
// Click open icon, ensure progress center is open.
assertTrue(test.fakeMouseClick(openIcon));
await test.waitForElement(visibleOpen);
// Ensure progress center is scrollable.
const footer = document.querySelector(navListFooter);
assertTrue(footer.scrollHeight > footer.clientHeight);
// Clear items.
items.forEach((item) => {
item.state = ProgressItemState.COMPLETED;
center.updateItem(item);
});
done();
};
......@@ -4,27 +4,23 @@
const uma = {};
uma.testClickBreadcrumb = (done) => {
test.setupAndWaitUntilReady()
.then(() => {
// Reset metrics.
chrome.metricsPrivate.userActions_ = [];
// Click first row which is 'photos' dir, wait for breadcrumb to show.
assertTrue(test.fakeMouseDoubleClick('#file-list li.table-row'));
return test.waitForElement(
'#location-breadcrumbs .breadcrumb-path:nth-of-type(2)');
})
.then(result => {
// Click breadcrumb to return to parent dir.
assertTrue(test.fakeMouseClick(
'#location-breadcrumbs .breadcrumb-path:nth-of-type(1)'));
return test.waitForFiles(
test.TestEntryInfo.getExpectedRows(test.BASIC_LOCAL_ENTRY_SET));
})
.then(result => {
assertArrayEquals(
['FileBrowser.ClickBreadcrumbs'],
chrome.metricsPrivate.userActions_);
done();
});
uma.testClickBreadcrumb = async (done) => {
await test.setupAndWaitUntilReady();
// Reset metrics.
chrome.metricsPrivate.userActions_ = [];
// Click first row which is 'photos' dir, wait for breadcrumb to show.
assertTrue(test.fakeMouseDoubleClick('#file-list li.table-row'));
await test.waitForElement(
'#location-breadcrumbs .breadcrumb-path:nth-of-type(2)');
// Click breadcrumb to return to parent dir.
assertTrue(test.fakeMouseClick(
'#location-breadcrumbs .breadcrumb-path:nth-of-type(1)'));
await test.waitForFiles(
test.TestEntryInfo.getExpectedRows(test.BASIC_LOCAL_ENTRY_SET));
assertArrayEquals(
['FileBrowser.ClickBreadcrumbs'], chrome.metricsPrivate.userActions_);
done();
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment