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.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* 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])';
testPromise(setupAndWaitUntilReady(null, RootPath.DOWNLOADS).then(
function(results) {
var windowId = results.windowId;
// Right click the list without selecting an entry.
return remoteCall
.callRemoteTestUtil('fakeMouseRightClick', windowId, ['list.list'])
.then(function(result) {
chrome.test.assertTrue(!!result, 'fakeMouseRightClick failed');
// Wait until the context menu is shown.
return remoteCall.waitForElement(windowId, contextMenu);
})
.then(function() {
// Assert the menu delete command is disabled.
const deleteDisabled = '[command="#delete"][disabled="disabled"]';
return remoteCall.waitForElement(
windowId, contextMenu + ' ' + deleteDisabled);
});
}));
const {appId} = await setupAndWaitUntilReady(null, RootPath.DOWNLOADS);
// Right click the list without selecting an entry.
chrome.test.assertTrue(
!!await remoteCall.callRemoteTestUtil(
'fakeMouseRightClick', appId, ['list.list']),
'fakeMouseRightClick failed');
// Wait until the context menu is shown.
await remoteCall.waitForElement(appId, contextMenu);
// Assert the menu delete command is disabled.
const deleteDisabled = '[command="#delete"][disabled="disabled"]';
await remoteCall.waitForElement(appId, contextMenu + ' ' + deleteDisabled);
};
/**
* Tests deleting an entry using the toolbar.
*/
testcase.deleteEntryWithToolbar = function() {
testcase.deleteEntryWithToolbar = async function() {
var beforeDeletion = TestEntryInfo.getExpectedRows([
ENTRIES.photos,
ENTRIES.hello,
ENTRIES.world,
ENTRIES.desktop,
ENTRIES.beautiful
ENTRIES.photos,
ENTRIES.hello,
ENTRIES.world,
ENTRIES.desktop,
ENTRIES.beautiful,
]);
var afterDeletion = TestEntryInfo.getExpectedRows([
ENTRIES.photos,
ENTRIES.hello,
ENTRIES.world,
ENTRIES.beautiful
ENTRIES.photos,
ENTRIES.hello,
ENTRIES.world,
ENTRIES.beautiful,
]);
testPromise(setupAndWaitUntilReady(null, RootPath.DOWNLOADS).then(
function(results) {
var windowId = results.windowId;
// Confirm entries in the directory before the deletion.
return remoteCall
.waitForFiles(
windowId, beforeDeletion, {ignoreLastModifiedTime: true})
.then(function() {
// Select My Desktop Background.png
return remoteCall.callRemoteTestUtil(
'selectFile', windowId, ['My Desktop Background.png']);
})
.then(function(result) {
chrome.test.assertTrue(result);
// Click delete button in the toolbar.
return remoteCall.callRemoteTestUtil(
'fakeMouseClick', windowId, ['button#delete-button']);
})
.then(function(result) {
chrome.test.assertTrue(result);
// Confirm that the confirmation dialog is shown.
return remoteCall.waitForElement(
windowId, '.cr-dialog-container.shown');
})
.then(function() {
// Press delete button.
return remoteCall.callRemoteTestUtil(
'fakeMouseClick', windowId, ['button.cr-dialog-ok']);
})
.then(function(result) {
chrome.test.assertTrue(!!result, 'fakeMouseClick failed');
// Confirm the file is removed.
return remoteCall.waitForFiles(
windowId, afterDeletion, {ignoreLastModifiedTime: true});
});
}));
const {appId} = await setupAndWaitUntilReady(null, RootPath.DOWNLOADS);
// Confirm entries in the directory before the deletion.
await remoteCall.waitForFiles(
appId, beforeDeletion, {ignoreLastModifiedTime: true});
// Select My Desktop Background.png
chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'selectFile', appId, ['My Desktop Background.png']));
// Click delete button in the toolbar.
chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['button#delete-button']));
// Confirm that the confirmation dialog is shown.
await remoteCall.waitForElement(appId, '.cr-dialog-container.shown');
// Press delete button.
chrome.test.assertTrue(
!!await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['button.cr-dialog-ok']),
'fakeMouseClick failed');
// Confirm the file is removed.
await remoteCall.waitForFiles(
appId, 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