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.image2, 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, 1024, 768, 'image2');
30 return gallery.waitAndClickElement(appId, '.arrow.right');
32 return gallery.waitForSlideImage(appId, 640, 480, 'image3');
34 return gallery.waitAndClickElement(appId, '.arrow.right');
36 return gallery.waitForSlideImage(appId, 800, 600, 'My Desktop Background');
41 * Runs a test to rename an image.
43 * @param {string} testVolumeName Test volume name passed to the addEntries
44 * function. Either 'drive' or 'local'.
45 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
46 * @return {Promise} Promise to be fulfilled with on success.
48 function renameImage(testVolumeName, volumeType) {
49 var launchedPromise = launch(
50 testVolumeName, volumeType, [ENTRIES.desktop]);
52 return launchedPromise.then(function(args) {
54 return gallery.waitForSlideImage(appId, 800, 600, 'My Desktop Background');
56 return gallery.changeNameAndWait(appId, 'New Image Name');
58 return repeatUntil(function() {
59 return gallery.getFilesUnderVolume(volumeType, ['New Image Name.png'])
60 .then(function(urls) {
63 return pending('"New Image Name.png" is not found.');
70 * Runs a test to delete an image.
72 * @param {string} testVolumeName Test volume name passed to the addEntries
73 * function. Either 'drive' or 'local'.
74 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
75 * @return {Promise} Promise to be fulfilled with on success.
77 function deleteImage(testVolumeName, volumeType) {
78 var launchedPromise = launch(
79 testVolumeName, volumeType, [ENTRIES.desktop]);
81 return launchedPromise.then(function(args) {
83 return gallery.waitForSlideImage(appId, 800, 600, 'My Desktop Background');
85 return gallery.waitAndClickElement(appId, 'button.delete');
87 return gallery.waitAndClickElement(appId, '.cr-dialog-ok');
89 return repeatUntil(function() {
90 return gallery.getFilesUnderVolume(volumeType, ['New Image Name.png'])
91 .then(function(urls) {
94 return pending('"New Image Name.png" is still there.');
101 * The traverseSlideImages test for Downloads.
102 * @return {Promise} Promise to be fulfilled with on success.
104 testcase.traverseSlideImagesOnDownloads = function() {
105 return traverseSlideImages('local', 'downloads');
109 * The traverseSlideImages test for Google Drive.
110 * @return {Promise} Promise to be fulfilled with on success.
112 testcase.traverseSlideImagesOnDrive = function() {
113 return traverseSlideImages('drive', 'drive');
117 * The renameImage test for Downloads.
118 * @return {Promise} Promise to be fulfilled with on success.
120 testcase.renameImageOnDownloads = function() {
121 return renameImage('local', 'downloads');
125 * The renameImage test for Google Drive.
126 * @return {Promise} Promise to be fulfilled with on success.
128 testcase.renameImageOnDrive = function() {
129 return renameImage('drive', 'drive');
133 * The deleteImage test for Downloads.
134 * @return {Promise} Promise to be fulfilled with on success.
136 testcase.deleteImageOnDownloads = function() {
137 return deleteImage('local', 'downloads');
141 * The deleteImage test for Google Drive.
142 * @return {Promise} Promise to be fulfilled with on success.
144 testcase.deleteImageOnDrive = function() {
145 return deleteImage('drive', 'drive');