Commit 438e9f06 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Speed-up QuickView openQuickView browser test

The test tests that Quick View opens by the usual method: user presses
the space key on a selected file.

Change the test to use a text file, rather than a PNG image, to remove
image decode and rescale costs from the test-time.

Also put all tests steps in a StepRunner group, so that all test steps
can be debugged using the step runner browser test flag. Document each
of the steps.

Bug: 851888
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ief21de93e9496f463506d2ae22ab28db76c087ef
Reviewed-on: https://chromium-review.googlesource.com/1097041Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566699}
parent 8ce6089c
......@@ -4,43 +4,38 @@
'use strict';
function openQuickViewSteps(appId, filename) {
var caller = getCaller();
function openQuickViewSteps(appId, name) {
let caller = getCaller();
function checkQuickViewElementsDisplayBlock(elements) {
const haveElements = Array.isArray(elements) && elements.length !== 0;
if (!haveElements || elements[0].styles.display !== 'block')
return pending(caller, 'Waiting for Quick View to open.');
return;
}
return [
function(results) {
remoteCall.callRemoteTestUtil('selectFile', appId, [filename], this.next);
// Select file |name| in the file list.
function() {
remoteCall.callRemoteTestUtil('selectFile', appId, [name], this.next);
},
function(results) {
chrome.test.assertTrue(results);
// Press Space key.
remoteCall.callRemoteTestUtil(
'fakeKeyDown', appId,
['#file-list', ' ', ' ', false, false, false], 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);
},
function(results) {
chrome.test.assertTrue(results);
// Wait until Quick View is displayed.
// Check: the Quick View element should be shown.
function(result) {
chrome.test.assertTrue(!!result, 'fakeKeyDown failed');
repeatUntil(function() {
const elements = ['#quick-view', '#dialog'];
return remoteCall
.callRemoteTestUtil(
'deepQueryAllElements', appId,
[['#quick-view', '#dialog'], null, ['display']])
.then(function(results) {
if (results.length === 0 ||
results[0].styles.display === 'none') {
return pending(caller, 'Quick View is not opened yet.');
}
return results;
});
'deepQueryAllElements', appId, [elements, null, ['display']])
.then(checkQuickViewElementsDisplayBlock);
}).then(this.next);
},
function(results) {
chrome.test.assertEq(1, results.length);
// Check Quick View dialog is displayed.
chrome.test.assertEq('block', results[0].styles.display);
checkIfNoErrorsOccured(this.next);
},
];
}
......@@ -71,13 +66,26 @@ function closeQuickViewSteps(appId) {
}
/**
* Tests opening Quick View.
* Tests opening Quick View on a local downloads file.
*/
testcase.openQuickView = function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS).then(function(results) {
StepsRunner.run(
openQuickViewSteps(results.windowId, 'My Desktop Background.png'));
});
let appId;
StepsRunner.run([
// Open Files app on local downloads.
function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
},
// Open a 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);
},
]);
};
/**
......
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