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

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

Issue 16097003: drive: Stop using FilePathWatcher from FileManagerBrowserTest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 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
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/file_manager_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Expected files before tests are performed. Entries for Local tests. 6 * Expected files before tests are performed. Entries for Local tests.
7 * @type {Array.<Array.<string>>} 7 * @type {Array.<Array.<string>>}
8 * @const 8 * @const
9 */ 9 */
10 var EXPECTED_FILES_BEFORE_LOCAL = [ 10 var EXPECTED_FILES_BEFORE_LOCAL = [
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 * Expected files shown in "Shared with me", which should be the entries labeled 109 * Expected files shown in "Shared with me", which should be the entries labeled
110 * with "shared-with-me". 110 * with "shared-with-me".
111 * @type {Array.<Array.<string>>} 111 * @type {Array.<Array.<string>>}
112 * @const 112 * @const
113 */ 113 */
114 var EXPECTED_FILES_IN_SHARED_WITH_ME = [ 114 var EXPECTED_FILES_IN_SHARED_WITH_ME = [
115 ['Test Shared Document.gdoc','--','Google document','Mar 20, 2013 10:40 PM'] 115 ['Test Shared Document.gdoc','--','Google document','Mar 20, 2013 10:40 PM']
116 ]; 116 ];
117 117
118 /** 118 /**
119 * Returns the name of the given file list entry.
120 * @param {Array.<string>} file An entry in a file list.
121 * @return {string} Name of the file.
122 */
123 function getFileName(fileListEntry) {
124 return fileListEntry[0];
125 }
126
127 /**
128 * Returns the size of the given file list entry.
129 * @param {Array.<string>} An entry in a file list.
130 * @return {string} Size of the file.
131 */
132 function getFileSize(fileListEntry) {
133 return fileListEntry[1];
134 }
135
136 /**
137 * Returns the type of the given file list entry.
138 * @param {Array.<string>} An entry in a file list.
139 * @return {string} Type of the file.
140 */
141 function getFileType(fileListEntry) {
142 return fileListEntry[2];
143 }
144
145 /**
119 * Namespace for test cases. 146 * Namespace for test cases.
120 */ 147 */
121 var testcase = {}; 148 var testcase = {};
122 149
123 /** 150 /**
124 * Namespace for intermediate test cases. 151 * Namespace for intermediate test cases.
125 * */ 152 * */
126 testcase.intermediate = {}; 153 testcase.intermediate = {};
127 154
128 /** 155 /**
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 steps.shift()(); 241 steps.shift()();
215 }; 242 };
216 243
217 /** 244 /**
218 * Tests copying a file to the same directory and waits until the file lists 245 * Tests copying a file to the same directory and waits until the file lists
219 * changes. 246 * changes.
220 * 247 *
221 * @param {string} path Directory path to be tested. 248 * @param {string} path Directory path to be tested.
222 */ 249 */
223 testcase.intermediate.keyboardCopy = function(path, callback) { 250 testcase.intermediate.keyboardCopy = function(path, callback) {
224 setupAndWaitUntilReady(path, function(appId) { 251 // Returns true if |fileList| contains a copy of |filename|.
225 callRemoteTestUtil('copyFile', appId, ['world.ogv'], function(result) { 252 var isCopyPresent = function(filename, fileList) {
226 chrome.test.assertFalse(!result); 253 var originalEntry;
227 callRemoteTestUtil('waitForFileListChange', 254 for (var i = 0; i < fileList.length; i++) {
228 appId, 255 if (getFileName(fileList[i]) == filename)
229 [getExpectedFilesBefore(path == '/drive/root').length], 256 originalEntry = fileList[i];
230 checkIfNoErrorsOccured.bind(null, 257 }
231 chrome.test.succeed)); 258 if (!originalEntry)
232 }); 259 return false;
233 }); 260
261 var baseName = filename.substring(0, filename.lastIndexOf('.'));
262 var extension = filename.substring(filename.lastIndexOf('.'));
263 var filenamePattern = new RegExp('^' + baseName + '.+' + extension + '$');
264 for (var i = 0; i < fileList.length; i++) {
265 // Check size, type and file name pattern to find a copy.
266 if (getFileSize(fileList[i]) == getFileSize(originalEntry) &&
267 getFileType(fileList[i]) == getFileType(originalEntry) &&
268 filenamePattern.exec(getFileName(fileList[i])))
269 return true;
270 }
271 return false;
272 }
273
274 var filename = 'world.ogv';
275 var appId, fileListBefore;
276 var steps = [
277 // Set up File Manager.
278 function() {
279 setupAndWaitUntilReady(path, steps.shift());
280 },
281 // Copy the file.
282 function(inAppId, inFileListBefore) {
283 appId = inAppId;
284 fileListBefore = inFileListBefore;
285 chrome.test.assertFalse(isCopyPresent(filename, fileListBefore));
286 callRemoteTestUtil('copyFile', appId, [filename], steps.shift());
287 },
288 // Wait for file list change.
289 function(result) {
290 chrome.test.assertTrue(result);
291 callRemoteTestUtil('waitForFileListChange', appId,
292 [fileListBefore.length], steps.shift());
293 },
294 // Verify the result.
295 function(fileList) {
296 chrome.test.assertTrue(isCopyPresent(filename, fileList));
297 checkIfNoErrorsOccured(chrome.test.succeed);
298 }
299 ];
300 steps = steps.map(function(f) { return chrome.test.callbackPass(f); });
301 steps.shift()();
234 }; 302 };
235 303
236 /** 304 /**
237 * Tests deleting a file and and waits until the file lists changes. 305 * Tests deleting a file and and waits until the file lists changes.
238 * @param {string} path Directory path to be tested. 306 * @param {string} path Directory path to be tested.
239 */ 307 */
240 testcase.intermediate.keyboardDelete = function(path) { 308 testcase.intermediate.keyboardDelete = function(path) {
241 setupAndWaitUntilReady(path, function(appId) { 309 // Returns true if |fileList| contains |filename|.
242 callRemoteTestUtil('deleteFile', appId, ['world.ogv'], function(result) { 310 var isFilePresent = function(filename, fileList) {
243 chrome.test.assertFalse(!result); 311 for (var i = 0; i < fileList.length; i++) {
244 callRemoteTestUtil('waitAndAcceptDialog', appId, [], function() { 312 if (getFileName(fileList[i]) == filename)
245 callRemoteTestUtil( 313 return true;
246 'waitForFileListChange', 314 }
247 appId, 315 return false;
248 [getExpectedFilesBefore(path == '/drive/root').length], 316 }
249 checkIfNoErrorsOccured.bind(null, chrome.test.succeed)); 317
250 }); 318 var filename = 'world.ogv';
251 }); 319 var appId, fileListBefore;
252 }); 320 var steps = [
321 // Set up File Manager.
322 function() {
323 setupAndWaitUntilReady(path, steps.shift());
324 },
325 // Delete the file.
326 function(inAppId, inFileListBefore) {
327 appId = inAppId;
328 fileListBefore = inFileListBefore;
329 chrome.test.assertTrue(isFilePresent(filename, fileListBefore));
330 callRemoteTestUtil('deleteFile', appId, [filename], steps.shift());
331 },
332 // Reply to dialog.
mtomasz 2013/05/28 05:10:38 nit: dialog -> the dialog
hashimoto 2013/05/28 05:12:44 Done.
333 function(result) {
334 chrome.test.assertTrue(result);
335 callRemoteTestUtil('waitAndAcceptDialog', appId, [], steps.shift());
336 },
337 // Wait for file list change.
mtomasz 2013/05/28 05:10:38 nit: Wait for -> Wait for a
hashimoto 2013/05/28 05:12:44 Done.
338 function() {
339 callRemoteTestUtil('waitForFileListChange', appId,
340 [fileListBefore.length], steps.shift());
341 },
342 // Verify the result.
343 function(fileList) {
344 chrome.test.assertFalse(isFilePresent(filename, fileList));
345 checkIfNoErrorsOccured(chrome.test.succeed);
346 }
347 ];
348 steps = steps.map(function(f) { return chrome.test.callbackPass(f); });
349 steps.shift()();
253 }; 350 };
254 351
255 testcase.fileDisplayDownloads = function() { 352 testcase.fileDisplayDownloads = function() {
256 testcase.intermediate.fileDisplay('/Downloads'); 353 testcase.intermediate.fileDisplay('/Downloads');
257 }; 354 };
258 355
259 testcase.galleryOpenDownloads = function() { 356 testcase.galleryOpenDownloads = function() {
260 testcase.intermediate.galleryOpen('/Downloads'); 357 testcase.intermediate.galleryOpen('/Downloads');
261 }; 358 };
262 359
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 /** 667 /**
571 * Tests copy from drive's offline to drive's root. 668 * Tests copy from drive's offline to drive's root.
572 */ 669 */
573 testcase.transferFromOfflineToDrive = function() { 670 testcase.transferFromOfflineToDrive = function() {
574 testcase.intermediate.copyBetweenVolumes('Test Document.gdoc', 671 testcase.intermediate.copyBetweenVolumes('Test Document.gdoc',
575 'drive_offline', 672 'drive_offline',
576 EXPECTED_FILES_IN_OFFLINE, 673 EXPECTED_FILES_IN_OFFLINE,
577 'drive', 674 'drive',
578 EXPECTED_FILES_BEFORE_DRIVE); 675 EXPECTED_FILES_BEFORE_DRIVE);
579 }; 676 };
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/file_manager_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698