Skip to content

Commit

Permalink
Add Quick View browser test for file with 'jpeg' extension.
Browse files Browse the repository at this point in the history
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: Alex Danilo <adanilo@chromium.org>
Reviewed-by: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760374}
  • Loading branch information
Josh Simmons authored and Commit Bot committed Apr 20, 2020
1 parent 0c62b5c commit a5637c5
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("openQuickViewAudio"),
TestCase("openQuickViewAudioOnDrive"),
TestCase("openQuickViewAudioWithImageMetadata"),
TestCase("openQuickViewImage"),
TestCase("openQuickViewImageJpg"),
TestCase("openQuickViewImageJpeg"),
TestCase("openQuickViewImageExif"),
TestCase("openQuickViewImageRaw"),
TestCase("openQuickViewImageRawWithOrientation"),
Expand Down
75 changes: 63 additions & 12 deletions ui/file_manager/integration_tests/file_manager/quick_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,8 @@
// Open the file in Quick View.
await openQuickView(appId, ENTRIES.hello.nameText);

// Check: the correct mimeType should be displayed (note: MIME type
// identification differs depending on the metadata provider for the
// 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).
// Check: the correct mimeType should be displayed (see crbug.com/1067499
// for details on mimeType differences between Drive and local filesystem).
const mimeType = await getQuickViewMetadataBoxField(appId, 'Type');
chrome.test.assertEq('text/plain', mimeType);
};
Expand Down Expand Up @@ -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 () => {
const caller = getCaller();
Expand Down Expand Up @@ -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();

/**
Expand Down Expand Up @@ -1143,8 +1139,59 @@
};

/**
* Tests opening Quick View on an JPEG image that has EXIF displays the EXIF
* information in the QuickView Metadata Box.
* Tests opening Quick View containing an image with extension 'jpeg'.
*/
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 () => {
const caller = getCaller();
Expand Down Expand Up @@ -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 () => {
const caller = getCaller();
Expand Down Expand Up @@ -1501,6 +1548,10 @@
// 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('video/webm', mimeType);

// Close Quick View.
await closeQuickView(appId);

Expand Down
12 changes: 12 additions & 0 deletions ui/file_manager/integration_tests/test_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,18 @@ const ENTRIES = {
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({
type: EntryType.FILE,
sourceFileName: 'broken.jpg',
Expand Down

0 comments on commit a5637c5

Please sign in to comment.