Commit 5318cda4 authored by Isabella Scalzi's avatar Isabella Scalzi Committed by Commit Bot

[quickview] add |deleteItemFromQuickViewCheckSelection| test

Add a test that tests deleting an item from Quick View that is part of
a check selection.

Bug: 803259
Change-Id: Icf9c77eee2fbeb400a981a0ecbe481addffaae2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2038295
Commit-Queue: Isabella Scalzi <isabellascalzi@google.com>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738762}
parent 825d6b20
......@@ -483,7 +483,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("openQuickViewWithMultipleFilesKeyboardLeftRight"),
TestCase("closeQuickView"),
TestCase("openQuickViewFromDirectoryTree"),
TestCase("deleteItemFromQuickViewSingleSelection")));
TestCase("deleteItemFromQuickViewSingleSelection"),
TestCase("deleteItemFromQuickViewCheckSelection")));
WRAPPED_INSTANTIATE_TEST_SUITE_P(
DirectoryTree, /* directory_tree.js */
......
......@@ -2085,4 +2085,88 @@
// Check: Quick View has closed.
await waitQuickViewClose(appId);
};
/**
* Tests deleting an item from Quick View while in check-selection mode.
* Deletes the item at the bottom of the file list, and checks that
* the item below the item deleted is shown in Quick View after the item's
* deletion.
*/
testcase.deleteItemFromQuickViewCheckSelection = async () => {
// Open Files app on Downloads containing BASIC_LOCAL_ENTRY_SET.
const appId = await setupAndWaitUntilReady(
RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET, []);
const caller = getCaller();
// Ctrl+A to select all files in the file-list.
const ctrlA = ['#file-list', 'a', true, false, false];
chrome.test.assertTrue(
!!await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, ctrlA),
'Ctrl+A failed');
function checkQuickViewElementsDisplayBlock(elements) {
const haveElements = Array.isArray(elements) && elements.length !== 0;
if (!haveElements || elements[0].styles.display !== 'block') {
return pending(caller, 'Waiting for Quick View to open.');
}
return;
}
// Open Quick View via its keyboard shortcut.
const space = ['#file-list', ' ', false, false, false];
await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, space);
// Check: the Quick View dialog should be shown.
await repeatUntil(async () => {
const elements = ['#quick-view', '#dialog[open]'];
return checkQuickViewElementsDisplayBlock(
await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, [elements, ['display']]));
});
// Press the up arrow to go to the last file in the selection.
const quickViewArrowUp = ['#quick-view', 'ArrowUp', false, false, false];
chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId, quickViewArrowUp));
// Open the Quick View delete confirm dialog.
const deleteKey = ['#quick-view', 'Delete', false, false, false];
chrome.test.assertTrue(
await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, deleteKey),
'Pressing Delete failed.');
// Click the delete confirm dialog OK button.
const deleteConfirm = ['#quick-view', '.cr-dialog-ok:not([hidden])'];
await remoteCall.waitAndClickElement(appId, deleteConfirm);
// Check: the hello.txt file should be deleted.
await remoteCall.waitForElementLost(
appId, '#file-list [file-name="hello.txt"]');
// Check: Quick View should display the entry below |hello.txt|,
// which is |world.ogv|.
function checkWebViewVideoLoaded(elements) {
let haveElements = Array.isArray(elements) && elements.length === 1;
if (haveElements) {
haveElements = elements[0].styles.display.includes('block');
}
if (!haveElements || elements[0].attributes.loaded !== '') {
return pending(caller, 'Waiting for <webview> to load.');
}
return;
}
const videoWebView =
['#quick-view', 'files-safe-media[type="video"]', 'webview'];
await repeatUntil(async () => {
return checkWebViewVideoLoaded(await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, [videoWebView, ['display']]));
});
// Check: The MIME type of |world.ogv| is audio/ogg
const mimeType = await getQuickViewMetadataBoxField(appId, 'Type');
chrome.test.assertEq(mimeType, 'audio/ogg');
};
})();
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