Commit fc1b962d authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[quickview] Add UTF-8 text file preview test

Load a file containing UTF-8 and other characters in the preview panel
and wait for the <webview> to load and display the file content [1].

Read the displayed text content and verify. Test is a PASS if the text
content of the <webview> contains 'їсти मुझे |∊🙂\n' and the right
file size "191 bytes" is shown in the quick view metadata box.

[1] Note: the test file must have a file extension that is known to be
text (an extension that files app deems to be text) to enable UTF-8 in
the preview panel <webview> renderer.

Test: browser_tests --gtest_filter="*openQuickViewUtf8Text"
Bug: 1064855
Change-Id: I7c07b7f98922a1bb93ea2b46c3bc93dd4ee9085d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426084
Auto-Submit: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810033}
parent 12ca867e
......@@ -507,6 +507,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("openQuickViewKeyboardLeftRightChangesView"),
TestCase("openQuickViewSniffedText"),
TestCase("openQuickViewTextFileWithUnknownMimeType"),
TestCase("openQuickViewUtf8Text"),
TestCase("openQuickViewScrollText"),
TestCase("openQuickViewScrollHtml"),
TestCase("openQuickViewMhtml"),
......
......@@ -620,6 +620,58 @@
await remoteCall.waitForElement(appId, mimeTypeQuery);
};
/**
* Tests opening Quick View with a text file containing some UTF-8 encoded
* characters: crbug.com/1064855
*/
testcase.openQuickViewUtf8Text = async () => {
const caller = getCaller();
/**
* The text <webview> resides in the #quick-view shadow DOM, as a child of
* the #dialog element.
*/
const webView = ['#quick-view', '#dialog[open] webview.text-content'];
// Open Files app on Downloads containing ENTRIES.utf8Text.
const appId = await setupAndWaitUntilReady(
RootPath.DOWNLOADS, [ENTRIES.utf8Text], []);
// Open the file in Quick View.
await openQuickView(appId, ENTRIES.utf8Text.nameText);
// Wait for the Quick View <webview> to load and display its content.
function checkWebViewTextLoaded(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 checkWebViewTextLoaded(await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, [webView, ['display']]));
});
// Wait until the <webview> displays the file's content.
await repeatUntil(async () => {
const getTextContent = 'window.document.body.textContent';
const text = await remoteCall.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [webView, getTextContent]);
// Check: the content of ENTRIES.utf8Text should be shown.
if (!text || !text[0].includes('їсти मुझे |∊☀✌✂♁ 🙂\n')) {
return pending(caller, 'Waiting for <webview> content.');
}
});
// Check: the correct file size should be shown.
const size = await getQuickViewMetadataBoxField(appId, 'Size');
chrome.test.assertEq('191 bytes', size);
};
/**
* Tests opening Quick View and scrolling its <webview> which contains a tall
* text document.
......
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