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.
return remoteCall chrome.test.assertTrue(
.callRemoteTestUtil('fakeMouseRightClick', windowId, ['list.list']) !!await remoteCall.callRemoteTestUtil(
.then(function(result) { 'fakeMouseRightClick', appId, ['list.list']),
chrome.test.assertTrue(!!result, 'fakeMouseRightClick failed'); '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"]';
return remoteCall.waitForElement( await remoteCall.waitForElement(appId, contextMenu + ' ' + deleteDisabled);
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.
return remoteCall await remoteCall.waitForFiles(
.waitForFiles( appId, beforeDeletion, {ignoreLastModifiedTime: true});
windowId, beforeDeletion, {ignoreLastModifiedTime: true})
.then(function() {
// Select My Desktop Background.png // Select My Desktop Background.png
return remoteCall.callRemoteTestUtil( chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'selectFile', windowId, ['My Desktop Background.png']); 'selectFile', appId, ['My Desktop Background.png']));
})
.then(function(result) {
chrome.test.assertTrue(result);
// Click delete button in the toolbar. // Click delete button in the toolbar.
return remoteCall.callRemoteTestUtil( chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'fakeMouseClick', windowId, ['button#delete-button']); 'fakeMouseClick', appId, ['button#delete-button']));
})
.then(function(result) {
chrome.test.assertTrue(result);
// Confirm that the confirmation dialog is shown. // Confirm that the confirmation dialog is shown.
return remoteCall.waitForElement( await remoteCall.waitForElement(appId, '.cr-dialog-container.shown');
windowId, '.cr-dialog-container.shown');
})
.then(function() {
// Press delete button. // Press delete button.
return remoteCall.callRemoteTestUtil( chrome.test.assertTrue(
'fakeMouseClick', windowId, ['button.cr-dialog-ok']); !!await remoteCall.callRemoteTestUtil(
}) 'fakeMouseClick', appId, ['button.cr-dialog-ok']),
.then(function(result) { 'fakeMouseClick failed');
chrome.test.assertTrue(!!result, 'fakeMouseClick failed');
// Confirm the file is removed. // Confirm the file is removed.
return remoteCall.waitForFiles( await remoteCall.waitForFiles(
windowId, afterDeletion, {ignoreLastModifiedTime: true}); 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