Commit 57da0c4f authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Convert suggest_app_dialog.js to use async-await.

Bug: 909056
Change-Id: I526a3f743c2c458caad3f3dbaf899d9ef6e64518
Reviewed-on: https://chromium-review.googlesource.com/c/1354748
Commit-Queue: Sam McNally <sammc@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612110}
parent 7920c70b
...@@ -7,107 +7,68 @@ ...@@ -7,107 +7,68 @@
/** /**
* Tests sharing a file on Drive * Tests sharing a file on Drive
*/ */
testcase.suggestAppDialog = function() { testcase.suggestAppDialog = async function() {
var appId; // Fetch the mock CWS page data.
StepsRunner.run([ const data =
// Set up File Manager. JSON.parse(await sendTestMessage({name: 'getCwsWidgetContainerMockUrl'}));
function() {
sendTestMessage({name: 'getCwsWidgetContainerMockUrl'}).then(this.next);
},
// Override the container URL with the mock.
function(json) {
var data = JSON.parse(json);
// Override the container URL with the mock.
var appState = { var appState = {
suggestAppsDialogState: { suggestAppsDialogState: {
overrideCwsContainerUrlForTest: data.url, overrideCwsContainerUrlForTest: data.url,
overrideCwsContainerOriginForTest: data.origin overrideCwsContainerOriginForTest: data.origin
} }
}; };
setupAndWaitUntilReady(appState, RootPath.DRIVE, this.next);
},
function(results) {
appId = results.windowId;
remoteCall.callRemoteTestUtil( // Set up File Manager.
'selectFile', appId, ['unsupported.foo'], this.next); const {appId} = await setupAndWaitUntilReady(appState, RootPath.DRIVE);
},
// Select a file.
chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'selectFile', appId, ['unsupported.foo']));
// Double-click the file. // Double-click the file.
function(result) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
chrome.test.assertTrue(result); 'fakeMouseDoubleClick', appId,
remoteCall.callRemoteTestUtil( ['#file-list li.table-row[selected] .filename-label span']));
'fakeMouseDoubleClick',
appId, // Wait until the widget is loaded.
['#file-list li.table-row[selected] .filename-label span'], chrome.test.assertTrue(!!await remoteCall.waitForElement(
this.next); appId, '#suggest-app-dialog webview[src]'));
},
// Wait for the widget is loaded. // Wait until the widget is initialized.
function(result) { chrome.test.assertTrue(!!await remoteCall.waitForElement(
chrome.test.assertTrue(result); appId, '.cws-widget-spinner-layer:not(.cws-widget-show-spinner)'));
remoteCall.waitForElement(appId, '#suggest-app-dialog webview[src]').
then(this.next);
},
// Wait for the widget is initialized.
function(result) {
chrome.test.assertTrue(!!result);
remoteCall.waitForElement(
appId, '.cws-widget-spinner-layer:not(.cws-widget-show-spinner)').
then(this.next);
},
// Override task APIs for test. // Override task APIs for test.
function(result) { chrome.test.assertTrue(!!await remoteCall.callRemoteTestUtil(
chrome.test.assertTrue(!!result); 'overrideTasks', appId, [[{
remoteCall.callRemoteTestUtil(
'overrideTasks',
appId,
[[
{
driveApp: false, driveApp: false,
iconUrl: 'chrome://theme/IDR_DEFAULT_FAVICON', // Dummy icon iconUrl: 'chrome://theme/IDR_DEFAULT_FAVICON', // Dummy icon
isDefault: true, isDefault: true,
taskId: 'dummytaskid|drive|open-with', taskId: 'dummytaskid|drive|open-with',
title: 'The dummy task for test' title: 'The dummy task for test'
} }]]));
]],
this.next);
},
// Override installWebstoreItem API for test. // Override installWebstoreItem API for test.
function(result) { chrome.test.assertTrue(!!remoteCall.callRemoteTestUtil(
chrome.test.assertTrue(!!result); 'overrideInstallWebstoreItemApi', appId,
remoteCall.callRemoteTestUtil(
'overrideInstallWebstoreItemApi',
appId,
[ [
'DUMMY_ITEM_ID_FOR_TEST', // Same ID in cws_container_mock/main.js. 'DUMMY_ITEM_ID_FOR_TEST', // Same ID in cws_container_mock/main.js.
null // Success null // Success
], ]));
this.next);
},
// Initiate an installation from the widget. // Initiate an installation from the widget.
function(result) { chrome.test.assertTrue(
chrome.test.assertTrue(!!result); !!await remoteCall.callRemoteTestUtil('executeScriptInWebView', appId, [
remoteCall.callRemoteTestUtil( '#suggest-app-dialog webview',
'executeScriptInWebView', 'document.querySelector("button").click()'
appId, ]));
['#suggest-app-dialog webview',
'document.querySelector("button").click()'],
this.next);
},
// Wait until the installation is finished and the dialog is closed. // Wait until the installation is finished and the dialog is closed.
function(result) { chrome.test.assertTrue(
chrome.test.assertTrue(!!result); !!await remoteCall.waitForElementLost(appId, '#suggest-app-dialog'));
remoteCall.waitForElementLost(appId, '#suggest-app-dialog').
then(this.next);
},
// Wait until the task is executed. // Wait until the task is executed.
function(result) { await remoteCall.waitUntilTaskExecutes(appId, 'dummytaskid|drive|open-with');
chrome.test.assertTrue(!!result);
remoteCall.waitUntilTaskExecutes(appId, 'dummytaskid|drive|open-with').
then(this.next);
},
// Check error
function() {
checkIfNoErrorsOccured(this.next);
}
]);
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment