Commit 8bcbdb3b authored by Rachel Sugrono's avatar Rachel Sugrono Committed by Commit Bot

[quickview] Test that Quick View opens with check-select

Add two non-consecutive files to a check-select (aka a multi-
selection). Quick View should open in check-select mode with
the first file being displayed.

Bug: 1038799
Change-Id: I1fada68b30ae3bd48df69d96669255aa166787ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006892Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732738}
parent ef72c91e
...@@ -469,6 +469,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P( ...@@ -469,6 +469,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("openQuickViewTabIndexAudio"), TestCase("openQuickViewTabIndexAudio"),
TestCase("openQuickViewTabIndexVideo"), TestCase("openQuickViewTabIndexVideo"),
TestCase("pressEnterOnInfoBoxToOpenClose"), TestCase("pressEnterOnInfoBoxToOpenClose"),
TestCase("openQuickViewWithMultipleFiles"),
TestCase("closeQuickView"), TestCase("closeQuickView"),
TestCase("openQuickViewFromDirectoryTree"))); TestCase("openQuickViewFromDirectoryTree")));
......
...@@ -1199,6 +1199,82 @@ ...@@ -1199,6 +1199,82 @@
await closeQuickView(appId); await closeQuickView(appId);
}; };
/**
* Tests that Quick View opens with multiple files selected.
*/
testcase.openQuickViewWithMultipleFiles = async () => {
const caller = getCaller();
/**
* The <webview> resides in the <files-safe-media type="image"> shadow DOM,
* which is a child of the #quick-view shadow DOM.
*/
const webView =
['#quick-view', 'files-safe-media[type="image"]', 'webview'];
// Open Files app on Downloads containing BASIC_LOCAL_ENTRY_SET.
const appId = await setupAndWaitUntilReady(
RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET, []);
// Add item 3 to the check-selection, ENTRIES.desktop.
const downKey = ['#file-list', 'ArrowDown', false, false, false];
for (let i = 0; i < 3; i++) {
chrome.test.assertTrue(
!!await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, downKey),
'ArrowDown failed');
}
const ctrlSpace = ['#file-list', ' ', true, false, false];
chrome.test.assertTrue(
!!await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, ctrlSpace),
'Ctrl+Space failed');
// Add item 5 to the check-selection, ENTRIES.hello.
const ctrlDown = ['#file-list', 'ArrowDown', true, false, false];
for (let i = 0; i < 2; i++) {
chrome.test.assertTrue(
!!await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, ctrlDown),
'Ctrl+ArrowDown failed');
}
chrome.test.assertTrue(
!!await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, ctrlSpace),
'Ctrl+Space failed');
// Check: both items should be selected.
const selectedRows = await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, ['#file-list li[selected]']);
chrome.test.assertEq(2, selectedRows.length);
chrome.test.assertTrue(
selectedRows[0].attributes['file-name'].includes(['Desktop']));
chrome.test.assertTrue(
selectedRows[1].attributes['file-name'].includes(['hello']));
// Open Quick View via its keyboard shortcut.
const space = ['#file-list', ' ', false, false, false];
await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, space);
// Wait for the Quick View <webview> to load and display its content.
function checkWebViewImageLoaded(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;
}
// Check: ENTRIES.desktop should be displayed in the webview.
await repeatUntil(async () => {
return checkWebViewImageLoaded(await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, [webView, ['display']]));
});
// Check: the correct file mimeType should be displayed.
const mimeType = await getQuickViewMetadataBoxField(appId, 'Type');
chrome.test.assertEq('image/png', mimeType);
};
/** /**
* Tests opening Quick View and closing with Escape key returns focus to file * Tests opening Quick View and closing with Escape key returns focus to file
* list. * list.
......
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