Commit 3ba0d67f authored by Noel Gordon's avatar Noel Gordon Committed by Chromium LUCI CQ

[quickview] Add a QuickView popup PDF file integration test

Bug: 1168436
Change-Id: I59adea182ac7dfaa4dfd2b24e64eb032c83e3b2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2631397Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845416}
parent ea71d3fe
...@@ -504,6 +504,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P( ...@@ -504,6 +504,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("openQuickViewVideo"), TestCase("openQuickViewVideo"),
TestCase("openQuickViewVideoOnDrive"), TestCase("openQuickViewVideoOnDrive"),
TestCase("openQuickViewPdf"), TestCase("openQuickViewPdf"),
TestCase("openQuickViewPdfPopup"),
TestCase("openQuickViewPdfPreviewsDisabled"), TestCase("openQuickViewPdfPreviewsDisabled"),
TestCase("openQuickViewKeyboardUpDownChangesView"), TestCase("openQuickViewKeyboardUpDownChangesView"),
TestCase("openQuickViewKeyboardLeftRightChangesView"), TestCase("openQuickViewKeyboardLeftRightChangesView"),
......
This diff was suppressed by a .gitattributes entry.
...@@ -899,6 +899,63 @@ ...@@ -899,6 +899,63 @@
chrome.test.assertEq('application/pdf', mimeType); chrome.test.assertEq('application/pdf', mimeType);
}; };
/**
* Tests opening Quick View on a PDF document that opens a popup JS dialog.
*/
testcase.openQuickViewPdfPopup = async () => {
const caller = getCaller();
/**
* The PDF <webview> resides in the #quick-view shadow DOM, as a child of
* the #dialog element.
*/
const webView = ['#quick-view', '#dialog[open] webview.content'];
// Open Files app on Downloads containing ENTRIES.popupPdf.
const appId = await setupAndWaitUntilReady(
RootPath.DOWNLOADS, [ENTRIES.popupPdf], []);
// Open the file in Quick View.
await openQuickView(appId, ENTRIES.popupPdf.nameText);
// 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;
}
await repeatUntil(async () => {
return checkWebViewPdfLoaded(await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, [webView, ['display']]));
});
// Get the <webview> embed type attribute.
function checkPdfEmbedType(type) {
const haveElements = Array.isArray(type) && type.length === 1;
if (!haveElements || !type[0].toString().includes('pdf')) {
return pending(caller, 'Waiting for plugin <embed> type.');
}
return type[0];
}
const type = await repeatUntil(async () => {
const getType = 'window.document.querySelector("embed").type';
return checkPdfEmbedType(await remoteCall.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [webView, getType]));
});
// Check: the <webview> embed type should be PDF mime type.
chrome.test.assertEq('application/pdf', type);
// Check: the correct mimeType should be displayed.
const mimeType = await getQuickViewMetadataBoxField(appId, 'Type');
chrome.test.assertEq('application/pdf', mimeType);
};
/** /**
* Tests that Quick View does not display a PDF file preview when that is * Tests that Quick View does not display a PDF file preview when that is
* disabled by system settings (preferences). * disabled by system settings (preferences).
......
...@@ -771,6 +771,17 @@ const ENTRIES = { ...@@ -771,6 +771,17 @@ const ENTRIES = {
typeText: 'PDF document', typeText: 'PDF document',
}), }),
popupPdf: new TestEntryInfo({
type: EntryType.FILE,
sourceFileName: 'popup.pdf',
targetPath: 'popup.pdf',
mimeType: 'application/pdf',
lastModifiedTime: 'Jul 4, 2000, 10:42 AM',
nameText: 'popup.pdf',
sizeText: '538 bytes',
typeText: 'PDF document',
}),
imgPdf: new TestEntryInfo({ imgPdf: new TestEntryInfo({
type: EntryType.FILE, type: EntryType.FILE,
sourceFileName: 'img.pdf', sourceFileName: 'img.pdf',
......
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