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 * Runs a test to traverse images in the slide mode.
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 * @return {Promise} Promise to be fulfilled with on success.
15 function traverseSlideImages(testVolumeName, volumeType) {
16 var testEntries = [ENTRIES.desktop, ENTRIES.image3];
17 var launchedPromise = launch(
18 testVolumeName, volumeType, testEntries, testEntries.slice(0, 1));
20 return launchedPromise.then(function(args) {
22 return gallery.waitForElement(appId, '.gallery[mode="slide"]');
24 return gallery.waitForSlideImage(appId, 800, 600, 'My Desktop Background');
26 return gallery.waitAndClickElement(appId, '.arrow.right');
28 return gallery.waitForSlideImage(appId, 640, 480, 'image3');
30 return gallery.waitAndClickElement(appId, '.arrow.right');
32 return gallery.waitForSlideImage(appId, 800, 600, 'My Desktop Background');
37 * Runs a test to rename an image.
39 * @param {string} testVolumeName Test volume name passed to the addEntries
40 * function. Either 'drive' or 'local'.
41 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
42 * @return {Promise} Promise to be fulfilled with on success.
44 function renameImage(testVolumeName, volumeType) {
45 var launchedPromise = launch(
46 testVolumeName, volumeType, [ENTRIES.desktop]);
48 return launchedPromise.then(function(args) {
50 return gallery.waitForSlideImage(appId, 800, 600, 'My Desktop Background');
52 return gallery.changeNameAndWait(appId, 'New Image Name');
54 return gallery.waitForAFile(volumeType, 'New Image Name.png');
59 * Runs a test to delete an image.
61 * @param {string} testVolumeName Test volume name passed to the addEntries
62 * function. Either 'drive' or 'local'.
63 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
64 * @return {Promise} Promise to be fulfilled with on success.
66 function deleteImage(testVolumeName, volumeType) {
67 var launchedPromise = launch(
68 testVolumeName, volumeType, [ENTRIES.desktop]);
70 return launchedPromise.then(function(args) {
72 return gallery.waitForSlideImage(appId, 800, 600, 'My Desktop Background');
74 return gallery.waitAndClickElement(appId, 'paper-button.delete');
76 return gallery.waitAndClickElement(appId, '.cr-dialog-ok');
78 return repeatUntil(function() {
79 return gallery.getFilesUnderVolume(volumeType, ['New Image Name.png'])
80 .then(function(urls) {
83 return pending('"New Image Name.png" is still there.');
90 * Runs test to check availability of share button.
92 * @param {string} testVolumeName Test volume name passed to the addEntries
93 * function. Either 'drive' or 'local'.
94 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
95 * @param {boolean} available True if share button should be available in test.
96 * @return {Promise} Promise to be fulfilled with on success.
98 function checkAvailabilityOfShareButton(testVolumeName, volumeType, available) {
101 testVolumeName, volumeType, [ENTRIES.desktop]).then(function(args) {
103 // Wait until UI has been initialized.
104 return gallery.waitForSlideImage(appId, 800, 600, 'My Desktop Background');
106 return gallery.waitForElement(appId,
107 'paper-button.share' + (available ? ':not([disabled])' : '[disabled]'));
112 * The traverseSlideImages test for Downloads.
113 * @return {Promise} Promise to be fulfilled with on success.
115 testcase.traverseSlideImagesOnDownloads = function() {
116 return traverseSlideImages('local', 'downloads');
120 * The traverseSlideImages test for Google Drive.
121 * @return {Promise} Promise to be fulfilled with on success.
123 testcase.traverseSlideImagesOnDrive = function() {
124 return traverseSlideImages('drive', 'drive');
128 * The renameImage test for Downloads.
129 * @return {Promise} Promise to be fulfilled with on success.
131 testcase.renameImageOnDownloads = function() {
132 return renameImage('local', 'downloads');
136 * The renameImage test for Google Drive.
137 * @return {Promise} Promise to be fulfilled with on success.
139 testcase.renameImageOnDrive = function() {
140 return renameImage('drive', 'drive');
144 * The deleteImage test for Downloads.
145 * @return {Promise} Promise to be fulfilled with on success.
147 testcase.deleteImageOnDownloads = function() {
148 return deleteImage('local', 'downloads');
152 * The deleteImage test for Google Drive.
153 * @return {Promise} Promise to be fulfilled with on success.
155 testcase.deleteImageOnDrive = function() {
156 return deleteImage('drive', 'drive');
160 * The checkAvailabilityOfShareButton test for Downloads.
161 * @return {Promise} Promise to be fulfilled with on success.
163 testcase.checkAvailabilityOfShareButtonOnDownloads = function() {
164 return checkAvailabilityOfShareButton(
165 'local', 'downloads', false /* not available */);
169 * The checkAvailabilityOfShareButton test for Google Drive.
170 * @return {Promise} Promise to be fulfilled with on success.
172 testcase.checkAvailabilityOfShareButtonOnDrive = function() {
173 return checkAvailabilityOfShareButton('drive', 'drive', true /* available */);