Commit a5637c5c authored by Josh Simmons's avatar Josh Simmons Committed by Commit Bot

Add Quick View browser test for file with 'jpeg' extension.

Bug 1067499 requires the addition of individual browser tests to
validate the MIME type detected and reported by Quick View for all
file extensions known to Files.app. This CL adds a new test for files
with extension 'jpeg' and more clearly names the existing test for files
with extension 'jpg'.

Bug: 1067499
Test: browser_tests --gtest_filter="*FilesApp*openQuickView*"
Change-Id: I03d72d6d7daeffb2f14f5bf0083b07ca328b685d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153461
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760374}
parent 0c62b5c8
...@@ -486,7 +486,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P( ...@@ -486,7 +486,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("openQuickViewAudio"), TestCase("openQuickViewAudio"),
TestCase("openQuickViewAudioOnDrive"), TestCase("openQuickViewAudioOnDrive"),
TestCase("openQuickViewAudioWithImageMetadata"), TestCase("openQuickViewAudioWithImageMetadata"),
TestCase("openQuickViewImage"), TestCase("openQuickViewImageJpg"),
TestCase("openQuickViewImageJpeg"),
TestCase("openQuickViewImageExif"), TestCase("openQuickViewImageExif"),
TestCase("openQuickViewImageRaw"), TestCase("openQuickViewImageRaw"),
TestCase("openQuickViewImageRawWithOrientation"), TestCase("openQuickViewImageRawWithOrientation"),
......
...@@ -305,12 +305,8 @@ ...@@ -305,12 +305,8 @@
// Open the file in Quick View. // Open the file in Quick View.
await openQuickView(appId, ENTRIES.hello.nameText); await openQuickView(appId, ENTRIES.hello.nameText);
// Check: the correct mimeType should be displayed (note: MIME type // Check: the correct mimeType should be displayed (see crbug.com/1067499
// identification differs depending on the metadata provider for the // for details on mimeType differences between Drive and local filesystem).
// underlying volume. Here, it is reported as text/plain for ENTRIES.hello,
// because the file is on Drive, later (see
// openQuickViewTextFileWithUnknownMimeType) it is not reported because the
// file is on the local filesystem).
const mimeType = await getQuickViewMetadataBoxField(appId, 'Type'); const mimeType = await getQuickViewMetadataBoxField(appId, 'Type');
chrome.test.assertEq('text/plain', mimeType); chrome.test.assertEq('text/plain', mimeType);
}; };
...@@ -988,7 +984,7 @@ ...@@ -988,7 +984,7 @@
}; };
/** /**
* Tests opening Quick View containing an audio file. * Tests opening Quick View containing an audio file on Drive.
*/ */
testcase.openQuickViewAudioOnDrive = async () => { testcase.openQuickViewAudioOnDrive = async () => {
const caller = getCaller(); const caller = getCaller();
...@@ -1093,9 +1089,9 @@ ...@@ -1093,9 +1089,9 @@
}; };
/** /**
* Tests opening Quick View containing an image. * Tests opening Quick View containing an image with extension 'jpg'.
*/ */
testcase.openQuickViewImage = async () => { testcase.openQuickViewImageJpg = async () => {
const caller = getCaller(); const caller = getCaller();
/** /**
...@@ -1143,8 +1139,59 @@ ...@@ -1143,8 +1139,59 @@
}; };
/** /**
* Tests opening Quick View on an JPEG image that has EXIF displays the EXIF * Tests opening Quick View containing an image with extension 'jpeg'.
* information in the QuickView Metadata Box. */
testcase.openQuickViewImageJpeg = 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 ENTRIES.sampleJpeg.
const appId = await setupAndWaitUntilReady(
RootPath.DOWNLOADS, [ENTRIES.sampleJpeg], []);
// Open the file in Quick View.
await openQuickView(appId, ENTRIES.sampleJpeg.nameText);
// 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;
}
await repeatUntil(async () => {
return checkWebViewImageLoaded(await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, [webView, ['display']]));
});
// Get the <webview> document.body backgroundColor style.
const getBackgroundStyle =
'window.getComputedStyle(document.body).backgroundColor';
const backgroundColor = await remoteCall.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [webView, getBackgroundStyle]);
// Check: the <webview> body backgroundColor should be transparent black.
chrome.test.assertEq('rgba(0, 0, 0, 0)', backgroundColor[0]);
// Check: the correct mimeType should be displayed.
const mimeType = await getQuickViewMetadataBoxField(appId, 'Type');
chrome.test.assertEq('image/jpeg', mimeType);
};
/**
* Tests opening Quick View on an JPEG image that has EXIF
* displays the EXIF information in the QuickView Metadata
* Box.
*/ */
testcase.openQuickViewImageExif = async () => { testcase.openQuickViewImageExif = async () => {
const caller = getCaller(); const caller = getCaller();
...@@ -1457,7 +1504,7 @@ ...@@ -1457,7 +1504,7 @@
}; };
/** /**
* Tests opening Quick View containing a video on DriveFS. * Tests opening Quick View containing a video on Drive.
*/ */
testcase.openQuickViewVideoOnDrive = async () => { testcase.openQuickViewVideoOnDrive = async () => {
const caller = getCaller(); const caller = getCaller();
...@@ -1501,6 +1548,10 @@ ...@@ -1501,6 +1548,10 @@
// Check: the <webview> body backgroundColor should be transparent black. // Check: the <webview> body backgroundColor should be transparent black.
chrome.test.assertEq('rgba(0, 0, 0, 0)', backgroundColor[0]); chrome.test.assertEq('rgba(0, 0, 0, 0)', backgroundColor[0]);
// Check: the correct mimeType should be displayed.
const mimeType = await getQuickViewMetadataBoxField(appId, 'Type');
chrome.test.assertEq('video/webm', mimeType);
// Close Quick View. // Close Quick View.
await closeQuickView(appId); await closeQuickView(appId);
......
...@@ -581,6 +581,18 @@ const ENTRIES = { ...@@ -581,6 +581,18 @@ const ENTRIES = {
typeText: 'JPEG image' typeText: 'JPEG image'
}), }),
// Used to differentiate between .jpg and .jpeg handling.
sampleJpeg: new TestEntryInfo({
type: EntryType.FILE,
sourceFileName: 'small.jpg',
targetPath: 'sample.jpeg',
mimeType: 'image/jpeg',
lastModifiedTime: 'Jan 18, 2038, 1:02 AM',
nameText: 'sample.jpeg',
sizeText: '1 KB',
typeText: 'JPEG image'
}),
brokenJpeg: new TestEntryInfo({ brokenJpeg: new TestEntryInfo({
type: EntryType.FILE, type: EntryType.FILE,
sourceFileName: 'broken.jpg', sourceFileName: 'broken.jpg',
......
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