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