Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: chrome/test/data/extensions/api_test/file_manager_browsertest/transfer.js

Issue 304683002: Add the browser test for the new gallery. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 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.
4
5 'use strict';
6
7 /**
8 * Test function to copy from the specified source to the specified destination.
9 * @param {TestEntryInfo} targetFile TestEntryInfo of target file to be copied.
10 * @param {string} srcName Type of source volume. e.g. downloads, drive,
11 * drive_recent, drive_shared_with_me, drive_offline.
12 * @param {Array.<TestEntryInfo>} srcEntries Expected initial contents in the
13 * source volume.
14 * @param {string} dstName Type of destination volume.
15 * @param {Array.<TestEntryInfo>} dstEntries Expected initial contents in the
16 * destination volume.
17 */
18 function copyBetweenVolumes(targetFile,
19 srcName,
20 srcEntries,
21 dstName,
22 dstEntries) {
23 var srcContents = TestEntryInfo.getExpectedRows(srcEntries).sort();
24 var dstContents = TestEntryInfo.getExpectedRows(dstEntries).sort();
25
26 var appId;
27 StepsRunner.run([
28 // Set up File Manager.
29 function() {
30 setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
31 },
32 // Select the source volume.
33 function(inAppId) {
34 appId = inAppId;
35 callRemoteTestUtil(
36 'selectVolume', appId, [srcName], this.next);
37 },
38 // Wait for the expected files to appear in the file list.
39 function(result) {
40 chrome.test.assertTrue(result);
41 waitForFiles(appId, srcContents).then(this.next);
42 },
43 // Select the source file.
44 function() {
45 callRemoteTestUtil(
46 'selectFile', appId, [targetFile.nameText], this.next);
47 },
48 // Copy the file.
49 function(result) {
50 chrome.test.assertTrue(result);
51 callRemoteTestUtil('execCommand', appId, ['copy'], this.next);
52 },
53 // Select the destination volume.
54 function(result) {
55 chrome.test.assertTrue(result);
56 callRemoteTestUtil(
57 'selectVolume', appId, [dstName], this.next);
58 },
59 // Wait for the expected files to appear in the file list.
60 function(result) {
61 chrome.test.assertTrue(result);
62 waitForFiles(appId, dstContents).then(this.next);
63 },
64 // Paste the file.
65 function() {
66 callRemoteTestUtil('execCommand', appId, ['paste'], this.next);
67 },
68 // Wait for the file list to change.
69 function(result) {
70 chrome.test.assertTrue(result);
71 var ignoreFileSize =
72 srcName == 'drive_shared_with_me' ||
73 srcName == 'drive_offline' ||
74 dstName == 'drive_shared_with_me' ||
75 dstName == 'drive_offline';
76 var dstContentsAfterPaste = dstContents.slice();
77 var pasteFile = targetFile.getExpectedRow();
78 for (var i = 0; i < dstContentsAfterPaste.length; i++) {
79 if (dstContentsAfterPaste[i][0] === pasteFile[0]) {
80 // Replace the last '.' in filename with ' (1).'.
81 // e.g. 'my.note.txt' -> 'my.note (1).txt'
82 pasteFile[0] = pasteFile[0].replace(/\.(?=[^\.]+$)/, ' (1).');
83 break;
84 }
85 }
86 dstContentsAfterPaste.push(pasteFile);
87 waitForFiles(appId, dstContentsAfterPaste, {
88 ignoreFileSize: ignoreFileSize,
89 ignoreLastModifiedTime: true
90 }).then(this.next);
91 },
92 // Check the last contents of file list.
93 function() {
94 checkIfNoErrorsOccured(this.next);
95 }
96 ]);
97 }
98
99 /**
100 * Tests copy from drive's root to local's downloads.
101 */
102 testcase.transferFromDriveToDownloads = copyBetweenVolumes.bind(
103 null,
104 ENTRIES.hello,
105 'drive',
106 BASIC_DRIVE_ENTRY_SET,
107 'downloads',
108 BASIC_LOCAL_ENTRY_SET);
109
110 /**
111 * Tests copy from local's downloads to drive's root.
112 */
113 testcase.transferFromDownloadsToDrive = copyBetweenVolumes.bind(
114 null,
115 ENTRIES.hello,
116 'downloads',
117 BASIC_LOCAL_ENTRY_SET,
118 'drive',
119 BASIC_DRIVE_ENTRY_SET);
120
121 /**
122 * Tests copy from drive's shared_with_me to local's downloads.
123 */
124 testcase.transferFromSharedToDownloads = copyBetweenVolumes.bind(
125 null,
126 ENTRIES.testSharedDocument,
127 'drive_shared_with_me',
128 SHARED_WITH_ME_ENTRY_SET,
129 'downloads',
130 BASIC_LOCAL_ENTRY_SET);
131
132 /**
133 * Tests copy from drive's shared_with_me to drive's root.
134 */
135 testcase.transferFromSharedToDrive = copyBetweenVolumes.bind(
136 null,
137 ENTRIES.testSharedDocument,
138 'drive_shared_with_me',
139 SHARED_WITH_ME_ENTRY_SET,
140 'drive',
141 BASIC_DRIVE_ENTRY_SET);
142
143 /**
144 * Tests copy from drive's recent to local's downloads.
145 */
146 testcase.transferFromRecentToDownloads = copyBetweenVolumes.bind(
147 null,
148 ENTRIES.hello,
149 'drive_recent',
150 RECENT_ENTRY_SET,
151 'downloads',
152 BASIC_LOCAL_ENTRY_SET);
153
154 /**
155 * Tests copy from drive's recent to drive's root.
156 */
157 testcase.transferFromRecentToDrive = copyBetweenVolumes.bind(
158 null,
159 ENTRIES.hello,
160 'drive_recent',
161 RECENT_ENTRY_SET,
162 'drive',
163 BASIC_DRIVE_ENTRY_SET);
164
165 /**
166 * Tests copy from drive's offline to local's downloads.
167 */
168 testcase.transferFromOfflineToDownloads = copyBetweenVolumes.bind(
169 null,
170 ENTRIES.testDocument,
171 'drive_offline',
172 OFFLINE_ENTRY_SET,
173 'downloads',
174 BASIC_LOCAL_ENTRY_SET);
175
176 /**
177 * Tests copy from drive's offline to drive's root.
178 */
179 testcase.transferFromOfflineToDrive = copyBetweenVolumes.bind(
180 null,
181 ENTRIES.testDocument,
182 'drive_offline',
183 OFFLINE_ENTRY_SET,
184 'drive',
185 BASIC_DRIVE_ENTRY_SET);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698