Commit 192bd649 authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Convert delete.js to use async-await.

Bug: 909056
Change-Id: I921d0807bf9cf84874664ab89e9a68a60aca4cd5
Reviewed-on: https://chromium-review.googlesource.com/c/1355022Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Sam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612455}
parent 05fbd624
// Copyright 2015 The Chromium Authors. All rights reserved. // Copyright 2015 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.
/** /**
* Tests that the Delete menu item is disabled if no entry is selected. * Tests that the Delete menu item is disabled if no entry is selected.
*/ */
testcase.deleteMenuItemNoEntrySelected = function() { testcase.deleteMenuItemNoEntrySelected = async function() {
const contextMenu = '#file-context-menu:not([hidden])'; const contextMenu = '#file-context-menu:not([hidden])';
testPromise(setupAndWaitUntilReady(null, RootPath.DOWNLOADS).then( const {appId} = await setupAndWaitUntilReady(null, RootPath.DOWNLOADS);
function(results) {
var windowId = results.windowId; // Right click the list without selecting an entry.
// Right click the list without selecting an entry. chrome.test.assertTrue(
return remoteCall !!await remoteCall.callRemoteTestUtil(
.callRemoteTestUtil('fakeMouseRightClick', windowId, ['list.list']) 'fakeMouseRightClick', appId, ['list.list']),
.then(function(result) { 'fakeMouseRightClick failed');
chrome.test.assertTrue(!!result, 'fakeMouseRightClick failed');
// Wait until the context menu is shown. // Wait until the context menu is shown.
return remoteCall.waitForElement(windowId, contextMenu); await remoteCall.waitForElement(appId, contextMenu);
})
.then(function() { // Assert the menu delete command is disabled.
// Assert the menu delete command is disabled. const deleteDisabled = '[command="#delete"][disabled="disabled"]';
const deleteDisabled = '[command="#delete"][disabled="disabled"]'; await remoteCall.waitForElement(appId, contextMenu + ' ' + deleteDisabled);
return remoteCall.waitForElement(
windowId, contextMenu + ' ' + deleteDisabled);
});
}));
}; };
/** /**
* Tests deleting an entry using the toolbar. * Tests deleting an entry using the toolbar.
*/ */
testcase.deleteEntryWithToolbar = function() { testcase.deleteEntryWithToolbar = async function() {
var beforeDeletion = TestEntryInfo.getExpectedRows([ var beforeDeletion = TestEntryInfo.getExpectedRows([
ENTRIES.photos, ENTRIES.photos,
ENTRIES.hello, ENTRIES.hello,
ENTRIES.world, ENTRIES.world,
ENTRIES.desktop, ENTRIES.desktop,
ENTRIES.beautiful ENTRIES.beautiful,
]); ]);
var afterDeletion = TestEntryInfo.getExpectedRows([ var afterDeletion = TestEntryInfo.getExpectedRows([
ENTRIES.photos, ENTRIES.photos,
ENTRIES.hello, ENTRIES.hello,
ENTRIES.world, ENTRIES.world,
ENTRIES.beautiful ENTRIES.beautiful,
]); ]);
testPromise(setupAndWaitUntilReady(null, RootPath.DOWNLOADS).then( const {appId} = await setupAndWaitUntilReady(null, RootPath.DOWNLOADS);
function(results) {
var windowId = results.windowId; // Confirm entries in the directory before the deletion.
// Confirm entries in the directory before the deletion. await remoteCall.waitForFiles(
return remoteCall appId, beforeDeletion, {ignoreLastModifiedTime: true});
.waitForFiles(
windowId, beforeDeletion, {ignoreLastModifiedTime: true}) // Select My Desktop Background.png
.then(function() { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
// Select My Desktop Background.png 'selectFile', appId, ['My Desktop Background.png']));
return remoteCall.callRemoteTestUtil(
'selectFile', windowId, ['My Desktop Background.png']);
}) // Click delete button in the toolbar.
.then(function(result) { chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
chrome.test.assertTrue(result); 'fakeMouseClick', appId, ['button#delete-button']));
// Click delete button in the toolbar.
return remoteCall.callRemoteTestUtil(
'fakeMouseClick', windowId, ['button#delete-button']); // Confirm that the confirmation dialog is shown.
}) await remoteCall.waitForElement(appId, '.cr-dialog-container.shown');
.then(function(result) {
chrome.test.assertTrue(result); // Press delete button.
// Confirm that the confirmation dialog is shown. chrome.test.assertTrue(
return remoteCall.waitForElement( !!await remoteCall.callRemoteTestUtil(
windowId, '.cr-dialog-container.shown'); 'fakeMouseClick', appId, ['button.cr-dialog-ok']),
}) 'fakeMouseClick failed');
.then(function() {
// Press delete button. // Confirm the file is removed.
return remoteCall.callRemoteTestUtil( await remoteCall.waitForFiles(
'fakeMouseClick', windowId, ['button.cr-dialog-ok']); appId, afterDeletion, {ignoreLastModifiedTime: true});
})
.then(function(result) {
chrome.test.assertTrue(!!result, 'fakeMouseClick failed');
// Confirm the file is removed.
return remoteCall.waitForFiles(
windowId, afterDeletion, {ignoreLastModifiedTime: true});
});
}));
}; };
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