1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 * Launches the Gallery app with the test entries.
10 * @param {string} testVolumeName Test volume name passed to the addEntries
11 * function. Either 'drive' or 'local'.
12 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
13 * @param {Array.<TestEntryInfo>} entries Entries to be parepared and passed to
15 * @param {Array.<TestEntryInfo>=} opt_selected Entries to be selected. Should
16 * be a sub-set of the entries argument.
18 function launchWithTestEntries(
19 testVolumeName, volumeType, entries, opt_selected) {
20 var entriesPromise = addEntries([testVolumeName], entries).then(function() {
21 var selectedEntries = opt_selected || entries;
22 return getFilesUnderVolume(
24 selectedEntries.map(function(entry) { return entry.nameText; }));
27 return launch(entriesPromise).then(function() {
28 var launchedPromise = Promise.all([appWindowPromise, entriesPromise]);
29 return launchedPromise.then(function(results) {
30 return {appWindow: results[0], entries: results[1]};
36 * Waits until the expected image is shown.
38 * @param {document} document Document.
39 * @param {number} width Expected width of the image.
40 * @param {number} height Expected height of the image.
41 * @param {string} name Expected name of the image.
42 * @return {Promise} Promsie to be fulfilled when the check is passed.
44 function waitForSlideImage(document, width, height, name) {
45 var expected = {width: width, height: height, name: name};
46 return repeatUntil(function() {
47 var fullResCanvas = document.querySelector(
48 '.gallery[mode="slide"] .content canvas.fullres');
49 var nameBox = document.querySelector('.namebox');
51 width: fullResCanvas && fullResCanvas.width,
52 height: fullResCanvas && fullResCanvas.height,
53 name: nameBox && nameBox.value
55 if (!chrome.test.checkDeepEq(expected, actual)) {
56 return pending('Slide mode state, expected is %j, actual is %j.',