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) { // Open the gear menu by clicking the gear button.
appId = id; chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.waitForElement(appId, '#gear-button:not([hidden])') 'fakeMouseClick', appId, ['#gear-button']));
.then(this.next);
}, // Wait for menu to not be hidden.
// Open the gear menu by clicking the gear button. await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
function() {
remoteCall.callRemoteTestUtil( // Wait for menu item to appear.
'fakeMouseClick', appId, ['#gear-button'], this.next); await remoteCall.waitForElement(
}, appId, toggleMenuItemSelector + ':not([disabled])');
// Wait for menu to not be hidden.
function(result) { // Wait for menu item to appear.
chrome.test.assertTrue(result); await remoteCall.waitForElement(
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])') appId, toggleMenuItemSelector + ':not([checked])');
.then(this.next);
}, // Click the menu item.
// Wait for menu item to appear. chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
function(result) { 'fakeMouseClick', appId, [toggleMenuItemSelector]));
remoteCall
.waitForElement(appId, toggleMenuItemSelector + ':not([disabled])') // Wait for item to be checked.
.then(this.next); await remoteCall.waitForElement(appId, toggleMenuItemSelector + '[checked]');
},
// Wait for menu item to appear. // Check the hidden files are displayed.
function(result) { await remoteCall.waitForFiles(
remoteCall appId, TestEntryInfo.getExpectedRows(hiddenEntrySet),
.waitForElement(appId, toggleMenuItemSelector + ':not([checked])') {ignoreFileSize: true, ignoreLastModifiedTime: true});
.then(this.next);
}, // Repeat steps to toggle again.
// Click the menu item. await remoteCall.waitForElement(appId, '#gear-button:not([hidden])');
function(results) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#gear-button']));
'fakeMouseClick', appId, [toggleMenuItemSelector], this.next);
}, await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
// Wait for item to be checked. await remoteCall.waitForElement(
function(result) { appId, toggleMenuItemSelector + ':not([disabled])');
chrome.test.assertTrue(result); await remoteCall.waitForElement(appId, toggleMenuItemSelector + '[checked]');
remoteCall.waitForElement(appId, toggleMenuItemSelector + '[checked]') chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
.then(this.next); 'fakeMouseClick', appId, [toggleMenuItemSelector]));
},
// Check the hidden files are displayed. await remoteCall.waitForElement(
function(result) { appId, toggleMenuItemSelector + ':not([checked])');
remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows( await remoteCall.waitForFiles(
hiddenEntrySet), {ignoreFileSize: true, ignoreLastModifiedTime: true}) appId, TestEntryInfo.getExpectedRows(basicSet),
.then(this.next); {ignoreFileSize: true, ignoreLastModifiedTime: true});
},
// Repeat steps to toggle again.
function(inAppId) {
remoteCall.waitForElement(appId, '#gear-button:not([hidden])')
.then(this.next);
},
function() {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])').then(
this.next);
},
function(result) {
remoteCall
.waitForElement(appId, toggleMenuItemSelector + ':not([disabled])')
.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. const appId = await openNewWindow(null, RootPath.ANDROID_FILES);
function() { await addEntries(['android_files'], BASIC_ANDROID_ENTRY_SET);
openNewWindow(null, RootPath.ANDROID_FILES).then(this.next);
}, // Wait for the file list to appear.
function(inAppId) { await remoteCall.waitForElement(appId, '#file-list');
appId = inAppId;
addEntries(['android_files'], BASIC_ANDROID_ENTRY_SET, this.next); // Wait for the gear menu button to appear.
}, await remoteCall.waitForElement(appId, '#gear-button:not([hidden])');
// Wait for the file list to appear.
function(result) { // Click the gear menu button.
chrome.test.assertTrue(result); chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.waitForElement(appId, '#file-list').then(this.next); 'fakeMouseClick', appId, ['#gear-button']));
},
// Wait for the gear menu button to appear. // Wait for the gear menu to appear.
function() { await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
remoteCall.waitForElement(appId, '#gear-button:not([hidden])')
.then(this.next); // #toggle-hidden-android-folders command should be shown and disabled by
}, // default.
// Click the gear menu button. await remoteCall.waitForElement(
function() { appId,
remoteCall.callRemoteTestUtil( '#gear-menu-toggle-hidden-android-folders' +
'fakeMouseClick', appId, ['#gear-button'], this.next); ':not([checked]):not([hidden])');
},
// Wait for the gear menu to appear. // Click the file list: the gear menu should hide.
function(result) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
chrome.test.assertTrue(result); 'fakeMouseClick', appId, ['#file-list']));
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])')
.then(this.next); // Wait for the gear menu to hide.
}, await remoteCall.waitForElement(appId, '#gear-menu[hidden]');
// #toggle-hidden-android-folders command should be shown and disabled by
// default. // Navigate to Recent.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall 'fakeMouseClick', appId, ['span[root-type-icon=\'recent\']']));
.waitForElement(
appId, // Click the gear menu button.
'#gear-menu-toggle-hidden-android-folders' + chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
':not([checked]):not([hidden])') 'fakeMouseClick', appId, ['#gear-button']));
.then(this.next);
}, // Wait for the gear menu to appear.
// Click the file list: the gear menu should hide. await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
function() {
remoteCall.callRemoteTestUtil( // #toggle-hidden-android-folders command should be hidden.
'fakeMouseClick', appId, ['#file-list'], this.next); await remoteCall.waitForElement(
}, appId, '#gear-menu-toggle-hidden-android-folders[hidden]');
// Wait for the gear menu to hide.
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next);
},
// Navigate to Recent.
function() {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['span[root-type-icon=\'recent\']'],
this.next);
},
// Click the gear menu button.
function(result) {
chrome.test.assertTrue(result);
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Wait for the gear menu to appear.
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])')
.then(this.next);
},
// #toggle-hidden-android-folders command should be hidden.
function(result) {
remoteCall
.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; // Open Files.App on Play Files.
var steps = [ const appId = await openNewWindow(null, RootPath.ANDROID_FILES);
// Open Files.App on Play Files. await addEntries(['android_files'], BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN);
function() {
openNewWindow(null, RootPath.ANDROID_FILES).then(this.next); // Wait for the file list to appear.
}, await remoteCall.waitForElement(appId, '#file-list');
function(inAppId) {
appId = inAppId; // Wait for the gear menu button to appear.
addEntries( await remoteCall.waitForElement(appId, '#gear-button:not([hidden])');
['android_files'], BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN, this.next); await runAndroidHiddenFilesTest(
}, appId, BASIC_ANDROID_ENTRY_SET, BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN);
// Wait for the file list to appear.
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#file-list').then(this.next);
},
// Wait for the gear menu button to appear.
function() {
remoteCall.waitForElement(appId, '#gear-button:not([hidden])')
.then(this.next);
},
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);
}, // Wait for the file list to appear.
function(inAppId) { await remoteCall.waitForElement(appId, '#file-list');
appId = inAppId;
addEntries( // Wait for the gear menu button to appear.
['android_files'], BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN, this.next); await remoteCall.waitForElement(appId, '#gear-button:not([hidden])');
},
// Wait for the file list to appear. // Open the gear menu by clicking the gear button.
function(result) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
chrome.test.assertTrue(result); 'fakeMouseClick', appId, ['#gear-button']));
remoteCall.waitForElement(appId, '#file-list').then(this.next);
}, // Wait for menu to not be hidden.
// Wait for the gear menu button to appear. await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
function() {
remoteCall.waitForElement(appId, '#gear-button:not([hidden])') // Wait for menu item to appear.
.then(this.next); await remoteCall.waitForElement(
}, appId, MENU_ITEM_SELECTOR + ':not([disabled]):not([checked])');
// Open the gear menu by clicking the gear button.
function() { // Click the menu item.
remoteCall.callRemoteTestUtil( chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-button'], this.next); 'fakeMouseClick', appId, [MENU_ITEM_SELECTOR]));
},
// Wait for menu to not be hidden. // Wait for item to be checked.
function(result) { await remoteCall.waitForElement(appId, MENU_ITEM_SELECTOR + '[checked]');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])') // Check the hidden files are displayed.
.then(this.next); await remoteCall.waitForFiles(
}, appId, TestEntryInfo.getExpectedRows(BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN),
// Wait for menu item to appear. {ignoreFileSize: true, ignoreLastModifiedTime: true});
function() {
remoteCall // Navigate to "/My files/Play files/A".
.waitForElement( await remoteCall.navigateWithDirectoryTree(
appId, MENU_ITEM_SELECTOR + ':not([disabled]):not([checked])') appId, '/A', 'My files/Play files', 'android_files');
.then(this.next);
}, // Wait until current directory is changed to "/My files/Play files/A".
// Click the menu item. await remoteCall.waitUntilCurrentDirectoryIsChanged(
function() { appId, '/My files/Play files/A');
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, [MENU_ITEM_SELECTOR], this.next); // Open the gear menu by clicking the gear button.
}, chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
// Wait for item to be checked. 'fakeMouseClick', appId, ['#gear-button']));
function(result) {
chrome.test.assertTrue(result); // Wait for menu to not be hidden.
remoteCall.waitForElement(appId, MENU_ITEM_SELECTOR + '[checked]') await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
.then(this.next);
}, // Wait for menu item to appear.
// Check the hidden files are displayed. await remoteCall.waitForElement(
function() { appId, MENU_ITEM_SELECTOR + '[checked]:not([disabled])');
remoteCall
.waitForFiles( // Click the menu item.
appId, chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
TestEntryInfo.getExpectedRows( 'fakeMouseClick', appId, [MENU_ITEM_SELECTOR]));
BASIC_ANDROID_ENTRY_SET_WITH_HIDDEN),
{ignoreFileSize: true, ignoreLastModifiedTime: true}) // Wait until the current directory is changed from
.then(this.next); // "/My files/Play files/A" to "/My files/Play files" since
}, // "/My files/Play files/A" is invisible now.
// Navigate to "/My files/Play files/A". await remoteCall.waitUntilCurrentDirectoryIsChanged(
function() { appId, '/My files/Play files');
remoteCall
.navigateWithDirectoryTree(
appId, '/A', 'My files/Play files', 'android_files')
.then(this.next);
},
// Wait until current directory is changed to "/My files/Play files/A".
function() {
remoteCall
.waitUntilCurrentDirectoryIsChanged(appId, '/My files/Play files/A')
.then(this.next);
},
// Open the gear menu by clicking the gear button.
function() {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Wait for menu to not be hidden.
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])')
.then(this.next);
},
// Wait for menu item to appear.
function() {
remoteCall
.waitForElement(
appId, MENU_ITEM_SELECTOR + '[checked]:not([disabled])')
.then(this.next);
},
// Click the menu item.
function() {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, [MENU_ITEM_SELECTOR], this.next);
},
// Wait until the current directory is changed from
// "/My files/Play files/A" to "/My files/Play files" since
// "/My files/Play files/A" is invisible now.
function(result) {
chrome.test.assertTrue(result);
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. await addEntries(['local'], entrySet);
function() {
addEntries(['local'], entrySet, this.next); // Open Files.App on Downloads.
}, const appId = await openNewWindow(null, RootPath.DOWNLOADS);
// Open Files.App on Downloads. await remoteCall.waitForElement(appId, '#file-list');
function(result) {
chrome.test.assertTrue(result); // Wait for the files to appear in the file list.
openNewWindow(null, RootPath.DOWNLOADS).then(this.next); await remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows(entrySet));
},
function(inAppId) { // Wait for the gear menu button to appear.
appId = inAppId; await remoteCall.waitForElement(appId, '#gear-button');
remoteCall.waitForElement(appId, '#file-list').then(this.next);
}, // 1. Before selecting entries: click the gear menu button.
// Wait for the files to appear in the file list. chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
function() { 'fakeMouseClick', appId, ['#gear-button']));
remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows(entrySet))
.then(this.next); // Wait for the gear menu to appear.
}, await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
// Wait for the gear menu button to appear.
function() { // #paste-into-current-folder command is shown. It should be disabled
remoteCall.waitForElement(appId, '#gear-button').then(this.next); // because no file has been copied to clipboard.
}, await remoteCall.waitForElement(
appId,
// 1. Before selecting entries: click the gear menu button. '#gear-menu cr-menu-item' +
function() { '[command=\'#paste-into-current-folder\']' +
remoteCall.callRemoteTestUtil( '[disabled]:not([hidden])');
'fakeMouseClick', appId, ['#gear-button'], this.next); chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
}, 'fakeMouseClick', appId, ['#file-list']));
// Wait for the gear menu to appear.
function(result) { await remoteCall.waitForElement(appId, '#gear-menu[hidden]');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])') // 2. Selecting a single regular file
.then(this.next); chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
}, 'selectFile', appId, [ENTRIES.hello.nameText]));
// #paste-into-current-folder command is shown. It should be disabled
// because no file has been copied to clipboard. chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
function(result) { 'fakeMouseClick', appId, ['#gear-button']));
remoteCall
.waitForElement( // Wait for menu to appear.
appId, // The command is still shown.
'#gear-menu cr-menu-item' + await remoteCall.waitForElement(
'[command=\'#paste-into-current-folder\']' + appId,
'[disabled]:not([hidden])') '#gear-menu:not([hidden]) cr-menu-item' +
.then(this.next); '[command=\'#paste-into-current-folder\']' +
}, '[disabled]:not([hidden])');
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#file-list']));
'fakeMouseClick', appId, ['#file-list'], this.next);
}, await remoteCall.waitForElement(appId, '#gear-menu[hidden]');
function(result) {
chrome.test.assertTrue(result); // 3. When ready to paste a file
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next); chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
}, 'selectFile', appId, [ENTRIES.hello.nameText]));
// 2. Selecting a single regular file // Ctrl-C to copy the selected file
function(result) { await remoteCall.fakeKeyDown(appId, '#file-list', 'c', true, false, false);
remoteCall.callRemoteTestUtil( chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'selectFile', appId, [ENTRIES.hello.nameText], this.next); 'fakeMouseClick', appId, ['#gear-button']));
},
function(result) { // The command appears enabled.
chrome.test.assertTrue(result); await remoteCall.waitForElement(
remoteCall.callRemoteTestUtil( appId,
'fakeMouseClick', appId, ['#gear-button'], this.next); '#gear-menu:not([hidden])' +
}, ' cr-menu-item[command=\'#paste-into-current-folder\']' +
// Wait for menu to appear. ':not([disabled]):not([hidden])');
// The command is still shown. chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
function(result) { 'fakeMouseClick', appId, ['#file-list']));
chrome.test.assertTrue(result);
remoteCall await remoteCall.waitForElement(appId, '#gear-menu[hidden]');
.waitForElement(
appId,
'#gear-menu:not([hidden]) cr-menu-item' +
'[command=\'#paste-into-current-folder\']' +
'[disabled]:not([hidden])')
.then(this.next);
},
function() {
remoteCall.callRemoteTestUtil(
'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
function(result) {
remoteCall.callRemoteTestUtil(
'selectFile', appId, [ENTRIES.hello.nameText], this.next);
},
// Ctrl-C to copy the selected file
function(result) {
chrome.test.assertTrue(result);
remoteCall
.fakeKeyDown(appId, '#file-list', 'c', true, false, false)
.then(this.next);
},
function() {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// The command appears enabled.
function(result) {
chrome.test.assertTrue(result);
remoteCall
.waitForElement(
appId,
'#gear-menu:not([hidden])' +
' cr-menu-item[command=\'#paste-into-current-folder\']' +
':not([disabled]):not([hidden])')
.then(this.next);
},
function() {
remoteCall.callRemoteTestUtil(
'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. const appId = await openNewWindow(null, RootPath.DOWNLOADS);
function() { await remoteCall.waitForElement(appId, '#file-list');
openNewWindow(null, RootPath.DOWNLOADS).then(this.next);
}, // Wait for the gear menu button to appear.
function(inAppId) { await remoteCall.waitForElement(appId, '#gear-button');
appId = inAppId;
remoteCall.waitForElement(appId, '#file-list').then(this.next); // Click the gear menu button.
}, chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
// Wait for the gear menu button to appear. 'fakeMouseClick', appId, ['#gear-button']));
function() {
remoteCall.waitForElement(appId, '#gear-button').then(this.next); // Wait for the gear menu to appear.
}, await remoteCall.waitForElement(appId, '#gear-menu:not([hidden])');
// Click the gear menu button.
function() { // Check: #select-all command is shown, but disabled (no files yet).
remoteCall.callRemoteTestUtil( await remoteCall.waitForElement(
'fakeMouseClick', appId, ['#gear-button'], this.next); appId,
}, '#gear-menu cr-menu-item' +
// Wait for the gear menu to appear. '[command=\'#select-all\']' +
function(result) { '[disabled]:not([hidden])');
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])') // Click the file list: the gear menu should hide.
.then(this.next); chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
}, 'fakeMouseClick', appId, ['#file-list']));
// Check: #select-all command is shown, but disabled (no files yet).
function(result) { // Wait for the gear menu to hide.
remoteCall await remoteCall.waitForElement(appId, '#gear-menu[hidden]');
.waitForElement(
appId, // Add a new file to Downloads.
'#gear-menu cr-menu-item' + await addEntries(['local'], entrySet);
'[command=\'#select-all\']' +
'[disabled]:not([hidden])') // Wait for the file list change.
.then(this.next); await remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows(entrySet));
},
// Click the file list: the gear menu should hide. // Click on the gear button again.
function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'fakeMouseClick', appId, ['#gear-button']));
'fakeMouseClick', appId, ['#file-list'], this.next);
}, // Check: #select-all command is shown, and enabled (there are files).
// Wait for the gear menu to hide. await remoteCall.waitForElement(
function(result) { appId,
chrome.test.assertTrue(result); '#gear-menu:not([hidden]) cr-menu-item' +
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next); '[command=\'#select-all\']' +
}, ':not([disabled]):not([hidden])');
// Add a new file to Downloads.
function() { // Click on the #gear-menu-select-all item.
addEntries(['local'], entrySet, this.next); chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
}, 'fakeMouseClick', appId, ['#gear-menu-select-all']));
// Wait for the file list change.
function(result) { // Check: the file-list should be selected.
chrome.test.assertTrue(result); await remoteCall.waitForElement(appId, '#file-list li[selected]');
remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows(entrySet))
.then(this.next);
},
// Click on the gear button again.
function(result) {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-button'], this.next);
},
// Check: #select-all command is shown, and enabled (there are files).
function(result) {
chrome.test.assertTrue(result);
remoteCall
.waitForElement(
appId,
'#gear-menu:not([hidden]) cr-menu-item' +
'[command=\'#select-all\']' +
':not([disabled]):not([hidden])')
.then(this.next);
},
// Click on the #gear-menu-select-all item.
function(results) {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-menu-select-all'], this.next);
},
// Check: the file-list should be selected.
function(result) {
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], [ // Focus the directory tree.
]).then(this.next); await remoteCall.callRemoteTestUtil('focus', appId, ['#directory-tree']);
},
// Focus the directory tree. // Open the gear menu.
function(results) { await remoteCall.waitForElement(appId, '#gear-button');
appId = results.windowId;
// Open the gear meny by a shortcut (Alt-E).
remoteCall.callRemoteTestUtil('focus', appId, ['#directory-tree']) chrome.test.assertTrue(
.then(this.next); await remoteCall.fakeKeyDown(appId, 'body', 'e', false, false, true));
},
// Open the gear menu. // Wait for menu to appear.
function() { await remoteCall.waitForElement(appId, '#gear-menu');
remoteCall.waitForElement(appId, '#gear-button').then(this.next);
}, // Wait for menu to appear, containing new folder.
// Open the gear meny by a shortcut (Alt-E). await remoteCall.waitForElement(
function() { appId, '#gear-menu-newfolder:not([disabled]):not([hidden])');
remoteCall.fakeKeyDown(appId, 'body', 'e', false, false, true)
.then(this.next);
},
// Wait for menu to appear.
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu').then(this.next);
},
// Wait for menu to appear, containing new folder.
function(result) {
remoteCall
.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