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

Add Quick View support for video files on DriveFS

Treat video files on DriveFS as if they were local when launching Quick
View. This results in auto-play (where the media is decodable).

DriveFS streams large files so if the user cancels / pauses the playback
there will not be unnecessary data transferred.

Bug: 1059072
Test: browser_tests --gtest_filter="openQuickViewVideoOnDrive"
Change-Id: I0bd6020acdaad8980c7fcf6f48891389d20e8a27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2089439Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Commit-Queue: Josh Simmons <simmonsjosh@google.com>
Cr-Commit-Position: refs/heads/master@{#747526}
parent ee8bfb35
......@@ -479,6 +479,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("openQuickViewBrokenImage"),
TestCase("openQuickViewImageClick"),
TestCase("openQuickViewVideo"),
TestCase("openQuickViewVideoOnDrive"),
TestCase("openQuickViewPdf"),
TestCase("openQuickViewPdfPreviewsDisabled"),
TestCase("openQuickViewKeyboardUpDownChangesView"),
......
......@@ -517,7 +517,7 @@ class QuickViewController {
volumeInfo.volumeType) >= 0;
// Treat certain types on Drive as if they were local (try auto-play etc).
if (entryIsOnDrive && type === 'audio') {
if (entryIsOnDrive && (type === 'audio' || type === 'video')) {
localFile = true;
}
......
......@@ -1302,6 +1302,60 @@
await remoteCall.waitForElement(appId, noSrcFilesSafeMedia);
};
/**
* Tests opening Quick View containing a video on DriveFS.
*/
testcase.openQuickViewVideoOnDrive = async () => {
const caller = getCaller();
/**
* The <webview> resides in the <files-safe-media type="video"> shadow DOM,
* which is a child of the #quick-view shadow DOM.
*/
const webView =
['#quick-view', 'files-safe-media[type="video"]', 'webview'];
// Open Files app on Downloads containing ENTRIES.webm video.
const appId =
await setupAndWaitUntilReady(RootPath.DRIVE, [], [ENTRIES.webm]);
// Open the file in Quick View.
await openQuickView(appId, ENTRIES.webm.nameText);
// Wait for the Quick View <webview> to load and display its content.
function checkWebViewVideoLoaded(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 checkWebViewVideoLoaded(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]);
// Close Quick View.
await closeQuickView(appId);
// Check quickview video <files-safe-media> has no "src", so it stops
// playing the video. crbug.com/970192
const noSrcFilesSafeMedia = ['#quick-view', '#videoSafeMedia[src=""]'];
await remoteCall.waitForElement(appId, noSrcFilesSafeMedia);
};
/**
* Tests opening Quick View with multiple files and using the up/down arrow
* keys to select and view their content.
......
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