Commit 93568e3a authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Convert quick_view.js to use async-await.

Bug: 909056
Change-Id: I0ed854a15d1ba9a2bfdda3be71430a34b808bfc8
Reviewed-on: https://chromium-review.googlesource.com/c/1351978Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Sam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612139}
parent fa4c2667
// Copyright 2016 The Chromium Authors. All rights reserved. // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
'use strict'; 'use strict';
/** /**
* Returns an array of steps that opens the Quick View dialog on a given file * Opens the Quick View dialog on a given file |name|. The file must be present
* |name|. The file must be present in the Files app file list. * in the Files app file list.
* *
* @param {string} appId Files app windowId. * @param {string} appId Files app windowId.
* @param {string} name File name. * @param {string} name File name.
* @return {!Array<function>}
*/ */
function openQuickViewSteps(appId, name) { async function openQuickView(appId, name) {
let caller = getCaller(); let caller = getCaller();
function checkQuickViewElementsDisplayBlock(elements) { function checkQuickViewElementsDisplayBlock(elements) {
...@@ -22,39 +20,33 @@ function openQuickViewSteps(appId, name) { ...@@ -22,39 +20,33 @@ function openQuickViewSteps(appId, name) {
return; return;
} }
return [ // Select file |name| in the file list.
// Select file |name| in the file list. chrome.test.assertTrue(
function() { !!await remoteCall.callRemoteTestUtil('selectFile', appId, [name]),
remoteCall.callRemoteTestUtil('selectFile', appId, [name], this.next); 'selectFile failed');
},
// Press the space key. // Press the space key.
function(result) { const space = ['#file-list', ' ', false, false, false];
chrome.test.assertTrue(!!result, 'selectFile failed'); chrome.test.assertTrue(
const space = ['#file-list', ' ', false, false, false]; !!await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, space),
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, space, this.next); 'fakeKeyDown failed');
},
// Check: the Quick View element should be shown. // Check: the Quick View element should be shown.
function(result) { await repeatUntil(async () => {
chrome.test.assertTrue(!!result, 'fakeKeyDown failed'); const elements = ['#quick-view', '#dialog[open]'];
repeatUntil(function() { return checkQuickViewElementsDisplayBlock(
const elements = ['#quick-view', '#dialog[open]']; await remoteCall.callRemoteTestUtil(
return remoteCall 'deepQueryAllElements', appId, [elements, ['display']]));
.callRemoteTestUtil( });
'deepQueryAllElements', appId, [elements, ['display']])
.then(checkQuickViewElementsDisplayBlock);
}).then(this.next);
},
];
} }
/** /**
* Assuming that Quick View is currently open per the openQuickViewSteps above, * Assuming that Quick View is currently open per openQuickView above, closes
* returns an array of steps that closes the Quick View dialog. * the Quick View dialog.
* *
* @param {string} appId Files app windowId. * @param {string} appId Files app windowId.
* @return {!Array<function>}
*/ */
function closeQuickViewSteps(appId) { async function closeQuickView(appId) {
let caller = getCaller(); let caller = getCaller();
function checkQuickViewElementsDisplayNone(elements) { function checkQuickViewElementsDisplayNone(elements) {
...@@ -64,306 +56,192 @@ function closeQuickViewSteps(appId) { ...@@ -64,306 +56,192 @@ function closeQuickViewSteps(appId) {
return; return;
} }
return [ // Click on Quick View to close it.
// Click on Quick View to close it. const panelElements = ['#quick-view', '#contentPanel'];
function() { chrome.test.assertTrue(
const panelElements = ['#quick-view', '#contentPanel']; !!await remoteCall.callRemoteTestUtil(
remoteCall.callRemoteTestUtil('fakeMouseClick', appId, [panelElements]) 'fakeMouseClick', appId, [panelElements]),
.then(this.next); 'fakeMouseClick failed');
},
// Check: the Quick View element should not be shown. // Check: the Quick View element should not be shown.
function(result) { await repeatUntil(async () => {
chrome.test.assertTrue(!!result, 'fakeMouseClick failed'); const elements = ['#quick-view', '#dialog:not([open])'];
repeatUntil(function() { return checkQuickViewElementsDisplayNone(
const elements = ['#quick-view', '#dialog:not([open])']; await remoteCall.callRemoteTestUtil(
return remoteCall 'deepQueryAllElements', appId, [elements, ['display']]));
.callRemoteTestUtil( });
'deepQueryAllElements', appId, [elements, ['display']])
.then(checkQuickViewElementsDisplayNone);
}).then(this.next);
},
];
} }
/** /**
* Tests opening Quick View on a local downloads file. * Tests opening Quick View on a local downloads file.
*/ */
testcase.openQuickView = function() { testcase.openQuickView = async function() {
let appId; // Open Files app on Downloads containing ENTRIES.hello.
const {appId} = await setupAndWaitUntilReady(
StepsRunner.run([ null, RootPath.DOWNLOADS, null, [ENTRIES.hello], []);
// Open Files app on Downloads containing ENTRIES.hello.
function() { // Open the file in Quick View.
setupAndWaitUntilReady( await openQuickView(appId, ENTRIES.hello.nameText);
null, RootPath.DOWNLOADS, this.next, [ENTRIES.hello], []);
},
// Open the file in Quick View.
function(results) {
appId = results.windowId;
const openSteps = openQuickViewSteps(appId, ENTRIES.hello.nameText);
StepsRunner.run(openSteps).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening then closing Quick View on a local downloads file. * Tests opening then closing Quick View on a local downloads file.
*/ */
testcase.closeQuickView = function() { testcase.closeQuickView = async function() {
let appId; // Open Files app on Downloads containing ENTRIES.hello.
const {appId} = await setupAndWaitUntilReady(
StepsRunner.run([ null, RootPath.DOWNLOADS, null, [ENTRIES.hello], []);
// Open Files app on Downloads containing ENTRIES.hello.
function() { // Open the file in Quick View.
setupAndWaitUntilReady( await openQuickView(appId, ENTRIES.hello.nameText);
null, RootPath.DOWNLOADS, this.next, [ENTRIES.hello], []);
}, // Close Quick View.
// Open the file in Quick View. await closeQuickView(appId);
function(results) {
appId = results.windowId;
const openSteps = openQuickViewSteps(appId, ENTRIES.hello.nameText);
StepsRunner.run(openSteps).then(this.next);
},
// Close Quick View.
function() {
StepsRunner.run(closeQuickViewSteps(appId)).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening Quick View on a Drive file. * Tests opening Quick View on a Drive file.
*/ */
testcase.openQuickViewDrive = function() { testcase.openQuickViewDrive = async function() {
let appId; // Open Files app on Drive containing ENTRIES.hello.
const {appId} = await setupAndWaitUntilReady(
StepsRunner.run([ null, RootPath.DRIVE, null, [], [ENTRIES.hello]);
// Open Files app on Drive containing ENTRIES.hello.
function() { // Open the file in Quick View.
setupAndWaitUntilReady( await openQuickView(appId, ENTRIES.hello.nameText);
null, RootPath.DRIVE, this.next, [], [ENTRIES.hello]);
},
// Open the file in Quick View.
function(results) {
appId = results.windowId;
const openSteps = openQuickViewSteps(appId, ENTRIES.hello.nameText);
StepsRunner.run(openSteps).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening Quick View on a USB file. * Tests opening Quick View on a USB file.
*/ */
testcase.openQuickViewUsb = function() { testcase.openQuickViewUsb = async function() {
let appId;
const USB_VOLUME_QUERY = '#directory-tree [volume-type-icon="removable"]'; const USB_VOLUME_QUERY = '#directory-tree [volume-type-icon="removable"]';
StepsRunner.run([ // Open Files app on Downloads containing ENTRIES.photos.
// Open Files app on Downloads containing ENTRIES.photos. const {appId} = await setupAndWaitUntilReady(
function() { null, RootPath.DOWNLOADS, null, [ENTRIES.photos], []);
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.photos], []); // Mount a USB volume.
}, await sendTestMessage({name: 'mountFakeUsb'});
// Mount a USB volume.
function(results) { // Wait for the USB volume to mount.
appId = results.windowId; await remoteCall.waitForElement(appId, USB_VOLUME_QUERY);
sendTestMessage({name: 'mountFakeUsb'}).then(this.next);
}, // Click to open the USB volume.
// Wait for the USB volume to mount. chrome.test.assertTrue(
function() { !!await remoteCall.callRemoteTestUtil(
remoteCall.waitForElement(appId, USB_VOLUME_QUERY).then(this.next); 'fakeMouseClick', appId, [USB_VOLUME_QUERY]),
}, 'fakeMouseClick failed');
// Click to open the USB volume.
function() { // Check: the USB files should appear in the file list.
remoteCall.callRemoteTestUtil( const files = TestEntryInfo.getExpectedRows(BASIC_FAKE_ENTRY_SET);
'fakeMouseClick', appId, [USB_VOLUME_QUERY], this.next); await remoteCall.waitForFiles(appId, files, {ignoreLastModifiedTime: true});
},
// Check: the USB files should appear in the file list. // Open a USB file in Quick View.
function(result) { await openQuickView(appId, ENTRIES.hello.nameText);
chrome.test.assertTrue(!!result, 'fakeMouseClick failed');
const files = TestEntryInfo.getExpectedRows(BASIC_FAKE_ENTRY_SET);
remoteCall.waitForFiles(appId, files, {ignoreLastModifiedTime: true})
.then(this.next);
},
// Open a USB file in Quick View.
function() {
const openSteps = openQuickViewSteps(appId, ENTRIES.hello.nameText);
StepsRunner.run(openSteps).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening Quick View on an MTP file. * Tests opening Quick View on an MTP file.
*/ */
testcase.openQuickViewMtp = function() { testcase.openQuickViewMtp = async function() {
let appId;
const MTP_VOLUME_QUERY = '#directory-tree [volume-type-icon="mtp"]'; const MTP_VOLUME_QUERY = '#directory-tree [volume-type-icon="mtp"]';
StepsRunner.run([ // Open Files app on Downloads containing ENTRIES.photos.
// Open Files app on Downloads containing ENTRIES.photos. const {appId} = await setupAndWaitUntilReady(
function() { null, RootPath.DOWNLOADS, null, [ENTRIES.photos], []);
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.photos], []); // Mount a non-empty MTP volume.
}, await sendTestMessage({name: 'mountFakeMtp'});
// Mount a non-empty MTP volume.
function(results) { // Wait for the MTP volume to mount.
appId = results.windowId; await remoteCall.waitForElement(appId, MTP_VOLUME_QUERY);
sendTestMessage({name: 'mountFakeMtp'}).then(this.next);
}, // Click to open the MTP volume.
// Wait for the MTP volume to mount. chrome.test.assertTrue(
function() { !!await remoteCall.callRemoteTestUtil(
remoteCall.waitForElement(appId, MTP_VOLUME_QUERY).then(this.next); 'fakeMouseClick', appId, [MTP_VOLUME_QUERY]),
}, 'fakeMouseClick failed');
// Click to open the MTP volume.
function() { // Check: the MTP files should appear in the file list.
remoteCall.callRemoteTestUtil( const files = TestEntryInfo.getExpectedRows(BASIC_FAKE_ENTRY_SET);
'fakeMouseClick', appId, [MTP_VOLUME_QUERY], this.next); await remoteCall.waitForFiles(appId, files, {ignoreLastModifiedTime: true});
},
// Check: the MTP files should appear in the file list. // Open an MTP file in Quick View.
function(result) { await openQuickView(appId, ENTRIES.hello.nameText);
chrome.test.assertTrue(!!result, 'fakeMouseClick failed');
const files = TestEntryInfo.getExpectedRows(BASIC_FAKE_ENTRY_SET);
remoteCall.waitForFiles(appId, files, {ignoreLastModifiedTime: true})
.then(this.next);
},
// Open an MTP file in Quick View.
function() {
const openSteps = openQuickViewSteps(appId, ENTRIES.hello.nameText);
StepsRunner.run(openSteps).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening Quick View on a Crostini file. * Tests opening Quick View on a Crostini file.
*/ */
testcase.openQuickViewCrostini = function() { testcase.openQuickViewCrostini = async function() {
let appId;
const fakeLinuxFiles = '#directory-tree [root-type-icon="crostini"]'; const fakeLinuxFiles = '#directory-tree [root-type-icon="crostini"]';
const realLinuxFiles = '#directory-tree [volume-type-icon="crostini"]'; const realLinuxFiles = '#directory-tree [volume-type-icon="crostini"]';
StepsRunner.run([ // Open Files app on Downloads containing ENTRIES.photos.
// Open Files app on Downloads containing ENTRIES.photos. const {appId} = await setupAndWaitUntilReady(
function() { null, RootPath.DOWNLOADS, null, [ENTRIES.photos], []);
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.photos], []); // Check: the fake Linux files icon should be shown.
}, await remoteCall.waitForElement(appId, fakeLinuxFiles);
// Check: the fake Linux files icon should be shown.
function(results) { // Add files to the Crostini volume.
appId = results.windowId; await addEntries(['crostini'], BASIC_CROSTINI_ENTRY_SET);
remoteCall.waitForElement(appId, fakeLinuxFiles).then(this.next);
}, // Click the fake Linux files icon to mount the Crostini volume.
// Add files to the Crostini volume. chrome.test.assertTrue(
function() { !!await remoteCall.callRemoteTestUtil(
addEntries(['crostini'], BASIC_CROSTINI_ENTRY_SET, this.next); 'fakeMouseClick', appId, [fakeLinuxFiles]),
}, 'fakeMouseClick failed');
// Click the fake Linux files icon to mount the Crostini volume.
function() { // Check: the Crostini volume icon should appear.
remoteCall.callRemoteTestUtil( await remoteCall.waitForElement(appId, realLinuxFiles);
'fakeMouseClick', appId, [fakeLinuxFiles], this.next);
}, // Check: the Crostini files should appear in the file list.
// Check: the Crostini volume icon should appear. const files = TestEntryInfo.getExpectedRows(BASIC_CROSTINI_ENTRY_SET);
function(result) { await remoteCall.waitForFiles(appId, files, {ignoreLastModifiedTime: true});
chrome.test.assertTrue(!!result, 'fakeMouseClick failed');
remoteCall.waitForElement(appId, realLinuxFiles).then(this.next); // Open a Crostini file in Quick View.
}, await openQuickView(appId, ENTRIES.hello.nameText);
// Check: the Crostini files should appear in the file list.
function() {
const files = TestEntryInfo.getExpectedRows(BASIC_CROSTINI_ENTRY_SET);
remoteCall.waitForFiles(appId, files, {ignoreLastModifiedTime: true})
.then(this.next);
},
// Open a Crostini file in Quick View.
function() {
const openSteps = openQuickViewSteps(appId, ENTRIES.hello.nameText);
StepsRunner.run(openSteps).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening Quick View on an Android file. * Tests opening Quick View on an Android file.
*/ */
testcase.openQuickViewAndroid = function() { testcase.openQuickViewAndroid = async function() {
let appId; // Open Files app on Android files.
const appId = await openNewWindow(null, RootPath.ANDROID_FILES);
StepsRunner.run([
// Open Files app on Android files. // Add files to the Android files volume.
function() { const entrySet = BASIC_ANDROID_ENTRY_SET.concat([ENTRIES.documentsText]);
openNewWindow(null, RootPath.ANDROID_FILES).then(this.next); await addEntries(['android_files'], entrySet);
},
// Add files to the Android files volume. // Wait for the file list to appear.
function(result) { await remoteCall.waitForElement(appId, '#file-list');
appId = result;
const entrySet = BASIC_ANDROID_ENTRY_SET.concat([ENTRIES.documentsText]); // Check: the basic Android file set should appear in the file list.
addEntries(['android_files'], entrySet, this.next); let files = TestEntryInfo.getExpectedRows(BASIC_ANDROID_ENTRY_SET);
}, await remoteCall.waitForFiles(appId, files, {ignoreLastModifiedTime: true});
// Wait for the file list to appear.
function(result) { // Navigate to the Android files '/Documents' directory.
chrome.test.assertTrue(result); await remoteCall.navigateWithDirectoryTree(
remoteCall.waitForElement(appId, '#file-list').then(this.next); appId, '/Documents', 'My files/Play files', 'android_files');
},
// Check: the basic Android file set should appear in the file list. // Check: the 'android.txt' file should appear in the file list.
function() { files = [ENTRIES.documentsText.getExpectedRow()];
const files = TestEntryInfo.getExpectedRows(BASIC_ANDROID_ENTRY_SET); await remoteCall.waitForFiles(appId, files, {ignoreLastModifiedTime: true});
remoteCall.waitForFiles(appId, files, {ignoreLastModifiedTime: true})
.then(this.next); // Open the Android file in Quick View.
}, const documentsFileName = ENTRIES.documentsText.nameText;
// Navigate to the Android files '/Documents' directory. await openQuickView(appId, documentsFileName);
function() {
remoteCall
.navigateWithDirectoryTree(
appId, '/Documents', 'My files/Play files', 'android_files')
.then(this.next);
},
// Check: the 'android.txt' file should appear in the file list.
function() {
const files = [ENTRIES.documentsText.getExpectedRow()];
remoteCall.waitForFiles(appId, files, {ignoreLastModifiedTime: true})
.then(this.next);
},
// Open the Android file in Quick View.
function() {
const documentsFileName = ENTRIES.documentsText.nameText;
const openSteps = openQuickViewSteps(appId, documentsFileName);
StepsRunner.run(openSteps).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening Quick View and scrolling its <webview> which contains a tall * Tests opening Quick View and scrolling its <webview> which contains a tall
* text document. * text document.
*/ */
testcase.openQuickViewScrollText = function() { testcase.openQuickViewScrollText = async function() {
const caller = getCaller(); const caller = getCaller();
let appId;
/** /**
* The text <webview> resides in the #quick-view shadow DOM, as a child of * The text <webview> resides in the #quick-view shadow DOM, as a child of
...@@ -373,85 +251,61 @@ testcase.openQuickViewScrollText = function() { ...@@ -373,85 +251,61 @@ testcase.openQuickViewScrollText = function() {
function scrollQuickViewTextBy(y) { function scrollQuickViewTextBy(y) {
const doScrollBy = `window.scrollBy(0,${y})`; const doScrollBy = `window.scrollBy(0,${y})`;
return remoteCall return remoteCall.callRemoteTestUtil(
.callRemoteTestUtil( 'deepExecuteScriptInWebView', appId, [webView, doScrollBy]);
'deepExecuteScriptInWebView', appId, [webView, doScrollBy]);
} }
function checkQuickViewTextScrollY(scrollY) { async function checkQuickViewTextScrollY(scrollY) {
if (!scrollY || Number(scrollY.toString()) <= 200) { if (!scrollY || Number(scrollY.toString()) <= 200) {
console.log('checkQuickViewTextScrollY: scrollY '.concat(scrollY)); console.log('checkQuickViewTextScrollY: scrollY '.concat(scrollY));
return scrollQuickViewTextBy(100).then(() => { await scrollQuickViewTextBy(100);
return pending(caller, 'Waiting for Quick View to scroll.'); return pending(caller, 'Waiting for Quick View to scroll.');
});
} }
} }
StepsRunner.run([ // Open Files app on Downloads containing ENTRIES.tallText.
// Open Files app on Downloads containing ENTRIES.tallText. const {appId} = await setupAndWaitUntilReady(
function() { null, RootPath.DOWNLOADS, null, [ENTRIES.tallText], []);
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.tallText], []); // Open the file in Quick View.
}, await openQuickView(appId, ENTRIES.tallText.nameText);
// Open the file in Quick View.
function(results) { // Wait for the Quick View <webview> to load and display its content.
appId = results.windowId; function checkWebViewTextLoaded(elements) {
const openSteps = openQuickViewSteps(appId, ENTRIES.tallText.nameText); let haveElements = Array.isArray(elements) && elements.length === 1;
StepsRunner.run(openSteps).then(this.next); if (haveElements)
}, haveElements = elements[0].styles.display.includes('block');
// Wait for the Quick View <webview> to load and display its content. if (!haveElements || !elements[0].attributes.src)
function() { return pending(caller, 'Waiting for <webview> to load.');
function checkWebViewTextLoaded(elements) { return;
let haveElements = Array.isArray(elements) && elements.length === 1; }
if (haveElements) await repeatUntil(async () => {
haveElements = elements[0].styles.display.includes('block'); return checkWebViewTextLoaded(await remoteCall.callRemoteTestUtil(
if (!haveElements || !elements[0].attributes.src) 'deepQueryAllElements', appId, [webView, ['display']]));
return pending(caller, 'Waiting for <webview> to load.'); });
return;
} // Get the Quick View <webview> scrollY.
repeatUntil(function() { const getScrollY = 'window.scrollY';
return remoteCall await remoteCall.callRemoteTestUtil(
.callRemoteTestUtil( 'deepExecuteScriptInWebView', appId, [webView, getScrollY]);
'deepQueryAllElements', appId, [webView, ['display']])
.then(checkWebViewTextLoaded); // Check: the initial <webview> scrollY should be 0.
}).then(this.next); chrome.test.assertEq('0', scrollY.toString());
},
// Get the Quick View <webview> scrollY. // Scroll the <webview> and verify that it scrolled.
function() { await repeatUntil(async () => {
const getScrollY = 'window.scrollY'; const getScrollY = 'window.scrollY';
remoteCall return checkQuickViewTextScrollY(await remoteCall.callRemoteTestUtil(
.callRemoteTestUtil( 'deepExecuteScriptInWebView', appId, [webView, getScrollY]));
'deepExecuteScriptInWebView', appId, [webView, getScrollY]) });
.then(this.next);
},
// Check: the initial <webview> scrollY should be 0.
function(scrollY) {
chrome.test.assertEq('0', scrollY.toString());
this.next();
},
// Scroll the <webview> and verify that it scrolled.
function() {
repeatUntil(function() {
const getScrollY = 'window.scrollY';
return remoteCall
.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [webView, getScrollY])
.then(checkQuickViewTextScrollY);
}).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening Quick View on a text document to verify that the background * Tests opening Quick View on a text document to verify that the background
* color of the <webview> root (html) element is solid white. * color of the <webview> root (html) element is solid white.
*/ */
testcase.openQuickViewBackgroundColorText = function() { testcase.openQuickViewBackgroundColorText = async function() {
const caller = getCaller(); const caller = getCaller();
let appId;
/** /**
* The text <webview> resides in the #quick-view shadow DOM, as a child of * The text <webview> resides in the #quick-view shadow DOM, as a child of
...@@ -459,61 +313,42 @@ testcase.openQuickViewBackgroundColorText = function() { ...@@ -459,61 +313,42 @@ testcase.openQuickViewBackgroundColorText = function() {
*/ */
const webView = ['#quick-view', '#dialog[open] webview.text-content']; const webView = ['#quick-view', '#dialog[open] webview.text-content'];
StepsRunner.run([ // Open Files app on Downloads containing ENTRIES.tallText.
// Open Files app on Downloads containing ENTRIES.tallText. const {appId} = await setupAndWaitUntilReady(
function() { null, RootPath.DOWNLOADS, null, [ENTRIES.tallText], []);
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.tallText], []); // Open the file in Quick View.
}, await openQuickView(appId, ENTRIES.tallText.nameText);
// Open the file in Quick View.
function(results) { // Wait for the Quick View <webview> to load and display its content.
appId = results.windowId; function checkWebViewTextLoaded(elements) {
const openSteps = openQuickViewSteps(appId, ENTRIES.tallText.nameText); let haveElements = Array.isArray(elements) && elements.length === 1;
StepsRunner.run(openSteps).then(this.next); if (haveElements)
}, haveElements = elements[0].styles.display.includes('block');
// Wait for the Quick View <webview> to load and display its content. if (!haveElements || !elements[0].attributes.src)
function() { return pending(caller, 'Waiting for <webview> to load.');
function checkWebViewTextLoaded(elements) { return;
let haveElements = Array.isArray(elements) && elements.length === 1; }
if (haveElements) await repeatUntil(async () => {
haveElements = elements[0].styles.display.includes('block'); return checkWebViewTextLoaded(await remoteCall.callRemoteTestUtil(
if (!haveElements || !elements[0].attributes.src) 'deepQueryAllElements', appId, [webView, ['display']]));
return pending(caller, 'Waiting for <webview> to load.'); });
return;
} // Get the <webview> root (html) element backgroundColor style.
repeatUntil(function() { const getBackgroundStyle =
return remoteCall 'window.getComputedStyle(document.documentElement).backgroundColor';
.callRemoteTestUtil( const backgroundColor = await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, [webView, ['display']]) 'deepExecuteScriptInWebView', appId, [webView, getBackgroundStyle]);
.then(checkWebViewTextLoaded);
}).then(this.next); // Check: the <webview> root backgroundColor should be solid white.
}, chrome.test.assertEq('rgb(255, 255, 255)', backgroundColor[0]);
// Get the <webview> root (html) element backgroundColor style.
function() {
const getBackgroundStyle =
'window.getComputedStyle(document.documentElement).backgroundColor';
remoteCall
.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [webView, getBackgroundStyle])
.then(this.next);
},
// Check: the <webview> root backgroundColor should be solid white.
function(backgroundColor) {
chrome.test.assertEq('rgb(255, 255, 255)', backgroundColor[0]);
this.next();
},
function(results) {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening Quick View containing a PDF document. * Tests opening Quick View containing a PDF document.
*/ */
testcase.openQuickViewPdf = function() { testcase.openQuickViewPdf = async function() {
const caller = getCaller(); const caller = getCaller();
let appId;
/** /**
* The PDF <webview> resides in the #quick-view shadow DOM, as a child of * The PDF <webview> resides in the #quick-view shadow DOM, as a child of
...@@ -521,69 +356,50 @@ testcase.openQuickViewPdf = function() { ...@@ -521,69 +356,50 @@ testcase.openQuickViewPdf = function() {
*/ */
const webView = ['#quick-view', '#dialog[open] webview.content']; const webView = ['#quick-view', '#dialog[open] webview.content'];
StepsRunner.run([ // Open Files app on Downloads containing ENTRIES.tallPdf.
// Open Files app on Downloads containing ENTRIES.tallPdf. const {appId} = await setupAndWaitUntilReady(
function() { null, RootPath.DOWNLOADS, null, [ENTRIES.tallPdf], []);
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.tallPdf], []); // Open the file in Quick View.
}, await openQuickView(appId, ENTRIES.tallPdf.nameText);
// Open the file in Quick View.
function(results) { // Wait for the Quick View <webview> to load and display its content.
appId = results.windowId; function checkWebViewPdfLoaded(elements) {
const openSteps = openQuickViewSteps(appId, ENTRIES.tallPdf.nameText); let haveElements = Array.isArray(elements) && elements.length === 1;
StepsRunner.run(openSteps).then(this.next); if (haveElements)
}, haveElements = elements[0].styles.display.includes('block');
// Wait for the Quick View <webview> to load and display its content. if (!haveElements || !elements[0].attributes.src)
function() { return pending(caller, 'Waiting for <webview> to load.');
function checkWebViewPdfLoaded(elements) { return;
let haveElements = Array.isArray(elements) && elements.length === 1; }
if (haveElements) await repeatUntil(async () => {
haveElements = elements[0].styles.display.includes('block'); return checkWebViewPdfLoaded(await remoteCall.callRemoteTestUtil(
if (!haveElements || !elements[0].attributes.src) 'deepQueryAllElements', appId, [webView, ['display']]));
return pending(caller, 'Waiting for <webview> to load.'); });
return;
} // Get the <webview> embed type attribute.
repeatUntil(function() { function checkPdfEmbedType(type) {
return remoteCall let haveElements = Array.isArray(type) && type.length === 1;
.callRemoteTestUtil( if (!haveElements || !type[0].toString().includes('pdf'))
'deepQueryAllElements', appId, [webView, ['display']]) return pending(caller, 'Waiting for plugin <embed> type.');
.then(checkWebViewPdfLoaded); return type[0];
}).then(this.next); }
}, const type = await repeatUntil(async () => {
// Get the <webview> embed type attribute. const getType = 'window.document.querySelector("embed").type';
function() { return checkPdfEmbedType(await remoteCall.callRemoteTestUtil(
function checkPdfEmbedType(type) { 'deepExecuteScriptInWebView', appId, [webView, getType]));
let haveElements = Array.isArray(type) && type.length === 1; });
if (!haveElements || !type[0].toString().includes('pdf'))
return pending(caller, 'Waiting for plugin <embed> type.'); // Check: the <webview> embed type should be PDF mime type.
return type[0]; chrome.test.assertEq('application/pdf', type);
}
repeatUntil(function() {
const getType = 'window.document.querySelector("embed").type';
return remoteCall
.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [webView, getType])
.then(checkPdfEmbedType);
}).then(this.next);
},
// Check: the <webview> embed type should be PDF mime type.
function(type) {
chrome.test.assertEq('application/pdf', type);
this.next();
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening Quick View and scrolling its <webview> which contains a tall * Tests opening Quick View and scrolling its <webview> which contains a tall
* html document. * html document.
*/ */
testcase.openQuickViewScrollHtml = function() { testcase.openQuickViewScrollHtml = async function() {
const caller = getCaller(); const caller = getCaller();
let appId;
/** /**
* The <webview> resides in the <files-safe-media type="html"> shadow DOM, * The <webview> resides in the <files-safe-media type="html"> shadow DOM,
...@@ -593,76 +409,53 @@ testcase.openQuickViewScrollHtml = function() { ...@@ -593,76 +409,53 @@ testcase.openQuickViewScrollHtml = function() {
function scrollQuickViewHtmlBy(y) { function scrollQuickViewHtmlBy(y) {
const doScrollBy = `window.scrollBy(0,${y})`; const doScrollBy = `window.scrollBy(0,${y})`;
return remoteCall return remoteCall.callRemoteTestUtil(
.callRemoteTestUtil( 'deepExecuteScriptInWebView', appId, [webView, doScrollBy]);
'deepExecuteScriptInWebView', appId, [webView, doScrollBy]);
} }
function checkQuickViewHtmlScrollY(scrollY) { async function checkQuickViewHtmlScrollY(scrollY) {
if (!scrollY || Number(scrollY.toString()) <= 200) { if (!scrollY || Number(scrollY.toString()) <= 200) {
console.log('checkQuickViewHtmlScrollY: scrollY '.concat(scrollY)); console.log('checkQuickViewHtmlScrollY: scrollY '.concat(scrollY));
return scrollQuickViewHtmlBy(100).then(() => { await scrollQuickViewHtmlBy(100);
return pending(caller, 'Waiting for Quick View to scroll.'); return pending(caller, 'Waiting for Quick View to scroll.');
});
} }
} }
StepsRunner.run([ // Open Files app on Downloads containing ENTRIES.tallHtml.
// Open Files app on Downloads containing ENTRIES.tallHtml. const {appId} = await setupAndWaitUntilReady(
function() { null, RootPath.DOWNLOADS, null, [ENTRIES.tallHtml], []);
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.tallHtml], []); // Open the file in Quick View.
}, await openQuickView(appId, ENTRIES.tallHtml.nameText);
// Open the file in Quick View.
function(results) { // Wait for the Quick View <webview> to load and display its content.
appId = results.windowId; function checkWebViewHtmlLoaded(elements) {
const openSteps = openQuickViewSteps(appId, ENTRIES.tallHtml.nameText); let haveElements = Array.isArray(elements) && elements.length === 1;
StepsRunner.run(openSteps).then(this.next); if (haveElements)
}, haveElements = elements[0].styles.display.includes('block');
// Wait for the Quick View <webview> to load and display its content. if (!haveElements || elements[0].attributes.loaded !== '')
function() { return pending(caller, 'Waiting for <webview> to load.');
function checkWebViewHtmlLoaded(elements) { return;
let haveElements = Array.isArray(elements) && elements.length === 1; }
if (haveElements) await repeatUntil(async () => {
haveElements = elements[0].styles.display.includes('block'); return checkWebViewHtmlLoaded(await remoteCall.callRemoteTestUtil(
if (!haveElements || elements[0].attributes.loaded !== '') 'deepQueryAllElements', appId, [webView, ['display']]));
return pending(caller, 'Waiting for <webview> to load.'); });
return;
} // Get the Quick View <webview> scrollY.
repeatUntil(function() { const getScrollY = 'window.scrollY';
return remoteCall await remoteCall.callRemoteTestUtil(
.callRemoteTestUtil( 'deepExecuteScriptInWebView', appId, [webView, getScrollY]);
'deepQueryAllElements', appId, [webView, ['display']])
.then(checkWebViewHtmlLoaded); // Check: the initial <webview> scrollY should be 0.
}).then(this.next); chrome.test.assertEq('0', scrollY.toString());
},
// Get the Quick View <webview> scrollY. // Scroll the <webview> and verify that it scrolled.
function() { await repeatUntil(async () => {
const getScrollY = 'window.scrollY'; const getScrollY = 'window.scrollY';
remoteCall return checkQuickViewHtmlScrollY(await remoteCall.callRemoteTestUtil(
.callRemoteTestUtil( 'deepExecuteScriptInWebView', appId, [webView, getScrollY]));
'deepExecuteScriptInWebView', appId, [webView, getScrollY]) });
.then(this.next);
},
// Check: the initial <webview> scrollY should be 0.
function(scrollY) {
chrome.test.assertEq('0', scrollY.toString());
this.next();
},
// Scroll the <webview> and verify that it scrolled.
function() {
repeatUntil(function() {
const getScrollY = 'window.scrollY';
return remoteCall
.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [webView, getScrollY])
.then(checkQuickViewHtmlScrollY);
}).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
...@@ -670,9 +463,8 @@ testcase.openQuickViewScrollHtml = function() { ...@@ -670,9 +463,8 @@ testcase.openQuickViewScrollHtml = function() {
* color of the <files-safe-media type="html"> that contains the <webview> is * color of the <files-safe-media type="html"> that contains the <webview> is
* solid white. * solid white.
*/ */
testcase.openQuickViewBackgroundColorHtml = function() { testcase.openQuickViewBackgroundColorHtml = async function() {
const caller = getCaller(); const caller = getCaller();
let appId;
/** /**
* The <webview> resides in the <files-safe-media type="html"> shadow DOM, * The <webview> resides in the <files-safe-media type="html"> shadow DOM,
...@@ -681,53 +473,37 @@ testcase.openQuickViewBackgroundColorHtml = function() { ...@@ -681,53 +473,37 @@ testcase.openQuickViewBackgroundColorHtml = function() {
*/ */
const fileSafeMedia = ['#quick-view', 'files-safe-media[type="html"]']; const fileSafeMedia = ['#quick-view', 'files-safe-media[type="html"]'];
StepsRunner.run([ // Open Files app on Downloads containing ENTRIES.tallHtml.
// Open Files app on Downloads containing ENTRIES.tallHtml. const {appId} = await setupAndWaitUntilReady(
function() { null, RootPath.DOWNLOADS, null, [ENTRIES.tallHtml], []);
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.tallHtml], []); // Open the file in Quick View.
}, await openQuickView(appId, ENTRIES.tallHtml.nameText);
// Open the file in Quick View.
function(results) { // Get the <files-safe-media type='html'> backgroundColor style.
appId = results.windowId; function getFileSafeMediaBackgroundColor(elements) {
const openSteps = openQuickViewSteps(appId, ENTRIES.tallHtml.nameText); let haveElements = Array.isArray(elements) && elements.length === 1;
StepsRunner.run(openSteps).then(this.next); if (haveElements)
}, haveElements = elements[0].styles.display.includes('block');
// Get the <files-safe-media type='html'> backgroundColor style. if (!haveElements || !elements[0].styles.backgroundColor)
function() { return pending(caller, 'Waiting for <file-safe-media> element.');
function getFileSafeMediaBackgroundColor(elements) { return elements[0].styles.backgroundColor;
let haveElements = Array.isArray(elements) && elements.length === 1; }
if (haveElements) const backgroundColor = await repeatUntil(async () => {
haveElements = elements[0].styles.display.includes('block'); const styles = ['display', 'backgroundColor'];
if (!haveElements || !elements[0].styles.backgroundColor) return getFileSafeMediaBackgroundColor(await remoteCall.callRemoteTestUtil(
return pending(caller, 'Waiting for <file-safe-media> element.'); 'deepQueryAllElements', appId, [fileSafeMedia, styles]));
return elements[0].styles.backgroundColor; });
}
repeatUntil(function() { // Check: the <files-safe-media> backgroundColor should be solid white.
const styles = ['display', 'backgroundColor']; chrome.test.assertEq('rgb(255, 255, 255)', backgroundColor);
return remoteCall
.callRemoteTestUtil(
'deepQueryAllElements', appId, [fileSafeMedia, styles])
.then(getFileSafeMediaBackgroundColor);
}).then(this.next);
},
// Check: the <files-safe-media> backgroundColor should be solid white.
function(backgroundColor) {
chrome.test.assertEq('rgb(255, 255, 255)', backgroundColor);
this.next();
},
function(results) {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening Quick View containing an audio file. * Tests opening Quick View containing an audio file.
*/ */
testcase.openQuickViewAudio = function() { testcase.openQuickViewAudio = async function() {
const caller = getCaller(); const caller = getCaller();
let appId;
/** /**
* The <webview> resides in the <files-safe-media type="audio"> shadow DOM, * The <webview> resides in the <files-safe-media type="audio"> shadow DOM,
...@@ -735,61 +511,42 @@ testcase.openQuickViewAudio = function() { ...@@ -735,61 +511,42 @@ testcase.openQuickViewAudio = function() {
*/ */
const webView = ['#quick-view', 'files-safe-media[type="audio"]', 'webview']; const webView = ['#quick-view', 'files-safe-media[type="audio"]', 'webview'];
StepsRunner.run([ // Open Files app on Downloads containing ENTRIES.beautiful song.
// Open Files app on Downloads containing ENTRIES.beautiful song. const {appId} = await setupAndWaitUntilReady(
function() { null, RootPath.DOWNLOADS, null, [ENTRIES.beautiful], []);
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.beautiful], []); // Open the file in Quick View.
}, await openQuickView(appId, ENTRIES.beautiful.nameText);
// Open the file in Quick View.
function(results) { // Wait for the Quick View <webview> to load and display its content.
appId = results.windowId; function checkWebViewAudioLoaded(elements) {
const openSteps = openQuickViewSteps(appId, ENTRIES.beautiful.nameText); let haveElements = Array.isArray(elements) && elements.length === 1;
StepsRunner.run(openSteps).then(this.next); if (haveElements)
}, haveElements = elements[0].styles.display.includes('block');
// Wait for the Quick View <webview> to load and display its content. if (!haveElements || elements[0].attributes.loaded !== '')
function() { return pending(caller, 'Waiting for <webview> to load.');
function checkWebViewAudioLoaded(elements) { return;
let haveElements = Array.isArray(elements) && elements.length === 1; }
if (haveElements) await repeatUntil(async () => {
haveElements = elements[0].styles.display.includes('block'); return checkWebViewAudioLoaded(await remoteCall.callRemoteTestUtil(
if (!haveElements || elements[0].attributes.loaded !== '') 'deepQueryAllElements', appId, [webView, ['display']]));
return pending(caller, 'Waiting for <webview> to load.'); });
return;
} // Get the <webview> document.body backgroundColor style.
repeatUntil(function() { const getBackgroundStyle =
return remoteCall 'window.getComputedStyle(document.body).backgroundColor';
.callRemoteTestUtil( const backgroundColor = await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, [webView, ['display']]) 'deepExecuteScriptInWebView', appId, [webView, getBackgroundStyle]);
.then(checkWebViewAudioLoaded);
}).then(this.next); // Check: the <webview> body backgroundColor should be transparent black.
}, chrome.test.assertEq('rgba(0, 0, 0, 0)', backgroundColor[0]);
// Get the <webview> document.body backgroundColor style.
function() {
const getBackgroundStyle =
'window.getComputedStyle(document.body).backgroundColor';
remoteCall
.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [webView, getBackgroundStyle])
.then(this.next);
},
// Check: the <webview> body backgroundColor should be transparent black.
function(backgroundColor) {
chrome.test.assertEq('rgba(0, 0, 0, 0)', backgroundColor[0]);
this.next();
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening Quick View containing an image. * Tests opening Quick View containing an image.
*/ */
testcase.openQuickViewImage = function() { testcase.openQuickViewImage = async function() {
const caller = getCaller(); const caller = getCaller();
let appId;
/** /**
* The <webview> resides in the <files-safe-media type="image"> shadow DOM, * The <webview> resides in the <files-safe-media type="image"> shadow DOM,
...@@ -797,61 +554,42 @@ testcase.openQuickViewImage = function() { ...@@ -797,61 +554,42 @@ testcase.openQuickViewImage = function() {
*/ */
const webView = ['#quick-view', 'files-safe-media[type="image"]', 'webview']; const webView = ['#quick-view', 'files-safe-media[type="image"]', 'webview'];
StepsRunner.run([ // Open Files app on Downloads containing ENTRIES.smallJpeg.
// Open Files app on Downloads containing ENTRIES.smallJpeg. const {appId} = await setupAndWaitUntilReady(
function() { null, RootPath.DOWNLOADS, null, [ENTRIES.smallJpeg], []);
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.smallJpeg], []); // Open the file in Quick View.
}, await openQuickView(appId, ENTRIES.smallJpeg.nameText);
// Open the file in Quick View.
function(results) { // Wait for the Quick View <webview> to load and display its content.
appId = results.windowId; function checkWebViewImageLoaded(elements) {
const openSteps = openQuickViewSteps(appId, ENTRIES.smallJpeg.nameText); let haveElements = Array.isArray(elements) && elements.length === 1;
StepsRunner.run(openSteps).then(this.next); if (haveElements)
}, haveElements = elements[0].styles.display.includes('block');
// Wait for the Quick View <webview> to load and display its content. if (!haveElements || elements[0].attributes.loaded !== '')
function() { return pending(caller, 'Waiting for <webview> to load.');
function checkWebViewImageLoaded(elements) { return;
let haveElements = Array.isArray(elements) && elements.length === 1; }
if (haveElements) await repeatUntil(async () => {
haveElements = elements[0].styles.display.includes('block'); return checkWebViewImageLoaded(await remoteCall.callRemoteTestUtil(
if (!haveElements || elements[0].attributes.loaded !== '') 'deepQueryAllElements', appId, [webView, ['display']]));
return pending(caller, 'Waiting for <webview> to load.'); });
return;
} // Get the <webview> document.body backgroundColor style.
repeatUntil(function() { const getBackgroundStyle =
return remoteCall 'window.getComputedStyle(document.body).backgroundColor';
.callRemoteTestUtil( const backgroundColor = await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, [webView, ['display']]) 'deepExecuteScriptInWebView', appId, [webView, getBackgroundStyle]);
.then(checkWebViewImageLoaded);
}).then(this.next); // Check: the <webview> body backgroundColor should be transparent black.
}, chrome.test.assertEq('rgba(0, 0, 0, 0)', backgroundColor[0]);
// Get the <webview> document.body backgroundColor style.
function() {
const getBackgroundStyle =
'window.getComputedStyle(document.body).backgroundColor';
remoteCall
.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [webView, getBackgroundStyle])
.then(this.next);
},
// Check: the <webview> body backgroundColor should be transparent black.
function(backgroundColor) {
chrome.test.assertEq('rgba(0, 0, 0, 0)', backgroundColor[0]);
this.next();
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests opening Quick View containing a video. * Tests opening Quick View containing a video.
*/ */
testcase.openQuickViewVideo = function() { testcase.openQuickViewVideo = async function() {
const caller = getCaller(); const caller = getCaller();
let appId;
/** /**
* The <webview> resides in the <files-safe-media type="video"> shadow DOM, * The <webview> resides in the <files-safe-media type="video"> shadow DOM,
...@@ -859,153 +597,99 @@ testcase.openQuickViewVideo = function() { ...@@ -859,153 +597,99 @@ testcase.openQuickViewVideo = function() {
*/ */
const webView = ['#quick-view', 'files-safe-media[type="video"]', 'webview']; const webView = ['#quick-view', 'files-safe-media[type="video"]', 'webview'];
StepsRunner.run([ // Open Files app on Downloads containing ENTRIES.world video.
// Open Files app on Downloads containing ENTRIES.world video. const {appId} = await setupAndWaitUntilReady(
function() { null, RootPath.DOWNLOADS, null, [ENTRIES.world], []);
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.world], []); // Open the file in Quick View.
}, await openQuickView(appId, ENTRIES.world.nameText);
// Open the file in Quick View.
function(results) { // Wait for the Quick View <webview> to load and display its content.
appId = results.windowId; function checkWebViewVideoLoaded(elements) {
const openSteps = openQuickViewSteps(appId, ENTRIES.world.nameText); let haveElements = Array.isArray(elements) && elements.length === 1;
StepsRunner.run(openSteps).then(this.next); if (haveElements)
}, haveElements = elements[0].styles.display.includes('block');
// Wait for the Quick View <webview> to load and display its content. if (!haveElements || elements[0].attributes.loaded !== '')
function() { return pending(caller, 'Waiting for <webview> to load.');
function checkWebViewVideoLoaded(elements) { return;
let haveElements = Array.isArray(elements) && elements.length === 1; }
if (haveElements) await repeatUntil(async () => {
haveElements = elements[0].styles.display.includes('block'); return checkWebViewVideoLoaded(await remoteCall.callRemoteTestUtil(
if (!haveElements || elements[0].attributes.loaded !== '') 'deepQueryAllElements', appId, [webView, ['display']]));
return pending(caller, 'Waiting for <webview> to load.'); });
return;
} // Get the <webview> document.body backgroundColor style.
repeatUntil(function() { const getBackgroundStyle =
return remoteCall 'window.getComputedStyle(document.body).backgroundColor';
.callRemoteTestUtil( const backgroundColor = await remoteCall.callRemoteTestUtil(
'deepQueryAllElements', appId, [webView, ['display']]) 'deepExecuteScriptInWebView', appId, [webView, getBackgroundStyle]);
.then(checkWebViewVideoLoaded);
}).then(this.next); // Check: the <webview> body backgroundColor should be transparent black.
}, chrome.test.assertEq('rgba(0, 0, 0, 0)', backgroundColor[0]);
// Get the <webview> document.body backgroundColor style.
function() {
const getBackgroundStyle =
'window.getComputedStyle(document.body).backgroundColor';
remoteCall
.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [webView, getBackgroundStyle])
.then(this.next);
},
// Check: the <webview> body backgroundColor should be transparent black.
function(backgroundColor) {
chrome.test.assertEq('rgba(0, 0, 0, 0)', backgroundColor[0]);
this.next();
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests close/open metadata info via Enter key. * Tests close/open metadata info via Enter key.
*/ */
testcase.pressEnterOnInfoBoxToOpenClose = function() { testcase.pressEnterOnInfoBoxToOpenClose = async function() {
const infoButton = ['#quick-view', '#metadata-button']; const infoButton = ['#quick-view', '#metadata-button'];
const key = [infoButton, 'Enter', false, false, false]; const key = [infoButton, 'Enter', false, false, false];
const infoShown = ['#quick-view', '#contentPanel[metadata-box-active]']; const infoShown = ['#quick-view', '#contentPanel[metadata-box-active]'];
const infoHidden = const infoHidden =
['#quick-view', '#contentPanel:not([metadata-box-active])']; ['#quick-view', '#contentPanel:not([metadata-box-active])'];
let appId;
// Open Files app on Downloads containing ENTRIES.hello.
StepsRunner.run([ const {appId} = await setupAndWaitUntilReady(
// Open Files app on Downloads containing ENTRIES.hello. null, RootPath.DOWNLOADS, null, [ENTRIES.hello], []);
function() {
setupAndWaitUntilReady( // Open the file in Quick View.
null, RootPath.DOWNLOADS, this.next, [ENTRIES.hello], []); await openQuickView(appId, ENTRIES.hello.nameText);
},
// Open the file in Quick View. // Press Enter on info button to close metadata box.
function(results) { await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key);
appId = results.windowId;
const openSteps = openQuickViewSteps(appId, ENTRIES.hello.nameText); // Info should be hidden.
StepsRunner.run(openSteps).then(this.next); await remoteCall.waitForElement(appId, infoHidden);
},
// Press Enter on info button to close metadata box. // Press Enter on info button to open metadata box.
function() { await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key);
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next);
}, // Info should be shown.
// Info should be hidden. await remoteCall.waitForElement(appId, infoShown);
function() {
remoteCall.waitForElement(appId, infoHidden).then(this.next); // Close Quick View.
}, await closeQuickView(appId);
// Press Enter on info button to open metadata box.
function() {
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next);
},
// Info should be shown.
function() {
remoteCall.waitForElement(appId, infoShown).then(this.next);
},
// Close Quick View.
function() {
StepsRunner.run(closeQuickViewSteps(appId)).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
},
]);
}; };
/** /**
* Tests that Quick View doesn't open with multiple files selected. * Tests that Quick View doesn't open with multiple files selected.
*/ */
testcase.cantOpenQuickViewWithMultipleFiles = function() { testcase.cantOpenQuickViewWithMultipleFiles = async function() {
let appId; // Open Files app on Downloads containing ENTRIES.hello and ENTRIES.world.
const {appId} = await setupAndWaitUntilReady(
StepsRunner.run([ null, RootPath.DOWNLOADS, null, [ENTRIES.hello, ENTRIES.world], []);
// Open Files app on Downloads containing ENTRIES.hello and ENTRIES.world.
function() { // Select all 2 files.
setupAndWaitUntilReady( const ctrlA = ['#file-list', 'a', true, false, false];
null, RootPath.DOWNLOADS, this.next, [ENTRIES.hello, ENTRIES.world], await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, ctrlA);
[]);
}, // Wait for the files to be selected.
// Select all 2 files. await remoteCall.waitForElement(
function(results) { appId, '#cancel-selection-button-wrapper:not([hidden]):not([disabled])');
appId = results.windowId;
// Attempt to open Quick View via its keyboard shortcut.
const ctrlA = ['#file-list', 'a', true, false, false]; const space = ['#file-list', ' ', false, false, false];
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, ctrlA, this.next); await remoteCall.callRemoteTestUtil('fakeKeyDown', appId, space);
},
// Wait for the files to be selected. // Wait for it to possibly open.
function() { await new Promise((resolve) => {
remoteCall window.setTimeout(resolve, 500);
.waitForElement( });
appId,
'#cancel-selection-button-wrapper:not([hidden]):not([disabled])') // Check Quick View hasn't opened.
.then(this.next); chrome.test.assertEq(
}, [],
// Attempt to open Quick View via its keyboard shortcut. await remoteCall.callRemoteTestUtil(
function() { 'deepQueryAllElements', appId, [['#quick-view', '#dialog[open]']]));
const space = ['#file-list', ' ', false, false, false];
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, space, this.next);
},
// Wait for it to possibly open.
function() {
window.setTimeout(this.next, 500);
},
// Check Quick View hasn't opened.
function() {
return remoteCall
.callRemoteTestUtil(
'deepQueryAllElements', appId, [['#quick-view', '#dialog[open]']])
.then(this.next);
},
function(result) {
chrome.test.assertEq([], result);
checkIfNoErrorsOccured(this.next);
},
]);
}; };
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