1 // Copyright 2015 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.
6 * Renames an image in thumbnail mode and confirms that thumbnail of renamed
7 * image is successfully updated.
8 * @param {string} testVolumeName Test volume name.
9 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
10 * @return {!Promise} Promise to be fulfilled with on success.
12 function renameImageInThumbnailMode(testVolumeName, volumeType) {
13 var launchedPromise = launch(testVolumeName, volumeType,
14 [ENTRIES.desktop, ENTRIES.image3], [ENTRIES.desktop]);
16 return launchedPromise.then(function(result) {
17 // Confirm initial state after the launch.
19 return gallery.waitForSlideImage(appId, 800, 600, 'My Desktop Background');
21 // Goes to thumbnail mode.
22 return gallery.waitAndClickElement(appId, 'button.mode');
24 return gallery.selectImageInThumbnailMode(appId, 'image3.jpg');
25 }).then(function(result) {
26 chrome.test.assertTrue(result);
27 return gallery.callRemoteTestUtil('changeName', appId, ['New Image Name']);
29 // Assert that rename had done successfully.
30 return gallery.waitForAFile(volumeType, 'New Image Name.jpg');
32 return gallery.selectImageInThumbnailMode(
33 appId, 'My Desktop Background.png');
34 }).then(function(result) {
35 chrome.test.assertTrue(result);
36 return gallery.callRemoteTestUtil('queryAllElements', appId,
37 ['.thumbnail-view > ul > li.selected']);
38 }).then(function(result) {
39 // Only My Desktop Background.png is selected.
40 chrome.test.assertEq(1, result.length);
42 chrome.test.assertEq('My Desktop Background.png',
43 result[0].attributes['title']);
44 return gallery.callRemoteTestUtil('queryAllElements', appId,
45 ['.thumbnail-view > ul > li:not(.selected)']);
46 }).then(function(result) {
47 // Confirm that thumbnail of renamed image has updated.
48 chrome.test.assertEq(1, result.length);
49 chrome.test.assertEq('New Image Name.jpg',
50 result[0].attributes['title']);
55 * Delete all images in thumbnail mode and confirm that no-images error banner
57 * @param {string} testVolumeName Test volume name.
58 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
59 * @return {!Promise} Promise to be fulfilled with on success.
61 function deleteAllImagesInThumbnailMode(testVolumeName, volumeType) {
62 var launchedPromise = launch(testVolumeName, volumeType,
63 [ENTRIES.desktop, ENTRIES.image3]);
65 return launchedPromise.then(function(result) {
67 // Click delete button.
68 return gallery.waitAndClickElement(appId, 'paper-button.delete');
69 }).then(function(result) {
70 chrome.test.assertTrue(!!result);
71 // Wait and click delete button of confirmation dialog.
72 return gallery.waitAndClickElement(appId, '.cr-dialog-ok');
73 }).then(function(result) {
74 chrome.test.assertTrue(!!result);
75 // Wait until error banner is shown.
76 return gallery.waitForElement(appId, '.gallery[error] .error-banner');
81 * Rename test in thumbnail mode for Downloads.
82 * @return {!Promise} Promise to be fulfilled with on success.
84 testcase.renameImageInThumbnailModeOnDownloads = function() {
85 return renameImageInThumbnailMode('local', 'downloads');
89 * Rename test in thumbnail mode for Drive.
90 * @return {!Promise} Promise to be fulfilled with on success.
92 testcase.renameImageInThumbnailModeOnDrive = function() {
93 return renameImageInThumbnailMode('drive', 'drive');
97 * Delete all images test in thumbnail mode for Downloads.
98 * @return {!Promise} Promise to be fulfilled with on success.
100 testcase.deleteAllImagesInThumbnailModeOnDownloads = function() {
101 return deleteAllImagesInThumbnailMode('local', 'downloads');
105 * Delete all images test in thumbnail mode for Drive.
106 * @return {!Promise} Promise to be fulfilled with on success.
108 testcase.deleteAllImagesInThumbnailModeOnDrive = function() {
109 return deleteAllImagesInThumbnailMode('drive', 'drive');