Commit 745b1ed8 authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Convert gear_menu.js to use async-await.

Bug: 909056
Change-Id: Ic571f2d16d9d906bc176d34f539e53f57b2acbb3
Reviewed-on: https://chromium-review.googlesource.com/c/1355301Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Sam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612530}
parent a1b95211
...@@ -71,11 +71,10 @@ const BASIC_DRIVE_ENTRY_SET_WITHOUT_GDOCS = [ ...@@ -71,11 +71,10 @@ const BASIC_DRIVE_ENTRY_SET_WITHOUT_GDOCS = [
* @param {!Array<!TestEntryInfo>} basicSet Files expected before showing hidden * @param {!Array<!TestEntryInfo>} basicSet Files expected before showing hidden
* @param {!Array<!TestEntryInfo>} hiddenEntrySet Files expected after showing * @param {!Array<!TestEntryInfo>} hiddenEntrySet Files expected after showing
* hidden * hidden
* @return {!Array} The test steps to toggle hidden files
*/ */
function getTestCaseStepsForHiddenFiles(basicSet, hiddenEntrySet) { function runHiddenFilesTest(appId, basicSet, hiddenEntrySet) {
return getTestCaseStepsForHiddenFilesWithMenuItem( return runHiddenFilesTestWithMenuItem(
basicSet, hiddenEntrySet, '#gear-menu-toggle-hidden-files'); appId, basicSet, hiddenEntrySet, '#gear-menu-toggle-hidden-files');
} }
/** /**
...@@ -83,11 +82,11 @@ function getTestCaseStepsForHiddenFiles(basicSet, hiddenEntrySet) { ...@@ -83,11 +82,11 @@ function getTestCaseStepsForHiddenFiles(basicSet, hiddenEntrySet) {
* @param {!Array<!TestEntryInfo>} basicSet Files expected before showing hidden * @param {!Array<!TestEntryInfo>} basicSet Files expected before showing hidden
* @param {!Array<!TestEntryInfo>} hiddenEntrySet Files expected after showing * @param {!Array<!TestEntryInfo>} hiddenEntrySet Files expected after showing
* hidden * hidden
* @return {!Array} The test steps to toggle hidden files
*/ */
function getTestCaseStepsForAndroidHiddenFiles(basicSet, hiddenEntrySet) { function runAndroidHiddenFilesTest(appId, basicSet, hiddenEntrySet) {
return getTestCaseStepsForHiddenFilesWithMenuItem( return runHiddenFilesTestWithMenuItem(
basicSet, hiddenEntrySet, '#gear-menu-toggle-hidden-android-folders'); appId, basicSet, hiddenEntrySet,
'#gear-menu-toggle-hidden-android-folders');
} }
/** /**
...@@ -97,669 +96,377 @@ function getTestCaseStepsForAndroidHiddenFiles(basicSet, hiddenEntrySet) { ...@@ -97,669 +96,377 @@ function getTestCaseStepsForAndroidHiddenFiles(basicSet, hiddenEntrySet) {
* hidden * hidden
* @param {string} toggleMenuItemSelector Selector for the menu item that * @param {string} toggleMenuItemSelector Selector for the menu item that
* toggles hidden file visibility * toggles hidden file visibility
* @return {!Array} The test steps to toggle hidden files
*/ */
function getTestCaseStepsForHiddenFilesWithMenuItem( async function runHiddenFilesTestWithMenuItem(
basicSet, hiddenEntrySet, toggleMenuItemSelector) { appId, basicSet, hiddenEntrySet, toggleMenuItemSelector) {
var appId; await remoteCall.waitForElement(appId, '#gear-button:not([hidden])');
return [
function(id) {
appId = id;
remoteCall.waitForElement(appId, '#gear-button:not([hidden])')
.then(this.next);
},
// Open the gear menu by clicking the gear button. // Open the gear menu by clicking the gear button.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#gear-button']));
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Wait for menu to not be hidden. // Wait for menu to not be hidden.
function(result) { await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])')
.then(this.next);
},
// Wait for menu item to appear. // Wait for menu item to appear.
function(result) { await remoteCall.waitForElement(
remoteCall appId, toggleMenuItemSelector + ':not([disabled])');
.waitForElement(appId, toggleMenuItemSelector + ':not([disabled])')
.then(this.next);
},
// Wait for menu item to appear. // Wait for menu item to appear.
function(result) { await remoteCall.waitForElement(
remoteCall appId, toggleMenuItemSelector + ':not([checked])');
.waitForElement(appId, toggleMenuItemSelector + ':not([checked])')
.then(this.next);
},
// Click the menu item. // Click the menu item.
function(results) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, [toggleMenuItemSelector]));
'fakeMouseClick', appId, [toggleMenuItemSelector], this.next);
},
// Wait for item to be checked. // Wait for item to be checked.
function(result) { await remoteCall.waitForElement(appId, toggleMenuItemSelector + '[checked]');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, toggleMenuItemSelector + '[checked]')
.then(this.next);
},
// Check the hidden files are displayed. // Check the hidden files are displayed.
function(result) { await remoteCall.waitForFiles(
remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows( appId, TestEntryInfo.getExpectedRows(hiddenEntrySet),
hiddenEntrySet), {ignoreFileSize: true, ignoreLastModifiedTime: true}) {ignoreFileSize: true, ignoreLastModifiedTime: true});
.then(this.next);
},
// Repeat steps to toggle again. // Repeat steps to toggle again.
function(inAppId) { await remoteCall.waitForElement(appId, '#gear-button:not([hidden])');
remoteCall.waitForElement(appId, '#gear-button:not([hidden])') chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
.then(this.next); 'fakeMouseClick', appId, ['#gear-button']));
},
function() { await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
remoteCall.callRemoteTestUtil( await remoteCall.waitForElement(
'fakeMouseClick', appId, ['#gear-button'], this.next); appId, toggleMenuItemSelector + ':not([disabled])');
}, await remoteCall.waitForElement(appId, toggleMenuItemSelector + '[checked]');
function(result) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
chrome.test.assertTrue(result); 'fakeMouseClick', appId, [toggleMenuItemSelector]));
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])').then(
this.next); await remoteCall.waitForElement(
}, appId, toggleMenuItemSelector + ':not([checked])');
function(result) { await remoteCall.waitForFiles(
remoteCall appId, TestEntryInfo.getExpectedRows(basicSet),
.waitForElement(appId, toggleMenuItemSelector + ':not([disabled])') {ignoreFileSize: true, ignoreLastModifiedTime: true});
.then(this.next);
},
function(result) {
remoteCall.waitForElement(appId, toggleMenuItemSelector + '[checked]')
.then(this.next);
},
function(results) {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, [toggleMenuItemSelector], this.next);
},
function(result) {
chrome.test.assertTrue(result);
remoteCall
.waitForElement(appId, toggleMenuItemSelector + ':not([checked])')
.then(this.next);
},
function(result) {
remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows(basicSet),
{ignoreFileSize: true, ignoreLastModifiedTime: true}).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
];
} }
/** /**
* Tests toggling the show-hidden-files menu option on Downloads. * Tests toggling the show-hidden-files menu option on Downloads.
*/ */
testcase.showHiddenFilesDownloads = function() { testcase.showHiddenFilesDownloads = async function() {
var appId; const {appId} = await setupAndWaitUntilReady(
var steps = [ null, RootPath.DOWNLOADS, null, BASIC_LOCAL_ENTRY_SET_WITH_HIDDEN, []);
function() {
addEntries(['local'], BASIC_LOCAL_ENTRY_SET_WITH_HIDDEN, this.next);
},
function(result) {
chrome.test.assertTrue(result);
openNewWindow(null, RootPath.DOWNLOADS).then(this.next);
},
function(inAppId) {
appId = inAppId;
remoteCall.waitForElement(appId, '#detail-table').then(this.next);
},
// Wait for volume list to be initialized.
function() {
remoteCall.waitForFileListChange(appId, 0).then(this.next);
},
function() {
this.next(appId);
},
];
steps = steps.concat(getTestCaseStepsForHiddenFiles(BASIC_LOCAL_ENTRY_SET,
BASIC_LOCAL_ENTRY_SET_WITH_HIDDEN));
StepsRunner.run(steps);
};
await runHiddenFilesTest(
appId, BASIC_LOCAL_ENTRY_SET, BASIC_LOCAL_ENTRY_SET_WITH_HIDDEN);
};
/** /**
* Tests toggling the show-hidden-files menu option on Drive. * Tests toggling the show-hidden-files menu option on Drive.
*/ */
testcase.showHiddenFilesDrive = function() { testcase.showHiddenFilesDrive = async function() {
var appId; const {appId} = await setupAndWaitUntilReady(
var steps = [ null, RootPath.DRIVE, null, [], BASIC_DRIVE_ENTRY_SET_WITH_HIDDEN);
function() {
addEntries(['drive'], BASIC_DRIVE_ENTRY_SET_WITH_HIDDEN, this.next); await runHiddenFilesTest(
}, appId, BASIC_DRIVE_ENTRY_SET, BASIC_DRIVE_ENTRY_SET_WITH_HIDDEN);
function(result) {
chrome.test.assertTrue(result);
openNewWindow(null, RootPath.DRIVE).then(this.next);
},
function(inAppId) {
appId = inAppId;
remoteCall.waitForElement(appId, '#detail-table').then(this.next);
},
// Wait for volume list to be initialized.
function() {
remoteCall.waitForFileListChange(appId, 0).then(this.next);
},
function() {
this.next(appId);
},
];
steps = steps.concat(getTestCaseStepsForHiddenFiles(BASIC_DRIVE_ENTRY_SET,
BASIC_DRIVE_ENTRY_SET_WITH_HIDDEN));
StepsRunner.run(steps);
}; };
/** /**
* Tests that toggle-hidden-android-folders menu item exists when "Play files" * Tests that toggle-hidden-android-folders menu item exists when "Play files"
* is selected, but hidden in Recents. * is selected, but hidden in Recents.
*/ */
testcase.showToggleHiddenAndroidFoldersGearMenuItemsInMyFiles = function() { testcase.showToggleHiddenAndroidFoldersGearMenuItemsInMyFiles =
var appId; async function() {
StepsRunner.run([
// Open Files.App on Play Files. // Open Files.App on Play Files.
function() { const appId = await openNewWindow(null, RootPath.ANDROID_FILES);
openNewWindow(null, RootPath.ANDROID_FILES).then(this.next); await addEntries(['android_files'], BASIC_ANDROID_ENTRY_SET);
},
function(inAppId) {
appId = inAppId;
addEntries(['android_files'], BASIC_ANDROID_ENTRY_SET, this.next);
},
// Wait for the file list to appear. // Wait for the file list to appear.
function(result) { await remoteCall.waitForElement(appId, '#file-list');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#file-list').then(this.next);
},
// Wait for the gear menu button to appear. // Wait for the gear menu button to appear.
function() { await remoteCall.waitForElement(appId, '#gear-button:not([hidden])');
remoteCall.waitForElement(appId, '#gear-button:not([hidden])')
.then(this.next);
},
// Click the gear menu button. // Click the gear menu button.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#gear-button']));
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Wait for the gear menu to appear. // Wait for the gear menu to appear.
function(result) { await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])')
.then(this.next);
},
// #toggle-hidden-android-folders command should be shown and disabled by // #toggle-hidden-android-folders command should be shown and disabled by
// default. // default.
function() { await remoteCall.waitForElement(
remoteCall
.waitForElement(
appId, appId,
'#gear-menu-toggle-hidden-android-folders' + '#gear-menu-toggle-hidden-android-folders' +
':not([checked]):not([hidden])') ':not([checked]):not([hidden])');
.then(this.next);
},
// Click the file list: the gear menu should hide. // Click the file list: the gear menu should hide.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#file-list']));
'fakeMouseClick', appId, ['#file-list'], this.next);
},
// Wait for the gear menu to hide. // Wait for the gear menu to hide.
function(result) { await remoteCall.waitForElement(appId, '#gear-menu[hidden]');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next);
},
// Navigate to Recent. // Navigate to Recent.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['span[root-type-icon=\'recent\']']));
'fakeMouseClick', appId, ['span[root-type-icon=\'recent\']'],
this.next);
},
// Click the gear menu button. // Click the gear menu button.
function(result) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
chrome.test.assertTrue(result); 'fakeMouseClick', appId, ['#gear-button']));
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Wait for the gear menu to appear. // Wait for the gear menu to appear.
function(result) { await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])')
.then(this.next);
},
// #toggle-hidden-android-folders command should be hidden. // #toggle-hidden-android-folders command should be hidden.
function(result) { await remoteCall.waitForElement(
remoteCall appId, '#gear-menu-toggle-hidden-android-folders[hidden]');
.waitForElement(
appId, '#gear-menu-toggle-hidden-android-folders[hidden]')
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests that "Play files" shows the full set of files after * Tests that "Play files" shows the full set of files after
* toggle-hidden-android-folders is enabled. * toggle-hidden-android-folders is enabled.
*/ */
testcase.enableToggleHiddenAndroidFoldersShowsHiddenFiles = function() { testcase.enableToggleHiddenAndroidFoldersShowsHiddenFiles = async function() {
var appId;
var steps = [
// Open Files.App on Play Files. // Open Files.App on Play Files.
function() { const appId = await openNewWindow(null, RootPath.ANDROID_FILES);
openNewWindow(null, RootPath.ANDROID_FILES).then(this.next); await addEntries(['android_files'], BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN);
},
function(inAppId) {
appId = inAppId;
addEntries(
['android_files'], BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN, this.next);
},
// Wait for the file list to appear. // Wait for the file list to appear.
function(result) { await remoteCall.waitForElement(appId, '#file-list');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#file-list').then(this.next);
},
// Wait for the gear menu button to appear. // Wait for the gear menu button to appear.
function() { await remoteCall.waitForElement(appId, '#gear-button:not([hidden])');
remoteCall.waitForElement(appId, '#gear-button:not([hidden])') await runAndroidHiddenFilesTest(
.then(this.next); appId, BASIC_ANDROID_ENTRY_SET, BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN);
},
function() {
this.next(appId);
}
];
steps = steps.concat(getTestCaseStepsForAndroidHiddenFiles(
BASIC_ANDROID_ENTRY_SET, BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN));
StepsRunner.run(steps);
}; };
/** /**
* Tests that the current directory is changed to "Play files" after the * Tests that the current directory is changed to "Play files" after the
* current directory is hidden by toggle-hidden-android-folders option. * current directory is hidden by toggle-hidden-android-folders option.
*/ */
testcase.hideCurrentDirectoryByTogglingHiddenAndroidFolders = function() { testcase.hideCurrentDirectoryByTogglingHiddenAndroidFolders = async function() {
let appId;
const MENU_ITEM_SELECTOR = '#gear-menu-toggle-hidden-android-folders'; const MENU_ITEM_SELECTOR = '#gear-menu-toggle-hidden-android-folders';
const steps = [ const appId = await openNewWindow(null, RootPath.ANDROID_FILES);
function() { await addEntries(['android_files'], BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN);
openNewWindow(null, RootPath.ANDROID_FILES).then(this.next);
},
function(inAppId) {
appId = inAppId;
addEntries(
['android_files'], BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN, this.next);
},
// Wait for the file list to appear. // Wait for the file list to appear.
function(result) { await remoteCall.waitForElement(appId, '#file-list');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#file-list').then(this.next);
},
// Wait for the gear menu button to appear. // Wait for the gear menu button to appear.
function() { await remoteCall.waitForElement(appId, '#gear-button:not([hidden])');
remoteCall.waitForElement(appId, '#gear-button:not([hidden])')
.then(this.next);
},
// Open the gear menu by clicking the gear button. // Open the gear menu by clicking the gear button.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#gear-button']));
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Wait for menu to not be hidden. // Wait for menu to not be hidden.
function(result) { await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])')
.then(this.next);
},
// Wait for menu item to appear. // Wait for menu item to appear.
function() { await remoteCall.waitForElement(
remoteCall appId, MENU_ITEM_SELECTOR + ':not([disabled]):not([checked])');
.waitForElement(
appId, MENU_ITEM_SELECTOR + ':not([disabled]):not([checked])')
.then(this.next);
},
// Click the menu item. // Click the menu item.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, [MENU_ITEM_SELECTOR]));
'fakeMouseClick', appId, [MENU_ITEM_SELECTOR], this.next);
},
// Wait for item to be checked. // Wait for item to be checked.
function(result) { await remoteCall.waitForElement(appId, MENU_ITEM_SELECTOR + '[checked]');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, MENU_ITEM_SELECTOR + '[checked]')
.then(this.next);
},
// Check the hidden files are displayed. // Check the hidden files are displayed.
function() { await remoteCall.waitForFiles(
remoteCall appId, TestEntryInfo.getExpectedRows(BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN),
.waitForFiles( {ignoreFileSize: true, ignoreLastModifiedTime: true});
appId,
TestEntryInfo.getExpectedRows(
BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN),
{ignoreFileSize: true, ignoreLastModifiedTime: true})
.then(this.next);
},
// Navigate to "/My files/Play files/A". // Navigate to "/My files/Play files/A".
function() { await remoteCall.navigateWithDirectoryTree(
remoteCall appId, '/A', 'My files/Play files', 'android_files');
.navigateWithDirectoryTree(
appId, '/A', 'My files/Play files', 'android_files')
.then(this.next);
},
// Wait until current directory is changed to "/My files/Play files/A". // Wait until current directory is changed to "/My files/Play files/A".
function() { await remoteCall.waitUntilCurrentDirectoryIsChanged(
remoteCall appId, '/My files/Play files/A');
.waitUntilCurrentDirectoryIsChanged(appId, '/My files/Play files/A')
.then(this.next);
},
// Open the gear menu by clicking the gear button. // Open the gear menu by clicking the gear button.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#gear-button']));
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Wait for menu to not be hidden. // Wait for menu to not be hidden.
function(result) { await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])')
.then(this.next);
},
// Wait for menu item to appear. // Wait for menu item to appear.
function() { await remoteCall.waitForElement(
remoteCall appId, MENU_ITEM_SELECTOR + '[checked]:not([disabled])');
.waitForElement(
appId, MENU_ITEM_SELECTOR + '[checked]:not([disabled])')
.then(this.next);
},
// Click the menu item. // Click the menu item.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, [MENU_ITEM_SELECTOR]));
'fakeMouseClick', appId, [MENU_ITEM_SELECTOR], this.next);
},
// Wait until the current directory is changed from // Wait until the current directory is changed from
// "/My files/Play files/A" to "/My files/Play files" since // "/My files/Play files/A" to "/My files/Play files" since
// "/My files/Play files/A" is invisible now. // "/My files/Play files/A" is invisible now.
function(result) { await remoteCall.waitUntilCurrentDirectoryIsChanged(
chrome.test.assertTrue(result); appId, '/My files/Play files');
remoteCall
.waitUntilCurrentDirectoryIsChanged(appId, '/My files/Play files')
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
];
StepsRunner.run(steps);
}; };
/** /**
* Tests the paste-into-current-folder menu item. * Tests the paste-into-current-folder menu item.
*/ */
testcase.showPasteIntoCurrentFolder = function() { testcase.showPasteIntoCurrentFolder = async function() {
const entrySet = [ENTRIES.hello, ENTRIES.world]; const entrySet = [ENTRIES.hello, ENTRIES.world];
var appId;
StepsRunner.run([
// Add files to Downloads volume. // Add files to Downloads volume.
function() { await addEntries(['local'], entrySet);
addEntries(['local'], entrySet, this.next);
},
// Open Files.App on Downloads. // Open Files.App on Downloads.
function(result) { const appId = await openNewWindow(null, RootPath.DOWNLOADS);
chrome.test.assertTrue(result); await remoteCall.waitForElement(appId, '#file-list');
openNewWindow(null, RootPath.DOWNLOADS).then(this.next);
},
function(inAppId) {
appId = inAppId;
remoteCall.waitForElement(appId, '#file-list').then(this.next);
},
// Wait for the files to appear in the file list. // Wait for the files to appear in the file list.
function() { await remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows(entrySet));
remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows(entrySet))
.then(this.next);
},
// Wait for the gear menu button to appear. // Wait for the gear menu button to appear.
function() { await remoteCall.waitForElement(appId, '#gear-button');
remoteCall.waitForElement(appId, '#gear-button').then(this.next);
},
// 1. Before selecting entries: click the gear menu button. // 1. Before selecting entries: click the gear menu button.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#gear-button']));
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Wait for the gear menu to appear. // Wait for the gear menu to appear.
function(result) { await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])')
.then(this.next);
},
// #paste-into-current-folder command is shown. It should be disabled // #paste-into-current-folder command is shown. It should be disabled
// because no file has been copied to clipboard. // because no file has been copied to clipboard.
function(result) { await remoteCall.waitForElement(
remoteCall
.waitForElement(
appId, appId,
'#gear-menu cr-menu-item' + '#gear-menu cr-menu-item' +
'[command=\'#paste-into-current-folder\']' + '[command=\'#paste-into-current-folder\']' +
'[disabled]:not([hidden])') '[disabled]:not([hidden])');
.then(this.next); chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
}, 'fakeMouseClick', appId, ['#file-list']));
function() {
remoteCall.callRemoteTestUtil( await remoteCall.waitForElement(appId, '#gear-menu[hidden]');
'fakeMouseClick', appId, ['#file-list'], this.next);
},
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next);
},
// 2. Selecting a single regular file // 2. Selecting a single regular file
function(result) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'selectFile', appId, [ENTRIES.hello.nameText]));
'selectFile', appId, [ENTRIES.hello.nameText], this.next);
}, chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
function(result) { 'fakeMouseClick', appId, ['#gear-button']));
chrome.test.assertTrue(result);
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Wait for menu to appear. // Wait for menu to appear.
// The command is still shown. // The command is still shown.
function(result) { await remoteCall.waitForElement(
chrome.test.assertTrue(result);
remoteCall
.waitForElement(
appId, appId,
'#gear-menu:not([hidden]) cr-menu-item' + '#gear-menu:not([hidden]) cr-menu-item' +
'[command=\'#paste-into-current-folder\']' + '[command=\'#paste-into-current-folder\']' +
'[disabled]:not([hidden])') '[disabled]:not([hidden])');
.then(this.next); chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
}, 'fakeMouseClick', appId, ['#file-list']));
function() {
remoteCall.callRemoteTestUtil( await remoteCall.waitForElement(appId, '#gear-menu[hidden]');
'fakeMouseClick', appId, ['#file-list'], this.next);
},
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next);
},
// 3. When ready to paste a file // 3. When ready to paste a file
function(result) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'selectFile', appId, [ENTRIES.hello.nameText]));
'selectFile', appId, [ENTRIES.hello.nameText], this.next);
},
// Ctrl-C to copy the selected file // Ctrl-C to copy the selected file
function(result) { await remoteCall.fakeKeyDown(appId, '#file-list', 'c', true, false, false);
chrome.test.assertTrue(result); chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall 'fakeMouseClick', appId, ['#gear-button']));
.fakeKeyDown(appId, '#file-list', 'c', true, false, false)
.then(this.next);
},
function() {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// The command appears enabled. // The command appears enabled.
function(result) { await remoteCall.waitForElement(
chrome.test.assertTrue(result);
remoteCall
.waitForElement(
appId, appId,
'#gear-menu:not([hidden])' + '#gear-menu:not([hidden])' +
' cr-menu-item[command=\'#paste-into-current-folder\']' + ' cr-menu-item[command=\'#paste-into-current-folder\']' +
':not([disabled]):not([hidden])') ':not([disabled]):not([hidden])');
.then(this.next); chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
}, 'fakeMouseClick', appId, ['#file-list']));
function() {
remoteCall.callRemoteTestUtil( await remoteCall.waitForElement(appId, '#gear-menu[hidden]');
'fakeMouseClick', appId, ['#file-list'], this.next);
},
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests the "select-all" menu item. * Tests the "select-all" menu item.
*/ */
testcase.showSelectAllInCurrentFolder = function() { testcase.showSelectAllInCurrentFolder = async function() {
const entrySet = [ENTRIES.newlyAdded]; const entrySet = [ENTRIES.newlyAdded];
var appId;
StepsRunner.run([
// Open Files.App on Downloads. // Open Files.App on Downloads.
function() { const appId = await openNewWindow(null, RootPath.DOWNLOADS);
openNewWindow(null, RootPath.DOWNLOADS).then(this.next); await remoteCall.waitForElement(appId, '#file-list');
},
function(inAppId) {
appId = inAppId;
remoteCall.waitForElement(appId, '#file-list').then(this.next);
},
// Wait for the gear menu button to appear. // Wait for the gear menu button to appear.
function() { await remoteCall.waitForElement(appId, '#gear-button');
remoteCall.waitForElement(appId, '#gear-button').then(this.next);
},
// Click the gear menu button. // Click the gear menu button.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#gear-button']));
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Wait for the gear menu to appear. // Wait for the gear menu to appear.
function(result) { await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])')
.then(this.next);
},
// Check: #select-all command is shown, but disabled (no files yet). // Check: #select-all command is shown, but disabled (no files yet).
function(result) { await remoteCall.waitForElement(
remoteCall
.waitForElement(
appId, appId,
'#gear-menu cr-menu-item' + '#gear-menu cr-menu-item' +
'[command=\'#select-all\']' + '[command=\'#select-all\']' +
'[disabled]:not([hidden])') '[disabled]:not([hidden])');
.then(this.next);
},
// Click the file list: the gear menu should hide. // Click the file list: the gear menu should hide.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#file-list']));
'fakeMouseClick', appId, ['#file-list'], this.next);
},
// Wait for the gear menu to hide. // Wait for the gear menu to hide.
function(result) { await remoteCall.waitForElement(appId, '#gear-menu[hidden]');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next);
},
// Add a new file to Downloads. // Add a new file to Downloads.
function() { await addEntries(['local'], entrySet);
addEntries(['local'], entrySet, this.next);
},
// Wait for the file list change. // Wait for the file list change.
function(result) { await remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows(entrySet));
chrome.test.assertTrue(result);
remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows(entrySet))
.then(this.next);
},
// Click on the gear button again. // Click on the gear button again.
function(result) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#gear-button']));
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Check: #select-all command is shown, and enabled (there are files). // Check: #select-all command is shown, and enabled (there are files).
function(result) { await remoteCall.waitForElement(
chrome.test.assertTrue(result);
remoteCall
.waitForElement(
appId, appId,
'#gear-menu:not([hidden]) cr-menu-item' + '#gear-menu:not([hidden]) cr-menu-item' +
'[command=\'#select-all\']' + '[command=\'#select-all\']' +
':not([disabled]):not([hidden])') ':not([disabled]):not([hidden])');
.then(this.next);
},
// Click on the #gear-menu-select-all item. // Click on the #gear-menu-select-all item.
function(results) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#gear-menu-select-all']));
'fakeMouseClick', appId, ['#gear-menu-select-all'], this.next);
},
// Check: the file-list should be selected. // Check: the file-list should be selected.
function(result) { await remoteCall.waitForElement(appId, '#file-list li[selected]');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#file-list li[selected]')
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests that new folder appears in the gear menu with Downloads focused in the * Tests that new folder appears in the gear menu with Downloads focused in the
* directory tree. * directory tree.
*/ */
testcase.newFolderInDownloads = function() { testcase.newFolderInDownloads = async function() {
var appId; const {appId} = await setupAndWaitUntilReady(
StepsRunner.run([ null, RootPath.DOWNLOADS, null, [ENTRIES.hello], []);
function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, null, [ENTRIES.hello], [
]).then(this.next);
},
// Focus the directory tree. // Focus the directory tree.
function(results) { await remoteCall.callRemoteTestUtil('focus', appId, ['#directory-tree']);
appId = results.windowId;
remoteCall.callRemoteTestUtil('focus', appId, ['#directory-tree'])
.then(this.next);
},
// Open the gear menu. // Open the gear menu.
function() { await remoteCall.waitForElement(appId, '#gear-button');
remoteCall.waitForElement(appId, '#gear-button').then(this.next);
},
// Open the gear meny by a shortcut (Alt-E). // Open the gear meny by a shortcut (Alt-E).
function() { chrome.test.assertTrue(
remoteCall.fakeKeyDown(appId, 'body', 'e', false, false, true) await remoteCall.fakeKeyDown(appId, 'body', 'e', false, false, true));
.then(this.next);
},
// Wait for menu to appear. // Wait for menu to appear.
function(result) { await remoteCall.waitForElement(appId, '#gear-menu');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu').then(this.next);
},
// Wait for menu to appear, containing new folder. // Wait for menu to appear, containing new folder.
function(result) { await remoteCall.waitForElement(
remoteCall appId, '#gear-menu-newfolder:not([disabled]):not([hidden])');
.waitForElement(
appId, '#gear-menu-newfolder:not([disabled]):not([hidden])')
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
}
]);
}; };
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