Commit 3455c993 authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Convert drive_specific.js to use async-await.

Bug: 909056
Change-Id: If6daa91932bad99510e267ef91cc6808bceeccfa
Reviewed-on: https://chromium-review.googlesource.com/c/1356162
Commit-Queue: Sam McNally <sammc@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612537}
parent 77bfbe84
// Copyright 2014 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
'use strict'; 'use strict';
/** /**
...@@ -11,7 +10,7 @@ ...@@ -11,7 +10,7 @@
*/ */
var EXPECTED_AUTOCOMPLETE_LIST = [ var EXPECTED_AUTOCOMPLETE_LIST = [
'\'hello\' - search Drive', '\'hello\' - search Drive',
'hello.txt' 'hello.txt',
]; ];
/** /**
...@@ -21,62 +20,40 @@ var EXPECTED_AUTOCOMPLETE_LIST = [ ...@@ -21,62 +20,40 @@ var EXPECTED_AUTOCOMPLETE_LIST = [
* @const * @const
*/ */
var SEARCH_RESULTS_ENTRY_SET = [ var SEARCH_RESULTS_ENTRY_SET = [
ENTRIES.hello ENTRIES.hello,
]; ];
/** /**
* Returns the steps to start a search for 'hello' and wait for the * Returns the steps to start a search for 'hello' and wait for the
* autocomplete results to appear. * autocomplete results to appear.
*/ */
function getStepsForSearchResultsAutoComplete() { async function startDriveSearchWithAutoComplete() {
var appId; // Open Files app on Drive.
var steps = [ const {appId} = await setupAndWaitUntilReady(null, RootPath.DRIVE, null);
function() {
setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); // Focus the search box.
}, chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
// Focus the search box. 'fakeEvent', appId, ['#search-box cr-input', 'focus']));
function(results) {
appId = results.windowId; // Input a text.
remoteCall.callRemoteTestUtil( await remoteCall.callRemoteTestUtil(
'fakeEvent', appId, ['#search-box cr-input', 'focus'], this.next); 'inputText', appId, ['#search-box cr-input', 'hello']);
},
// Input a text. // Notify the element of the input.
function(result) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
chrome.test.assertTrue(result); 'fakeEvent', appId, ['#search-box cr-input', 'input']));
remoteCall.callRemoteTestUtil(
'inputText', appId, ['#search-box cr-input', 'hello'], this.next); // Wait for the auto complete list getting the expected contents.
}, var caller = getCaller();
// Notify the element of the input. await repeatUntil(async () => {
function() { const elements = await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil( 'queryAllElements', appId, ['#autocomplete-list li']);
'fakeEvent', appId, ['#search-box cr-input', 'input'], this.next); var list = elements.map((element) => element.text);
}, return chrome.test.checkDeepEq(EXPECTED_AUTOCOMPLETE_LIST, list) ?
// Wait for the auto complete list getting the expected contents. undefined :
function(result) { pending(caller, 'Current auto complete list: %j.', list);
chrome.test.assertTrue(result); });
var caller = getCaller(); return appId;
repeatUntil(function() {
return remoteCall.callRemoteTestUtil('queryAllElements',
appId,
['#autocomplete-list li']).
then(function(elements) {
var list = elements.map(
function(element) { return element.text; });
return chrome.test.checkDeepEq(EXPECTED_AUTOCOMPLETE_LIST, list) ?
undefined :
pending(caller, 'Current auto complete list: %j.', list);
});
}).
then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
function() {
this.next(appId);
}
];
return steps;
} }
/** /**
...@@ -85,29 +62,17 @@ function getStepsForSearchResultsAutoComplete() { ...@@ -85,29 +62,17 @@ function getStepsForSearchResultsAutoComplete() {
* should be shown. "Available offline" entries are hosted documents and the * should be shown. "Available offline" entries are hosted documents and the
* entries cached by DriveCache. * entries cached by DriveCache.
*/ */
testcase.driveOpenSidebarOffline = function() { testcase.driveOpenSidebarOffline = async function() {
var appId; // Open Files app on Drive.
StepsRunner.run([ const {appId} = await setupAndWaitUntilReady(null, RootPath.DRIVE, null);
function() {
setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); // Click the icon of the Offline volume.
}, chrome.test.assertFalse(!await remoteCall.callRemoteTestUtil(
// Click the icon of the Offline volume. 'selectVolume', appId, ['drive_offline']));
function(results) {
appId = results.windowId; // Check: the file list should display the offline file set.
remoteCall.callRemoteTestUtil( await remoteCall.waitForFiles(
'selectVolume', appId, ['drive_offline'], this.next); appId, TestEntryInfo.getExpectedRows(OFFLINE_ENTRY_SET));
},
// Check: the file list should display the offline file set.
function(result) {
chrome.test.assertFalse(!result);
remoteCall
.waitForFiles(appId, TestEntryInfo.getExpectedRows(OFFLINE_ENTRY_SET))
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
}
]);
}; };
/** /**
...@@ -115,340 +80,192 @@ testcase.driveOpenSidebarOffline = function() { ...@@ -115,340 +80,192 @@ testcase.driveOpenSidebarOffline = function() {
* icon, and checks contents of the file list. Only the entries labeled with * icon, and checks contents of the file list. Only the entries labeled with
* "shared-with-me" should be shown. * "shared-with-me" should be shown.
*/ */
testcase.driveOpenSidebarSharedWithMe = function() { testcase.driveOpenSidebarSharedWithMe = async function() {
let appId; const isDriveFsEnabled =
let isDriveFsEnabled; await sendTestMessage({name: 'getDriveFsEnabled'}) === 'true';
StepsRunner.run([
function() { // Open Files app on Drive containing "Shared with me" file entries.
sendTestMessage({name: 'getDriveFsEnabled'}).then(this.next); const {appId} = await setupAndWaitUntilReady(
}, null, RootPath.DRIVE, null, [], BASIC_DRIVE_ENTRY_SET.concat([
function(result) { ENTRIES.sharedDirectory,
isDriveFsEnabled = result === 'true'; ENTRIES.sharedDirectoryFile,
]));
setupAndWaitUntilReady(
null, RootPath.DRIVE, this.next, [], BASIC_DRIVE_ENTRY_SET.concat([ // Click the icon of the Shared With Me volume.
ENTRIES.sharedDirectory, // Use the icon for a click target.
ENTRIES.sharedDirectoryFile, chrome.test.assertFalse(!await remoteCall.callRemoteTestUtil(
])); 'selectVolume', appId, ['drive_shared_with_me']));
},
// Click the icon of the Shared With Me volume. // Wait until the breadcrumb path is updated.
function(results) { await remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/Shared with me');
appId = results.windowId;
// Use the icon for a click target. // Verify the file list.
remoteCall.callRemoteTestUtil('selectVolume', await remoteCall.waitForFiles(
appId, appId,
['drive_shared_with_me'], this.next); TestEntryInfo.getExpectedRows(
}, SHARED_WITH_ME_ENTRY_SET.concat([ENTRIES.sharedDirectory])));
// Wait until the breadcrumb path is updated.
function(result) { // Navigate to the directory within Shared with me.
chrome.test.assertFalse(!result); chrome.test.assertFalse(!await remoteCall.callRemoteTestUtil(
remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/Shared with me') 'openFile', appId, ['Shared Directory']));
.then(this.next);
}, // Wait until the breadcrumb path is updated.
// Verify the file list. await remoteCall.waitUntilCurrentDirectoryIsChanged(
function() { appId,
remoteCall isDriveFsEnabled ? '/Shared with me/Shared Directory' :
.waitForFiles( '/My Drive/Shared Directory');
appId,
TestEntryInfo.getExpectedRows( // Verify the file list.
SHARED_WITH_ME_ENTRY_SET.concat([ENTRIES.sharedDirectory]))) await remoteCall.waitForFiles(
.then(this.next); appId, TestEntryInfo.getExpectedRows([ENTRIES.sharedDirectoryFile]));
},
// Navigate to the directory within Shared with me.
function() {
remoteCall.callRemoteTestUtil('openFile', appId, ['Shared Directory'])
.then(this.next);
},
// Wait until the breadcrumb path is updated.
function(result) {
chrome.test.assertFalse(!result);
remoteCall
.waitUntilCurrentDirectoryIsChanged(
appId,
isDriveFsEnabled ? '/Shared with me/Shared Directory' :
'/My Drive/Shared Directory')
.then(this.next);
},
// Verify the file list.
function() {
remoteCall
.waitForFiles(
appId,
TestEntryInfo.getExpectedRows([ENTRIES.sharedDirectoryFile]))
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
}
]);
}; };
/** /**
* Tests autocomplete with a query 'hello'. * Tests autocomplete with a query 'hello'.
*/ */
testcase.driveAutoCompleteQuery = function() { testcase.driveAutoCompleteQuery = async function() {
StepsRunner.run(getStepsForSearchResultsAutoComplete()); return startDriveSearchWithAutoComplete();
}; };
/** /**
* Tests that clicking the first option in the autocomplete box shows all of * Tests that clicking the first option in the autocomplete box shows all of
* the results for that query. * the results for that query.
*/ */
testcase.driveClickFirstSearchResult = function() { testcase.driveClickFirstSearchResult = async function() {
var appId; const appId = await startDriveSearchWithAutoComplete();
var steps = getStepsForSearchResultsAutoComplete(); chrome.test.assertTrue(!!await remoteCall.callRemoteTestUtil(
steps.push( 'fakeKeyDown', appId,
function(id) { ['#autocomplete-list', 'ArrowDown', false, false, false]));
appId = id;
remoteCall.callRemoteTestUtil( await remoteCall.waitForElement(appId, ['#autocomplete-list li[selected]']);
'fakeKeyDown', appId, chrome.test.assertTrue(!!await remoteCall.callRemoteTestUtil(
['#autocomplete-list', 'ArrowDown', false, false, false], 'fakeMouseDown', appId, ['#autocomplete-list li[selected]']));
this.next);
}, await remoteCall.waitForFiles(
function(result) { appId, TestEntryInfo.getExpectedRows(SEARCH_RESULTS_ENTRY_SET));
chrome.test.assertTrue(!!result);
remoteCall.waitForElement(appId, ['#autocomplete-list li[selected]'])
.then(this.next);
},
function(result) {
remoteCall.callRemoteTestUtil(
'fakeMouseDown', appId, ['#autocomplete-list li[selected]'],
this.next);
},
function(result) {
chrome.test.assertTrue(!!result);
remoteCall
.waitForFiles(
appId, TestEntryInfo.getExpectedRows(SEARCH_RESULTS_ENTRY_SET))
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
});
StepsRunner.run(steps);
}; };
/** /**
* Tests that pressing enter after typing a search shows all of * Tests that pressing enter after typing a search shows all of
* the results for that query. * the results for that query.
*/ */
testcase.drivePressEnterToSearch = function() { testcase.drivePressEnterToSearch = async function() {
var appId; const appId = await startDriveSearchWithAutoComplete();
var steps = getStepsForSearchResultsAutoComplete(); chrome.test.assertTrue(!!await remoteCall.callRemoteTestUtil(
steps.push( 'fakeEvent', appId, ['#search-box cr-input', 'focus']));
function(id) { chrome.test.assertTrue(!!await remoteCall.callRemoteTestUtil(
appId = id; 'fakeKeyDown', appId,
remoteCall.callRemoteTestUtil( ['#search-box cr-input', 'Enter', false, false, false]));
'fakeEvent', appId, ['#search-box cr-input', 'focus'], this.next); await remoteCall.waitForFiles(
}, appId, TestEntryInfo.getExpectedRows(SEARCH_RESULTS_ENTRY_SET));
function(result) {
chrome.test.assertTrue(!!result);
remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId,
['#search-box cr-input', 'Enter', false, false, false], this.next);
},
function(result) {
chrome.test.assertTrue(!!result);
remoteCall
.waitForFiles(
appId, TestEntryInfo.getExpectedRows(SEARCH_RESULTS_ENTRY_SET))
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
});
StepsRunner.run(steps);
}; };
/** /**
* Tests pinning a file to a mobile network. * Tests pinning a file to a mobile network.
*/ */
testcase.drivePinFileMobileNetwork = function() { testcase.drivePinFileMobileNetwork = async function() {
testPromise(setupAndWaitUntilReady(null, RootPath.DRIVE).then( const {appId} = await setupAndWaitUntilReady(null, RootPath.DRIVE);
function(results) { var caller = getCaller();
var windowId = results.windowId; await sendTestMessage({name: 'useCellularNetwork'});
var caller = getCaller(); await remoteCall.callRemoteTestUtil('selectFile', appId, ['hello.txt']);
return sendTestMessage( await repeatUntil(() => {
{name: 'useCellularNetwork'}).then(function(result) { return navigator.connection.type != 'cellular' ?
return remoteCall.callRemoteTestUtil( pending(caller, 'Network state is not changed to cellular.') :
'selectFile', windowId, ['hello.txt']); null;
}).then(function() { });
return repeatUntil(function() { await remoteCall.waitForElement(appId, ['.table-row[selected]']);
return navigator.connection.type != 'cellular' ? chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
pending(caller, 'Network state is not changed to cellular.') : 'fakeMouseRightClick', appId, ['.table-row[selected]']));
null;
}); await remoteCall.waitForElement(appId, '#file-context-menu:not([hidden])');
}).then(function() { await remoteCall.waitForElement(appId, ['[command="#toggle-pinned"]']);
return remoteCall.waitForElement(windowId, ['.table-row[selected]']); await remoteCall.callRemoteTestUtil(
}).then(function() { 'fakeMouseClick', appId, ['[command="#toggle-pinned"]']);
return remoteCall.callRemoteTestUtil( await remoteCall.waitForElement(appId, '#file-context-menu[hidden]');
'fakeMouseRightClick', windowId, ['.table-row[selected]']); chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
}).then(function(result) { 'fakeEvent', appId, ['#file-list', 'contextmenu']));
chrome.test.assertTrue(result);
return remoteCall.waitForElement( await remoteCall.waitForElement(appId, '[command="#toggle-pinned"][checked]');
windowId, '#file-context-menu:not([hidden])'); await repeatUntil(async () => {
}).then(function() { const idSet =
return remoteCall.waitForElement(windowId, await remoteCall.callRemoteTestUtil('getNotificationIDs', null, []);
['[command="#toggle-pinned"]']); return !idSet['disabled-mobile-sync'] ?
}).then(function() { pending(caller, 'Sync disable notification is not found.') :
return remoteCall.callRemoteTestUtil( null;
'fakeMouseClick', windowId, ['[command="#toggle-pinned"]']); });
}).then(function(result) { await sendTestMessage({
return remoteCall.waitForElement( name: 'clickNotificationButton',
windowId, '#file-context-menu[hidden]'); extensionId: FILE_MANAGER_EXTENSIONS_ID,
}).then(function() { notificationId: 'disabled-mobile-sync',
return remoteCall.callRemoteTestUtil( index: 0
'fakeEvent', windowId, ['#file-list', 'contextmenu']); });
}).then(function(result) { await repeatUntil(async () => {
chrome.test.assertTrue(result); const preferences =
return remoteCall.waitForElement( await remoteCall.callRemoteTestUtil('getPreferences', null, []);
windowId, '[command="#toggle-pinned"][checked]'); return preferences.cellularDisabled ?
}).then(function() { pending(caller, 'Drive sync is still disabled.') :
return repeatUntil(function() { null;
return remoteCall.callRemoteTestUtil( });
'getNotificationIDs', null, []).then(function(idSet) {
return !idSet['disabled-mobile-sync'] ?
pending(caller, 'Sync disable notification is not found.') :
null;
});
});
}).then(function() {
return sendTestMessage({
name: 'clickNotificationButton',
extensionId: FILE_MANAGER_EXTENSIONS_ID,
notificationId: 'disabled-mobile-sync',
index: 0
});
}).then(function() {
return repeatUntil(function() {
return remoteCall.callRemoteTestUtil(
'getPreferences', null, []).then(function(preferences) {
return preferences.cellularDisabled ?
pending(caller, 'Drive sync is still disabled.') : null;
});
});
});
}));
}; };
/** /**
* Tests that pressing Ctrl+A (select all files) from the search box doesn't put * Tests that pressing Ctrl+A (select all files) from the search box doesn't put
* the Files App into check-select mode (crbug.com/849253). * the Files App into check-select mode (crbug.com/849253).
*/ */
testcase.drivePressCtrlAFromSearch = function() { testcase.drivePressCtrlAFromSearch = async function() {
var appId; // Open Files app on Drive.
var steps = [ const {appId} = await setupAndWaitUntilReady(null, RootPath.DRIVE, null);
function() {
setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); // Focus the search box.
}, chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
// Focus the search box. 'fakeMouseClick', appId, ['#search-button']));
function(results) {
appId = results.windowId; // Wait for the search box to be visible.
remoteCall.callRemoteTestUtil( await remoteCall.waitForElement(
'fakeMouseClick', appId, ['#search-button'], this.next); appId, ['#search-box cr-input:not([hidden])']);
},
// Wait for the search box to be visible. // Press Ctrl+A inside the search box.
function(result) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
chrome.test.assertTrue(result); 'fakeKeyDown', appId, ['#search-box cr-input', 'A', true, false, false]));
remoteCall.waitForElement(appId, ['#search-box cr-input:not([hidden])'])
.then(this.next); // Check we didn't enter check-select mode.
}, await remoteCall.waitForElement(appId, ['body:not(.check-select)']);
// Press Ctrl+A inside the search box.
function(result) {
remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId,
['#search-box cr-input', 'A', true, false, false], this.next);
},
// Check we didn't enter check-select mode.
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, ['body:not(.check-select)'])
.then(this.next);
},
function(result) {
checkIfNoErrorsOccured(this.next);
},
];
StepsRunner.run(steps);
}; };
/** /**
* Pin hello.txt in the old Drive client. * Pin hello.txt in the old Drive client.
*/ */
testcase.PRE_driveMigratePinnedFile = function() { testcase.PRE_driveMigratePinnedFile = async function() {
testPromise( const {appId} = await setupAndWaitUntilReady(null, RootPath.DRIVE);
setupAndWaitUntilReady(null, RootPath.DRIVE).then(function(results) { await remoteCall.callRemoteTestUtil('selectFile', appId, ['hello.txt']);
var windowId = results.windowId; await remoteCall.waitForElement(appId, ['.table-row[selected]']);
return remoteCall chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
.callRemoteTestUtil('selectFile', windowId, ['hello.txt']) 'fakeMouseRightClick', appId, ['.table-row[selected]']));
.then(function() {
return remoteCall.waitForElement( await remoteCall.waitForElement(appId, '#file-context-menu:not([hidden])');
windowId, ['.table-row[selected]']); await remoteCall.waitForElement(appId, ['[command="#toggle-pinned"]']);
}) await remoteCall.callRemoteTestUtil(
.then(function() { 'fakeMouseClick', appId, ['[command="#toggle-pinned"]']);
return remoteCall.callRemoteTestUtil( await remoteCall.waitForElement(appId, '#file-context-menu[hidden]');
'fakeMouseRightClick', windowId, ['.table-row[selected]']); chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
}) 'fakeEvent', appId, ['#file-list', 'contextmenu']));
.then(function(result) {
chrome.test.assertTrue(result); await remoteCall.waitForElement(appId, '[command="#toggle-pinned"][checked]');
return remoteCall.waitForElement(
windowId, '#file-context-menu:not([hidden])');
})
.then(function() {
return remoteCall.waitForElement(
windowId, ['[command="#toggle-pinned"]']);
})
.then(function() {
return remoteCall.callRemoteTestUtil(
'fakeMouseClick', windowId, ['[command="#toggle-pinned"]']);
})
.then(function(result) {
return remoteCall.waitForElement(
windowId, '#file-context-menu[hidden]');
})
.then(function() {
return remoteCall.callRemoteTestUtil(
'fakeEvent', windowId, ['#file-list', 'contextmenu']);
})
.then(function(result) {
chrome.test.assertTrue(result);
return remoteCall.waitForElement(
windowId, '[command="#toggle-pinned"][checked]');
});
}));
}; };
/** /**
* Verify hello.txt is still pinned after migrating to DriveFS. * Verify hello.txt is still pinned after migrating to DriveFS.
*/ */
testcase.driveMigratePinnedFile = function() { testcase.driveMigratePinnedFile = async function() {
// After enabling DriveFS, ensure the file is still pinned. // After enabling DriveFS, ensure the file is still pinned.
testPromise( const {appId} = await setupAndWaitUntilReady(null, RootPath.DRIVE);
setupAndWaitUntilReady(null, RootPath.DRIVE).then(function(results) { await remoteCall.callRemoteTestUtil('selectFile', appId, ['hello.txt']);
var windowId = results.windowId; await remoteCall.waitForElement(appId, ['.table-row[selected]']);
return remoteCall chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
.callRemoteTestUtil('selectFile', windowId, ['hello.txt']) 'fakeMouseRightClick', appId, ['.table-row[selected]']));
.then(function() {
return remoteCall.waitForElement(
windowId, ['.table-row[selected]']);
})
.then(function() {
return remoteCall.callRemoteTestUtil(
'fakeMouseRightClick', windowId, ['.table-row[selected]']);
})
.then(function(result) {
chrome.test.assertTrue(result);
return remoteCall.waitForElement(
windowId, '#file-context-menu:not([hidden])');
})
.then(function() {
return remoteCall.waitForElement(
windowId, '[command="#toggle-pinned"][checked]');
});
}));
await remoteCall.waitForElement(appId, '#file-context-menu:not([hidden])');
await remoteCall.waitForElement(appId, '[command="#toggle-pinned"][checked]');
}; };
// Match the way the production version formats dates. // Match the way the production version formats dates.
...@@ -469,73 +286,46 @@ function formatDate(date) { ...@@ -469,73 +286,46 @@ function formatDate(date) {
* Test that a images within a DCIM directory on removable media is backed up to * Test that a images within a DCIM directory on removable media is backed up to
* Drive, in the Chrome OS Cloud backup/<current date> directory. * Drive, in the Chrome OS Cloud backup/<current date> directory.
*/ */
testcase.driveBackupPhotos = function() { testcase.driveBackupPhotos = async function() {
let appId;
const USB_VOLUME_QUERY = '#directory-tree [volume-type-icon="removable"]'; const USB_VOLUME_QUERY = '#directory-tree [volume-type-icon="removable"]';
let date; let date;
StepsRunner.run([ // Open Files app on local downloads.
// Open Files app on local downloads. const {appId} = await setupAndWaitUntilReady(null, RootPath.DOWNLOADS, null);
function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next); // Mount USB volume in the Downloads window.
}, await sendTestMessage({name: 'mountFakeUsbDcim'});
// Mount USB volume in the Downloads window.
function(results) { // Wait for the USB mount.
appId = results.windowId; await remoteCall.waitForElement(appId, USB_VOLUME_QUERY);
sendTestMessage({name: 'mountFakeUsbDcim'}).then(this.next);
}, // Navigate to the DCIM directory.
// Wait for the USB mount. await remoteCall.navigateWithDirectoryTree(
function() { appId, '/DCIM', 'fake-usb', 'removable');
remoteCall.waitForElement(appId, USB_VOLUME_QUERY).then(this.next);
}, // Wait for the import button to be ready.
// Navigate to the DCIM directory. await remoteCall.waitForElement(
function() { appId, '#cloud-import-button [icon="files:cloud-upload"]');
remoteCall
.navigateWithDirectoryTree(appId, '/DCIM', 'fake-usb', 'removable') // Start the import.
.then(this.next); date = new Date();
}, chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
// Wait for the import button to be ready. 'fakeMouseClick', appId, ['#cloud-import-button']));
function() {
remoteCall // Wait for the image to be marked as imported.
.waitForElement( await remoteCall.waitForElement(
appId, '#cloud-import-button [icon="files:cloud-upload"]') appId, '.status-icon[file-status-icon="imported"]');
.then(this.next);
}, // Navigate to today's backup directory in Drive.
// Start the import. const formattedDate = formatDate(date);
function() { await remoteCall.navigateWithDirectoryTree(
date = new Date(); appId, `/root/Chrome OS Cloud backup/${formattedDate}`, 'My Drive',
remoteCall 'drive');
.callRemoteTestUtil('fakeMouseClick', appId, ['#cloud-import-button'])
.then(this.next); // Verify the backed-up file list contains only a copy of the image within
}, // DCIM in the removable storage.
// Wait for the image to be marked as imported. const files = TestEntryInfo.getExpectedRows([ENTRIES.image3]);
function(success) { await remoteCall.waitForFiles(appId, files, {ignoreLastModifiedTime: true});
chrome.test.assertTrue(success);
remoteCall
.waitForElement(appId, '.status-icon[file-status-icon="imported"]')
.then(this.next);
},
// Navigate to today's backup directory in Drive.
function() {
const formattedDate = formatDate(date);
remoteCall
.navigateWithDirectoryTree(
appId, `/root/Chrome OS Cloud backup/${formattedDate}`,
'My Drive', 'drive')
.then(this.next);
},
// Verify the backed-up file list contains only a copy of the image within
// DCIM in the removable storage.
function() {
const files = TestEntryInfo.getExpectedRows([ENTRIES.image3]);
remoteCall.waitForFiles(appId, files, {ignoreLastModifiedTime: true})
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
}
]);
}; };
/** /**
...@@ -545,83 +335,56 @@ testcase.driveBackupPhotos = function() { ...@@ -545,83 +335,56 @@ testcase.driveBackupPhotos = function() {
* never complete syncing to the fake drive service so will remain dirty * never complete syncing to the fake drive service so will remain dirty
* forever. * forever.
*/ */
testcase.PRE_driveRecoverDirtyFiles = function() { testcase.PRE_driveRecoverDirtyFiles = async function() {
let appId; // Open Files app on downloads.
StepsRunner.run([ const {appId} = await setupAndWaitUntilReady(
function() { null, RootPath.DOWNLOADS, null, [ENTRIES.neverSync],
setupAndWaitUntilReady( [ENTRIES.directoryA]);
null, RootPath.DOWNLOADS, this.next, [ENTRIES.neverSync],
[ENTRIES.directoryA]); // Select never-sync.txt.
}, chrome.test.assertTrue(
// Select never-sync.txt. await remoteCall.callRemoteTestUtil(
function(results) { 'selectFile', appId, ['never-sync.txt']),
appId = results.windowId; 'selectFile failed');
remoteCall.callRemoteTestUtil('selectFile', appId, ['never-sync.txt']) // Copy it.
.then(this.next); chrome.test.assertTrue(
}, await remoteCall.callRemoteTestUtil(
// Copy it. 'fakeKeyDown', appId, ['#file-list', 'c', true, false, false]),
function(result) { 'copy failed');
chrome.test.assertTrue(result, 'selectFile failed');
// Navigate to My Drive.
return remoteCall await remoteCall.navigateWithDirectoryTree(
.callRemoteTestUtil( appId, '/root', 'My Drive', 'drive');
'fakeKeyDown', appId, ['#file-list', 'c', true, false, false])
.then(this.next); // Paste.
}, chrome.test.assertTrue(
// Navigate to My Drive. await remoteCall.callRemoteTestUtil(
function(result) { 'fakeKeyDown', appId, ['#file-list', 'v', true, false, false]),
chrome.test.assertTrue(result, 'copy failed'); 'paste failed');
return remoteCall // Wait for the paste to complete.
.navigateWithDirectoryTree(appId, '/root', 'My Drive', 'drive') let expectedEntryRows = [
.then(this.next); ENTRIES.neverSync.getExpectedRow(),
}, ENTRIES.directoryA.getExpectedRow(),
// Paste. ];
function() { await remoteCall.waitForFiles(
return remoteCall appId, expectedEntryRows, {ignoreLastModifiedTime: true});
.callRemoteTestUtil(
'fakeKeyDown', appId, ['#file-list', 'v', true, false, false]) // Navigate to My Drive/A.
.then(this.next); await remoteCall.navigateWithDirectoryTree(
}, appId, '/root/A', 'My Drive', 'drive');
// Wait for the paste to complete.
function(result) { // Paste.
chrome.test.assertTrue(result, 'paste failed'); chrome.test.assertTrue(
const expectedEntryRows = [ await remoteCall.callRemoteTestUtil(
ENTRIES.neverSync.getExpectedRow(), 'fakeKeyDown', appId, ['#file-list', 'v', true, false, false]),
ENTRIES.directoryA.getExpectedRow(), 'paste failed');
];
remoteCall // Wait for the paste to complete.
.waitForFiles( expectedEntryRows = [ENTRIES.neverSync.getExpectedRow()];
appId, expectedEntryRows, {ignoreLastModifiedTime: true}) await remoteCall.waitForFiles(
.then(this.next); appId, expectedEntryRows, {ignoreLastModifiedTime: true});
},
// Navigate to My Drive/A.
function() {
return remoteCall
.navigateWithDirectoryTree(appId, '/root/A', 'My Drive', 'drive')
.then(this.next);
},
// Paste.
function() {
return remoteCall
.callRemoteTestUtil(
'fakeKeyDown', appId, ['#file-list', 'v', true, false, false])
.then(this.next);
},
// Wait for the paste to complete.
function(result) {
chrome.test.assertTrue(result, 'paste failed');
const expectedEntryRows = [ENTRIES.neverSync.getExpectedRow()];
remoteCall
.waitForFiles(
appId, expectedEntryRows, {ignoreLastModifiedTime: true})
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
...@@ -631,102 +394,67 @@ testcase.PRE_driveRecoverDirtyFiles = function() { ...@@ -631,102 +394,67 @@ testcase.PRE_driveRecoverDirtyFiles = function() {
* - never-sync.txt * - never-sync.txt
* - never-sync (1).txt * - never-sync (1).txt
*/ */
testcase.driveRecoverDirtyFiles = function() { testcase.driveRecoverDirtyFiles = async function() {
let appId; // After enabling DriveFS, ensure the dirty files have been
// After enabling DriveFS, ensure the dirty files have been recovered into // recovered into Downloads.
// Downloads. const {appId} =
StepsRunner.run([ await setupAndWaitUntilReady(null, RootPath.DOWNLOADS, null, [], []);
function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next, [], []); // Wait for the Recovered files directory to be in Downloads.
}, let expectedEntryRows = [
// Wait for the Recovered files directory to be in Downloads. ENTRIES.neverSync.getExpectedRow(),
function(results) { ['Recovered files from Google Drive', '--', 'Folder'],
appId = results.windowId; ];
await remoteCall.waitForFiles(
const expectedEntryRows = [ appId, expectedEntryRows, {ignoreLastModifiedTime: true});
ENTRIES.neverSync.getExpectedRow(),
['Recovered files from Google Drive', '--', 'Folder'], // Navigate to the recovered files directory.
]; await remoteCall.navigateWithDirectoryTree(
remoteCall appId, RootPath.DOWNLOADS_PATH + '/Recovered files from Google Drive',
.waitForFiles( 'My files/Downloads');
appId, expectedEntryRows, {ignoreLastModifiedTime: true})
.then(this.next); // Ensure it contains never-sync.txt and never-sync (1).txt.
}, var uniquifiedNeverSync = ENTRIES.neverSync.getExpectedRow();
// Navigate to the recovered files directory. uniquifiedNeverSync[0] = 'never-sync (1).txt';
function() { expectedEntryRows = [
return remoteCall ENTRIES.neverSync.getExpectedRow(),
.navigateWithDirectoryTree( uniquifiedNeverSync,
appId, ];
RootPath.DOWNLOADS_PATH + '/Recovered files from Google Drive', await remoteCall.waitForFiles(
'My files/Downloads') appId, expectedEntryRows, {ignoreLastModifiedTime: true});
.then(this.next);
},
// Ensure it contains never-sync.txt and never-sync (1).txt.
function() {
var uniquifiedNeverSync = ENTRIES.neverSync.getExpectedRow();
uniquifiedNeverSync[0] = 'never-sync (1).txt';
const expectedEntryRows = [
ENTRIES.neverSync.getExpectedRow(),
uniquifiedNeverSync,
];
remoteCall
.waitForFiles(
appId, expectedEntryRows, {ignoreLastModifiedTime: true})
.then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Verify that "Available Offline" is available from the gear menu for a drive * Verify that "Available Offline" is available from the gear menu for a drive
* file before the context menu has been opened. * file before the context menu has been opened.
*/ */
testcase.driveAvailableOfflineGearMenu = function() { testcase.driveAvailableOfflineGearMenu = async function() {
const pinnedMenuQuery = '#file-context-menu:not([hidden]) ' + const pinnedMenuQuery = '#file-context-menu:not([hidden]) ' +
'cr-menu-item[command="#toggle-pinned"]:not([disabled])'; 'cr-menu-item[command="#toggle-pinned"]:not([disabled])';
let appId;
let steps = [ // Open Files app on Drive.
function() { const {appId} = await setupAndWaitUntilReady(null, RootPath.DRIVE, null, []);
setupAndWaitUntilReady(null, RootPath.DRIVE, this.next, []);
}, // Select a file.
// Select a file in drive. chrome.test.assertTrue(
function(result) { !!await remoteCall.callRemoteTestUtil('selectFile', appId, ['hello.txt']),
appId = result.windowId; 'selectFile failed');
remoteCall.callRemoteTestUtil(
'selectFile', appId, ['hello.txt'], this.next); // Wait for the entry to be selected.
}, await remoteCall.waitForElement(appId, '.table-row[selected]');
// Wait for the entry to be selected.
function(result) { // Click on the icon of the file to check select it
chrome.test.assertTrue(!!result, 'selectFile failed'); await remoteCall.callRemoteTestUtil(
remoteCall.waitForElement(appId, '.table-row[selected]').then(this.next); 'fakeMouseClick', appId,
}, ['#file-list .table-row[selected] .detail-checkmark']);
// Click on the icon of the file to check select it
function(result) { // Ensure gear button is available
remoteCall.callRemoteTestUtil( await remoteCall.waitForElement(appId, '#selection-menu-button');
'fakeMouseClick', appId,
['#file-list .table-row[selected] .detail-checkmark'], this.next); // Click on gear menu and ensure "Available Offline" is shown.
}, chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
// Ensure gear button is available 'fakeMouseClick', appId, ['#selection-menu-button']));
function(result) {
remoteCall.waitForElement(appId, '#selection-menu-button') // Check that "Available Offline" is shown in the menu/
.then(this.next); await remoteCall.waitForElement(appId, pinnedMenuQuery);
},
// Cick on gear menu and ensure "Avaialble Offline" is shown.
function(result) {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#selection-menu-button'], this.next);
},
// Check that "Available Offline" is shown in the menu/
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, pinnedMenuQuery).then(this.next);
},
function(result) {
checkIfNoErrorsOccured(this.next);
}
];
StepsRunner.run(steps);
}; };
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