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