Commit f9be676a authored by Rachel Sugrono's avatar Rachel Sugrono Committed by Commit Bot

[quickview] Test the PDF file is displayed when multiple files are

selected

Check-select an image and a PDF file, show the files in Quick View,
and down-arrow to the PDF file.

Check the PDF file is displayed in Quick View (tests a bug where the
PDF file was not being displayed, which was fixed in CL:2007795).

Bug: 1038799
Change-Id: I5e6eda55c64458f7fd82a343597906399ba5feda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2010602
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733506}
parent e0e1250b
......@@ -471,6 +471,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("pressEnterOnInfoBoxToOpenClose"),
TestCase("openQuickViewWithMultipleFiles"),
TestCase("openQuickViewWithMultipleFilesText"),
TestCase("openQuickViewWithMultipleFilesPdf"),
TestCase("openQuickViewWithMultipleFilesKeyboardUpDown"),
TestCase("openQuickViewWithMultipleFilesKeyboardLeftRight"),
TestCase("closeQuickView"),
......
......@@ -1378,6 +1378,109 @@
appId, ['#quick-view', '#open-button:not([hidden])']);
};
/**
* Tests that Quick View displays pdf files when multiple files are
* selected.
*/
testcase.openQuickViewWithMultipleFilesPdf = 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'];
const files = [ENTRIES.tallPdf, ENTRIES.desktop, ENTRIES.smallJpeg];
const appId = await setupAndWaitUntilReady(RootPath.DOWNLOADS, files, []);
// Add item 1 to the check-selection, ENTRIES.smallJpeg.
const downKey = ['#file-list', 'ArrowDown', false, false, false];
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 3 to the check-selection, ENTRIES.tallPdf.
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(['small']));
chrome.test.assertTrue(
selectedRows[1].attributes['file-name'].includes(['tall']));
// Attempt to 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: the image file should be displayed in the content panel.
await repeatUntil(async () => {
return checkWebViewImageLoaded(await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, [webView, ['display']]));
});
/**
* The PDF <webview> resides in the #quick-view shadow DOM, as a child of
* the #dialog element.
*/
const pdfView = ['#quick-view', '#dialog[open] webview.content'];
// Press the down arrow key to select the next file.
const downArrow = ['#quick-view', 'ArrowDown', false, false, false];
chrome.test.assertTrue(
await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, downArrow));
// Wait for the Quick View <webview> to load and display its content.
function checkWebViewPdfLoaded(elements) {
let haveElements = Array.isArray(elements) && elements.length === 1;
if (haveElements) {
haveElements = elements[0].styles.display.includes('block');
}
if (!haveElements || !elements[0].attributes.src) {
return pending(caller, 'Waiting for <webview> to load.');
}
return;
}
// Check: the pdf file should be displayed in the content panel.
await repeatUntil(async () => {
return checkWebViewPdfLoaded(await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, [pdfView, ['display']]));
});
// Check: the open button should be displayed.
await remoteCall.waitForElement(
appId, ['#quick-view', '#open-button:not([hidden])']);
};
/**
* Tests that the content panel changes when using the up/down arrow keys
* when multiple files are selected.
......
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