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