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