OLD | NEW |
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 * */ | 155 * */ |
156 testcase.intermediate = {}; | 156 testcase.intermediate = {}; |
157 | 157 |
158 /** | 158 /** |
159 * Tests if the files initially added by the C++ side are displayed, and | 159 * Tests if the files initially added by the C++ side are displayed, and |
160 * that a subsequently added file shows up. | 160 * that a subsequently added file shows up. |
161 * | 161 * |
162 * @param {string} path Directory path to be tested. | 162 * @param {string} path Directory path to be tested. |
163 */ | 163 */ |
164 testcase.intermediate.fileDisplay = function(path) { | 164 testcase.intermediate.fileDisplay = function(path) { |
| 165 var appId; |
| 166 |
165 var expectedFilesBefore = getExpectedFilesBefore(path == '/drive/root'); | 167 var expectedFilesBefore = getExpectedFilesBefore(path == '/drive/root'); |
166 var expectedFilesAfter = | 168 var expectedFilesAfter = |
167 expectedFilesBefore.concat(EXPECTED_NEWLY_ADDED_FILE).sort(); | 169 expectedFilesBefore.concat(EXPECTED_NEWLY_ADDED_FILE).sort(); |
168 | 170 |
169 setupAndWaitUntilReady(path, function(appId, actualFilesBefore) { | 171 StepsRunner.run([ |
170 chrome.test.assertEq(expectedFilesBefore, actualFilesBefore); | 172 function() { |
171 chrome.test.sendMessage('initial check done', function(reply) { | 173 setupAndWaitUntilReady(path, this.next); |
| 174 }, |
| 175 // Notify that the list has been verified and a new file can be added |
| 176 // in file_manager_browsertest.cc. |
| 177 function(inAppId, actualFilesBefore) { |
| 178 appId = inAppId; |
| 179 chrome.test.assertEq(expectedFilesBefore, actualFilesBefore); |
| 180 chrome.test.sendMessage('initial check done', this.next); |
| 181 }, |
| 182 // Confirm that the file has been added externally and wait for it |
| 183 // to appear in UI. |
| 184 function(reply) { |
172 chrome.test.assertEq('file added', reply); | 185 chrome.test.assertEq('file added', reply); |
173 callRemoteTestUtil( | 186 callRemoteTestUtil( |
174 'waitForFileListChange', | 187 'waitForFileListChange', |
175 appId, | 188 appId, |
176 [expectedFilesBefore.length], function(actualFilesAfter) { | 189 [expectedFilesBefore.length], |
177 chrome.test.assertEq(expectedFilesAfter, actualFilesAfter); | 190 this.next); |
178 checkIfNoErrorsOccured(chrome.test.succeed); | 191 }, |
179 }); | 192 // Confirm the file list. |
180 }); | 193 function(actualFilesAfter) { |
181 }); | 194 chrome.test.assertEq(expectedFilesAfter, actualFilesAfter); |
| 195 checkIfNoErrorsOccured(this.next); |
| 196 }, |
| 197 ]); |
182 }; | 198 }; |
183 | 199 |
184 /** | 200 /** |
185 * Tests if the gallery shows up for the selected image and that the image | 201 * Tests if the gallery shows up for the selected image and that the image |
186 * gets displayed. | 202 * gets displayed. |
187 * | 203 * |
188 * @param {string} path Directory path to be tested. | 204 * @param {string} path Directory path to be tested. |
189 */ | 205 */ |
190 testcase.intermediate.galleryOpen = function(path) { | 206 testcase.intermediate.galleryOpen = function(path) { |
191 var appId; | 207 var appId; |
192 var steps = [ | 208 StepsRunner.run([ |
193 function() { | 209 function() { |
194 setupAndWaitUntilReady(path, steps.shift()); | 210 setupAndWaitUntilReady(path, this.next); |
195 }, | 211 }, |
| 212 // Resize the window to desired dimensions to avoid flakyness. |
196 function(inAppId) { | 213 function(inAppId) { |
197 appId = inAppId; | 214 appId = inAppId; |
198 // Resize the window to desired dimensions to avoid flakyness. | 215 callRemoteTestUtil('resizeWindow', |
199 callRemoteTestUtil('resizeWindow', appId, [320, 320], steps.shift()); | 216 appId, |
| 217 [320, 320], |
| 218 this.next); |
200 }, | 219 }, |
| 220 // Select the image. |
201 function(result) { | 221 function(result) { |
202 chrome.test.assertTrue(result); | 222 chrome.test.assertTrue(result); |
203 // Select the image. | 223 callRemoteTestUtil('selectFile', |
204 callRemoteTestUtil( | 224 appId, |
205 'selectFile', appId, ['My Desktop Background.png'], steps.shift()); | 225 ['My Desktop Background.png'], |
| 226 this.next); |
206 }, | 227 }, |
| 228 // Click on the label to enter the photo viewer. |
207 function(result) { | 229 function(result) { |
208 chrome.test.assertTrue(result); | 230 chrome.test.assertTrue(result); |
209 // Click on the label to enter the photo viewer. | |
210 callRemoteTestUtil( | 231 callRemoteTestUtil( |
211 'fakeMouseClick', | 232 'fakeMouseClick', |
212 appId, | 233 appId, |
213 ['#file-list li.table-row[selected] .filename-label span'], | 234 ['#file-list li.table-row[selected] .filename-label span'], |
214 steps.shift()); | 235 this.next); |
215 }, | 236 }, |
| 237 // Wait for the image in the gallery's screen image. |
216 function(result) { | 238 function(result) { |
217 chrome.test.assertTrue(result); | 239 chrome.test.assertTrue(result); |
218 // Wait for the image in the gallery's screen image. | |
219 callRemoteTestUtil('waitForElement', | 240 callRemoteTestUtil('waitForElement', |
220 appId, | 241 appId, |
221 ['.gallery .content canvas.image', | 242 ['.gallery .content canvas.image', |
222 'iframe.overlay-pane'], | 243 'iframe.overlay-pane'], |
223 steps.shift()); | 244 this.next); |
224 }, | 245 }, |
| 246 // Verify the gallery's screen image. |
225 function(element) { | 247 function(element) { |
226 // Verify the gallery's screen image. | |
227 chrome.test.assertEq('320', element.attributes.width); | 248 chrome.test.assertEq('320', element.attributes.width); |
228 chrome.test.assertEq('240', element.attributes.height); | 249 chrome.test.assertEq('240', element.attributes.height); |
229 // Get the full-resolution image. | 250 // Get the full-resolution image. |
230 callRemoteTestUtil('waitForElement', | 251 callRemoteTestUtil('waitForElement', |
231 appId, | 252 appId, |
232 ['.gallery .content canvas.fullres', | 253 ['.gallery .content canvas.fullres', |
233 'iframe.overlay-pane'], | 254 'iframe.overlay-pane'], |
234 steps.shift()); | 255 this.next); |
235 }, | 256 }, |
| 257 // Verify the gallery's full resolution image. |
236 function(element) { | 258 function(element) { |
237 // Verify the gallery's screen image. | |
238 chrome.test.assertEq('800', element.attributes.width); | 259 chrome.test.assertEq('800', element.attributes.width); |
239 chrome.test.assertEq('600', element.attributes.height); | 260 chrome.test.assertEq('600', element.attributes.height); |
240 chrome.test.succeed(); | 261 checkIfNoErrorsOccured(this.next); |
241 } | 262 } |
242 ]; | 263 ]); |
243 steps = steps.map(function(f) { return chrome.test.callbackPass(f); }); | |
244 steps.shift()(); | |
245 }; | 264 }; |
246 | 265 |
247 /** | 266 /** |
248 * Tests if the audio player shows up for the selected image and that the audio | 267 * Tests if the audio player shows up for the selected image and that the audio |
249 * is loaded successfully. | 268 * is loaded successfully. |
250 * | 269 * |
251 * @param {string} path Directory path to be tested. | 270 * @param {string} path Directory path to be tested. |
252 */ | 271 */ |
253 testcase.intermediate.audioOpen = function(path) { | 272 testcase.intermediate.audioOpen = function(path) { |
254 var appId; | 273 var appId; |
255 var audioAppId; | 274 var audioAppId; |
256 var steps = [ | 275 StepsRunner.run([ |
257 function() { | 276 function() { |
258 setupAndWaitUntilReady(path, steps.shift()); | 277 setupAndWaitUntilReady(path, this.next); |
259 }, | 278 }, |
| 279 // Select the song. |
260 function(inAppId) { | 280 function(inAppId) { |
261 appId = inAppId; | 281 appId = inAppId; |
262 // Select the song. | |
263 callRemoteTestUtil( | 282 callRemoteTestUtil( |
264 'selectFile', appId, ['Beautiful Song.ogg'], steps.shift()); | 283 'selectFile', appId, ['Beautiful Song.ogg'], this.next); |
265 }, | 284 }, |
| 285 // Click on the label to enter the audio player. |
266 function(result) { | 286 function(result) { |
267 chrome.test.assertTrue(result); | 287 chrome.test.assertTrue(result); |
268 // Click on the label to enter the audio player. | |
269 callRemoteTestUtil( | 288 callRemoteTestUtil( |
270 'fakeMouseClick', | 289 'fakeMouseClick', |
271 appId, | 290 appId, |
272 ['#file-list li.table-row[selected] .filename-label span'], | 291 ['#file-list li.table-row[selected] .filename-label span'], |
273 steps.shift()); | 292 this.next); |
274 }, | 293 }, |
| 294 // Wait for the audio player. |
275 function(result) { | 295 function(result) { |
276 chrome.test.assertTrue(result); | 296 chrome.test.assertTrue(result); |
277 // Wait for the audio player. | |
278 callRemoteTestUtil('waitForWindow', | 297 callRemoteTestUtil('waitForWindow', |
279 null, | 298 null, |
280 ['mediaplayer.html'], | 299 ['mediaplayer.html'], |
281 steps.shift()); | 300 this.next); |
282 }, | 301 }, |
| 302 // Wait for the audio tag and verify the source. |
283 function(inAppId) { | 303 function(inAppId) { |
284 audioAppId = inAppId; | 304 audioAppId = inAppId; |
285 // Wait for the audio tag and verify the source. | |
286 callRemoteTestUtil('waitForElement', | 305 callRemoteTestUtil('waitForElement', |
287 audioAppId, | 306 audioAppId, |
288 ['audio[src]'], | 307 ['audio[src]'], |
289 steps.shift()); | 308 this.next); |
290 }, | 309 }, |
| 310 // Get the title tag. |
291 function(element) { | 311 function(element) { |
292 chrome.test.assertEq( | 312 chrome.test.assertEq( |
293 'filesystem:chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/' + | 313 'filesystem:chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/' + |
294 'external' + path + '/Beautiful%20Song.ogg', | 314 'external' + path + '/Beautiful%20Song.ogg', |
295 element.attributes.src); | 315 element.attributes.src); |
296 // Get the title tag. | |
297 callRemoteTestUtil('waitForElement', | 316 callRemoteTestUtil('waitForElement', |
298 audioAppId, | 317 audioAppId, |
299 ['.data-title'], | 318 ['.data-title'], |
300 steps.shift()); | 319 this.next); |
301 }, | 320 }, |
| 321 // Get the artist tag. |
302 function(element) { | 322 function(element) { |
303 chrome.test.assertEq('Beautiful Song', element.text); | 323 chrome.test.assertEq('Beautiful Song', element.text); |
304 // Get the artist tag. | |
305 callRemoteTestUtil('waitForElement', | 324 callRemoteTestUtil('waitForElement', |
306 audioAppId, | 325 audioAppId, |
307 ['.data-artist'], | 326 ['.data-artist'], |
308 steps.shift()); | 327 this.next); |
309 }, | 328 }, |
| 329 // Verify the artist and if there are no javascript errors. |
310 function(element) { | 330 function(element) { |
311 chrome.test.assertEq('Unknown Artist', element.text); | 331 chrome.test.assertEq('Unknown Artist', element.text); |
312 chrome.test.succeed(); | 332 checkIfNoErrorsOccured(this.next); |
313 } | 333 } |
314 ]; | 334 ]); |
315 steps = steps.map(function(f) { return chrome.test.callbackPass(f); }); | |
316 steps.shift()(); | |
317 }; | 335 }; |
318 | 336 |
319 /** | 337 /** |
320 * Tests if the video player shows up for the selected movie and that it is | 338 * Tests if the video player shows up for the selected movie and that it is |
321 * loaded successfully. | 339 * loaded successfully. |
322 * | 340 * |
323 * @param {string} path Directory path to be tested. | 341 * @param {string} path Directory path to be tested. |
324 */ | 342 */ |
325 testcase.intermediate.videoOpen = function(path) { | 343 testcase.intermediate.videoOpen = function(path) { |
326 var appId; | 344 var appId; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 var extension = filename.substring(filename.lastIndexOf('.')); | 419 var extension = filename.substring(filename.lastIndexOf('.')); |
402 var filenamePattern = new RegExp('^' + baseName + '.+' + extension + '$'); | 420 var filenamePattern = new RegExp('^' + baseName + '.+' + extension + '$'); |
403 for (var i = 0; i < fileList.length; i++) { | 421 for (var i = 0; i < fileList.length; i++) { |
404 // Check size, type and file name pattern to find a copy. | 422 // Check size, type and file name pattern to find a copy. |
405 if (getFileSize(fileList[i]) == getFileSize(originalEntry) && | 423 if (getFileSize(fileList[i]) == getFileSize(originalEntry) && |
406 getFileType(fileList[i]) == getFileType(originalEntry) && | 424 getFileType(fileList[i]) == getFileType(originalEntry) && |
407 filenamePattern.exec(getFileName(fileList[i]))) | 425 filenamePattern.exec(getFileName(fileList[i]))) |
408 return true; | 426 return true; |
409 } | 427 } |
410 return false; | 428 return false; |
411 } | 429 }; |
412 | 430 |
413 var filename = 'world.ogv'; | 431 var filename = 'world.ogv'; |
414 var appId, fileListBefore; | 432 var appId, fileListBefore; |
415 var steps = [ | 433 StepsRunner.run([ |
416 // Set up File Manager. | 434 // Set up File Manager. |
417 function() { | 435 function() { |
418 setupAndWaitUntilReady(path, steps.shift()); | 436 setupAndWaitUntilReady(path, this.next); |
419 }, | 437 }, |
420 // Copy the file. | 438 // Copy the file. |
421 function(inAppId, inFileListBefore) { | 439 function(inAppId, inFileListBefore) { |
422 appId = inAppId; | 440 appId = inAppId; |
423 fileListBefore = inFileListBefore; | 441 fileListBefore = inFileListBefore; |
424 chrome.test.assertFalse(isCopyPresent(filename, fileListBefore)); | 442 chrome.test.assertFalse(isCopyPresent(filename, fileListBefore)); |
425 callRemoteTestUtil('copyFile', appId, [filename], steps.shift()); | 443 callRemoteTestUtil('copyFile', appId, [filename], this.next); |
426 }, | 444 }, |
427 // Wait for a file list change. | 445 // Wait for a file list change. |
428 function(result) { | 446 function(result) { |
429 chrome.test.assertTrue(result); | 447 chrome.test.assertTrue(result); |
430 callRemoteTestUtil('waitForFileListChange', appId, | 448 callRemoteTestUtil('waitForFileListChange', |
431 [fileListBefore.length], steps.shift()); | 449 appId, |
| 450 [fileListBefore.length], |
| 451 this.next); |
432 }, | 452 }, |
433 // Verify the result. | 453 // Verify the result. |
434 function(fileList) { | 454 function(fileList) { |
435 chrome.test.assertTrue(isCopyPresent(filename, fileList)); | 455 chrome.test.assertTrue(isCopyPresent(filename, fileList)); |
436 checkIfNoErrorsOccured(steps.shift()); | 456 checkIfNoErrorsOccured(this.next); |
437 }, | 457 } |
438 function() {} | 458 ]); |
439 ]; | |
440 steps = steps.map(function(f) { return chrome.test.callbackPass(f); }); | |
441 steps.shift()(); | |
442 }; | 459 }; |
443 | 460 |
444 /** | 461 /** |
445 * Tests deleting a file and and waits until the file lists changes. | 462 * Tests deleting a file and and waits until the file lists changes. |
446 * @param {string} path Directory path to be tested. | 463 * @param {string} path Directory path to be tested. |
447 */ | 464 */ |
448 testcase.intermediate.keyboardDelete = function(path) { | 465 testcase.intermediate.keyboardDelete = function(path) { |
449 // Returns true if |fileList| contains |filename|. | 466 // Returns true if |fileList| contains |filename|. |
450 var isFilePresent = function(filename, fileList) { | 467 var isFilePresent = function(filename, fileList) { |
451 for (var i = 0; i < fileList.length; i++) { | 468 for (var i = 0; i < fileList.length; i++) { |
452 if (getFileName(fileList[i]) == filename) | 469 if (getFileName(fileList[i]) == filename) |
453 return true; | 470 return true; |
454 } | 471 } |
455 return false; | 472 return false; |
456 } | 473 }; |
457 | 474 |
458 var filename = 'world.ogv'; | 475 var filename = 'world.ogv'; |
459 var directoryName = 'photos'; | 476 var directoryName = 'photos'; |
460 var appId, fileListBefore; | 477 var appId, fileListBefore; |
461 var steps = [ | 478 StepsRunner.run([ |
462 // Set up File Manager. | 479 // Set up File Manager. |
463 function() { | 480 function() { |
464 setupAndWaitUntilReady(path, steps.shift()); | 481 setupAndWaitUntilReady(path, this.next); |
465 }, | 482 }, |
466 // Delete the file. | 483 // Delete the file. |
467 function(inAppId, inFileListBefore) { | 484 function(inAppId, inFileListBefore) { |
468 appId = inAppId; | 485 appId = inAppId; |
469 fileListBefore = inFileListBefore; | 486 fileListBefore = inFileListBefore; |
470 chrome.test.assertTrue(isFilePresent(filename, fileListBefore)); | 487 chrome.test.assertTrue(isFilePresent(filename, fileListBefore)); |
471 callRemoteTestUtil('deleteFile', appId, [filename], steps.shift()); | 488 callRemoteTestUtil( |
| 489 'deleteFile', appId, [filename], this.next); |
472 }, | 490 }, |
473 // Reply to a dialog. | 491 // Reply to a dialog. |
474 function(result) { | 492 function(result) { |
475 chrome.test.assertTrue(result); | 493 chrome.test.assertTrue(result); |
476 callRemoteTestUtil('waitAndAcceptDialog', appId, [], steps.shift()); | 494 callRemoteTestUtil( |
| 495 'waitAndAcceptDialog', appId, [], this.next); |
477 }, | 496 }, |
478 // Wait for a file list change. | 497 // Wait for a file list change. |
479 function() { | 498 function() { |
480 callRemoteTestUtil('waitForFileListChange', appId, | 499 callRemoteTestUtil('waitForFileListChange', |
481 [fileListBefore.length], steps.shift()); | 500 appId, |
| 501 [fileListBefore.length], |
| 502 this.next); |
482 }, | 503 }, |
483 // Delete the directory. | 504 // Delete the directory. |
484 function(fileList) { | 505 function(fileList) { |
485 fileListBefore = fileList; | 506 fileListBefore = fileList; |
486 chrome.test.assertFalse(isFilePresent(filename, fileList)); | 507 chrome.test.assertFalse(isFilePresent(filename, fileList)); |
487 chrome.test.assertTrue(isFilePresent(directoryName, fileList)); | 508 chrome.test.assertTrue(isFilePresent(directoryName, fileList)); |
488 callRemoteTestUtil('deleteFile', appId, [directoryName], steps.shift()); | 509 callRemoteTestUtil('deleteFile', appId, [directoryName], this.next); |
489 }, | 510 }, |
490 // Reply to a dialog. | 511 // Reply to a dialog. |
491 function(result) { | 512 function(result) { |
492 chrome.test.assertTrue(result); | 513 chrome.test.assertTrue(result); |
493 callRemoteTestUtil('waitAndAcceptDialog', appId, [], steps.shift()); | 514 callRemoteTestUtil('waitAndAcceptDialog', appId, [], this.next); |
494 }, | 515 }, |
495 // Wait for a file list change. | 516 // Wait for a file list change. |
496 function() { | 517 function() { |
497 callRemoteTestUtil('waitForFileListChange', appId, | 518 callRemoteTestUtil('waitForFileListChange', appId, |
498 [fileListBefore.length], steps.shift()); | 519 [fileListBefore.length], this.next); |
499 }, | 520 }, |
500 // Verify the result. | 521 // Verify the result. |
501 function(fileList) { | 522 function(fileList) { |
502 chrome.test.assertFalse(isFilePresent(directoryName, fileList)); | 523 chrome.test.assertFalse(isFilePresent(directoryName, fileList)); |
503 checkIfNoErrorsOccured(steps.shift()); | 524 checkIfNoErrorsOccured(this.next); |
504 }, | 525 } |
505 function() {} | 526 ]); |
506 ]; | |
507 steps = steps.map(function(f) { return chrome.test.callbackPass(f); }); | |
508 steps.shift()(); | |
509 }; | 527 }; |
510 | 528 |
511 testcase.fileDisplayDownloads = function() { | 529 testcase.fileDisplayDownloads = function() { |
512 testcase.intermediate.fileDisplay('/Downloads'); | 530 testcase.intermediate.fileDisplay('/Downloads'); |
513 }; | 531 }; |
514 | 532 |
515 testcase.galleryOpenDownloads = function() { | 533 testcase.galleryOpenDownloads = function() { |
516 testcase.intermediate.galleryOpen('/Downloads'); | 534 testcase.intermediate.galleryOpen('/Downloads'); |
517 }; | 535 }; |
518 | 536 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 testcase.intermediate.keyboardDelete('/drive/root'); | 574 testcase.intermediate.keyboardDelete('/drive/root'); |
557 }; | 575 }; |
558 | 576 |
559 /** | 577 /** |
560 * Tests opening the "Recent" on the sidebar navigation by clicking the icon, | 578 * Tests opening the "Recent" on the sidebar navigation by clicking the icon, |
561 * and verifies the directory contents. We test if there are only files, since | 579 * and verifies the directory contents. We test if there are only files, since |
562 * directories are not allowed in "Recent". This test is only available for | 580 * directories are not allowed in "Recent". This test is only available for |
563 * Drive. | 581 * Drive. |
564 */ | 582 */ |
565 testcase.openSidebarRecent = function() { | 583 testcase.openSidebarRecent = function() { |
566 var onFileListChange = function(actualFilesAfter) { | 584 var appId; |
567 chrome.test.assertEq(EXPECTED_FILES_IN_RECENT, actualFilesAfter); | 585 StepsRunner.run([ |
568 checkIfNoErrorsOccured(chrome.test.succeed); | 586 function() { |
569 }; | 587 setupAndWaitUntilReady('/drive/root', this.next); |
570 | 588 }, |
571 setupAndWaitUntilReady('/drive/root', function(appId) { | 589 // Click the icon of the Recent volume. |
572 // Use the icon for a click target. | 590 function(inAppId) { |
573 callRemoteTestUtil( | 591 appId = inAppId; |
574 'selectVolume', appId, ['drive_recent'], | 592 callRemoteTestUtil( |
575 function(result) { | 593 'selectVolume', appId, ['drive_recent'], this.next); |
576 chrome.test.assertFalse(!result); | 594 }, |
577 callRemoteTestUtil( | 595 // Wait until the file list is updated. |
578 'waitForFileListChange', | 596 function(result) { |
579 appId, | 597 chrome.test.assertFalse(!result); |
580 [getExpectedFilesBefore(true /* isDrive */).length], | 598 callRemoteTestUtil( |
581 onFileListChange); | 599 'waitForFileListChange', |
582 }); | 600 appId, |
583 }); | 601 [getExpectedFilesBefore(true /* isDrive */).length], |
| 602 this.next); |
| 603 }, |
| 604 // Verify the file list. |
| 605 function(actualFilesAfter) { |
| 606 chrome.test.assertEq(EXPECTED_FILES_IN_RECENT, actualFilesAfter); |
| 607 checkIfNoErrorsOccured(this.next); |
| 608 } |
| 609 ]); |
584 }; | 610 }; |
585 | 611 |
586 /** | 612 /** |
587 * Tests opening the "Offline" on the sidebar navigation by clicking the icon, | 613 * Tests opening the "Offline" on the sidebar navigation by clicking the icon, |
588 * and checks contenets of the file list. Only the entries "available offline" | 614 * and checks contenets of the file list. Only the entries "available offline" |
589 * should be shown. "Available offline" entires are hosted documents and the | 615 * should be shown. "Available offline" entires are hosted documents and the |
590 * entries cached by DriveCache. | 616 * entries cached by DriveCache. |
591 */ | 617 */ |
592 testcase.openSidebarOffline = function() { | 618 testcase.openSidebarOffline = function() { |
593 var onFileListChange = function(actualFilesAfter) { | 619 var appId; |
594 chrome.test.assertEq(EXPECTED_FILES_IN_OFFLINE, actualFilesAfter); | 620 StepsRunner.run([ |
595 checkIfNoErrorsOccured(chrome.test.succeed); | 621 function() { |
596 }; | 622 setupAndWaitUntilReady('/drive/root/', this.next) |
597 | 623 }, |
598 setupAndWaitUntilReady('/drive/root/', function(appId) { | 624 // Click the icon of the Offline volume. |
599 // Use the icon for a click target. | 625 function(inAppId) { |
600 callRemoteTestUtil( | 626 appId = inAppId; |
601 'selectVolume', appId, ['drive_offline'], | 627 callRemoteTestUtil( |
602 function(result) { | 628 'selectVolume', appId, ['drive_offline'], this.next); |
603 chrome.test.assertFalse(!result); | 629 }, |
604 callRemoteTestUtil( | 630 // Wait until the file list is updated. |
605 'waitForFileListChange', | 631 function(result) { |
606 appId, | 632 chrome.test.assertFalse(!result); |
607 [getExpectedFilesBefore(true /* isDrive */).length], | 633 callRemoteTestUtil( |
608 onFileListChange); | 634 'waitForFileListChange', |
609 }); | 635 appId, |
610 }); | 636 [getExpectedFilesBefore(true /* isDrive */).length], |
| 637 this.next); |
| 638 }, |
| 639 // Verify the file list. |
| 640 function(actualFilesAfter) { |
| 641 chrome.test.assertEq(EXPECTED_FILES_IN_OFFLINE, actualFilesAfter); |
| 642 checkIfNoErrorsOccured(this.next); |
| 643 } |
| 644 ]); |
611 }; | 645 }; |
612 | 646 |
613 /** | 647 /** |
614 * Tests opening the "Shared with me" on the sidebar navigation by clicking the | 648 * Tests opening the "Shared with me" on the sidebar navigation by clicking the |
615 * icon, and checks contents of the file list. Only the entries labeled with | 649 * icon, and checks contents of the file list. Only the entries labeled with |
616 * "shared-with-me" should be shown. | 650 * "shared-with-me" should be shown. |
617 */ | 651 */ |
618 testcase.openSidebarSharedWithMe = function() { | 652 testcase.openSidebarSharedWithMe = function() { |
619 var onFileListChange = chrome.test.callbackPass(function(actualFilesAfter) { | 653 var appId; |
620 chrome.test.assertEq(EXPECTED_FILES_IN_SHARED_WITH_ME, actualFilesAfter); | 654 StepsRunner.run([ |
621 }); | 655 function() { |
622 | 656 setupAndWaitUntilReady('/drive/root/', this.next); |
623 setupAndWaitUntilReady('/drive/root/', function(appId) { | 657 }, |
624 // Use the icon for a click target. | 658 // Click the icon of the Shared With Me volume. |
625 callRemoteTestUtil( | 659 function(inAppId) { |
626 'selectVolume', appId, ['drive_shared_with_me'], | 660 appId = inAppId; |
627 function(result) { | 661 // Use the icon for a click target. |
628 chrome.test.assertFalse(!result); | 662 callRemoteTestUtil('selectVolume', |
629 callRemoteTestUtil( | 663 appId, |
630 'waitForFileListChange', | 664 ['drive_shared_with_me'], this.next); |
631 appId, | 665 }, |
632 [getExpectedFilesBefore(true /* isDrive */).length], | 666 // Wait until the file list is updated. |
633 onFileListChange); | 667 function(result) { |
634 }); | 668 chrome.test.assertFalse(!result); |
635 }); | 669 callRemoteTestUtil( |
| 670 'waitForFileListChange', |
| 671 appId, |
| 672 [getExpectedFilesBefore(true /* isDrive */).length], |
| 673 this.next); |
| 674 }, |
| 675 // Verify the file list. |
| 676 function(actualFilesAfter) { |
| 677 chrome.test.assertEq(EXPECTED_FILES_IN_SHARED_WITH_ME, actualFilesAfter); |
| 678 checkIfNoErrorsOccured(this.next); |
| 679 } |
| 680 ]); |
636 }; | 681 }; |
637 | 682 |
638 /** | 683 /** |
639 * Tests autocomplete with a query 'hello'. This test is only available for | 684 * Tests autocomplete with a query 'hello'. This test is only available for |
640 * Drive. | 685 * Drive. |
641 */ | 686 */ |
642 testcase.autocomplete = function() { | 687 testcase.autocomplete = function() { |
643 var EXPECTED_AUTOCOMPLETE_LIST = [ | 688 var EXPECTED_AUTOCOMPLETE_LIST = [ |
644 '\'hello\' - search Drive\n', | 689 '\'hello\' - search Drive\n', |
645 'hello.txt\n', | 690 'hello.txt\n', |
646 ]; | 691 ]; |
647 | 692 |
648 var onAutocompleteListShown = function(autocompleteList) { | 693 StepsRunner.run([ |
649 chrome.test.assertEq(EXPECTED_AUTOCOMPLETE_LIST, autocompleteList); | 694 function() { |
650 checkIfNoErrorsOccured(chrome.test.succeed); | 695 setupAndWaitUntilReady('/drive/root', this.next); |
651 }; | 696 }, |
652 | 697 // Perform an auto complete test and wait until the list changes. |
653 setupAndWaitUntilReady('/drive/root', function(appId, list) { | 698 // TODO(mtomasz): Move the operation from test_util.js to tests_cases.js. |
654 callRemoteTestUtil('performAutocompleteAndWait', | 699 function(appId, list) { |
655 appId, | 700 callRemoteTestUtil('performAutocompleteAndWait', |
656 ['hello', EXPECTED_AUTOCOMPLETE_LIST.length], | 701 appId, |
657 onAutocompleteListShown); | 702 ['hello', EXPECTED_AUTOCOMPLETE_LIST.length], |
658 }); | 703 this.next); |
| 704 }, |
| 705 // Verify the list contents. |
| 706 function(autocompleteList) { |
| 707 chrome.test.assertEq(EXPECTED_AUTOCOMPLETE_LIST, autocompleteList); |
| 708 checkIfNoErrorsOccured(this.next); |
| 709 } |
| 710 ]); |
659 }; | 711 }; |
660 | 712 |
661 /** | 713 /** |
662 * Test function to copy from the specified source to the specified destination. | 714 * Test function to copy from the specified source to the specified destination. |
663 * @param {string} targetFile Name of target file to be copied. | 715 * @param {string} targetFile Name of target file to be copied. |
664 * @param {string} srcName Type of source volume. e.g. downloads, drive, | 716 * @param {string} srcName Type of source volume. e.g. downloads, drive, |
665 * drive_recent, drive_shared_with_me, drive_offline. | 717 * drive_recent, drive_shared_with_me, drive_offline. |
666 * @param {Array.<Array.<string>>} srcContents Expected initial contents in the | 718 * @param {Array.<Array.<string>>} srcContents Expected initial contents in the |
667 * source volume. | 719 * source volume. |
668 * @param {string} dstName Type of destination volume. | 720 * @param {string} dstName Type of destination volume. |
669 * @param {Array.<Array.<string>>} dstContents Expected initial contents in the | 721 * @param {Array.<Array.<string>>} dstContents Expected initial contents in the |
670 * destination volume. | 722 * destination volume. |
671 */ | 723 */ |
672 testcase.intermediate.copyBetweenVolumes = function(targetFile, | 724 testcase.intermediate.copyBetweenVolumes = function(targetFile, |
673 srcName, | 725 srcName, |
674 srcContents, | 726 srcContents, |
675 dstName, | 727 dstName, |
676 dstContents) { | 728 dstContents) { |
677 var appId; | 729 var appId; |
678 var steps = [ | 730 StepsRunner.run([ |
679 // Set up File Manager. | 731 // Set up File Manager. |
680 function() { | 732 function() { |
681 setupAndWaitUntilReady('/Downloads', steps.shift()); | 733 setupAndWaitUntilReady('/Downloads', this.next); |
682 }, | 734 }, |
683 // Select the source volume. | 735 // Select the source volume. |
684 function(inAppId) { | 736 function(inAppId) { |
685 appId = inAppId; | 737 appId = inAppId; |
686 callRemoteTestUtil('selectVolume', appId, [srcName], steps.shift()); | 738 callRemoteTestUtil( |
| 739 'selectVolume', appId, [srcName], this.next); |
687 }, | 740 }, |
688 // Wait for the expected files to appear in the file list. | 741 // Wait for the expected files to appear in the file list. |
689 function(result) { | 742 function(result) { |
690 chrome.test.assertTrue(result); | 743 chrome.test.assertTrue(result); |
691 callRemoteTestUtil('waitForFiles', appId, [srcContents], steps.shift()); | 744 callRemoteTestUtil( |
| 745 'waitForFiles', appId, [srcContents], this.next); |
692 }, | 746 }, |
693 // Select the source file. | 747 // Select the source file. |
694 function(result) { | 748 function(result) { |
695 chrome.test.assertTrue(result); | 749 chrome.test.assertTrue(result); |
696 callRemoteTestUtil('selectFile', appId, [targetFile], steps.shift()); | 750 callRemoteTestUtil( |
| 751 'selectFile', appId, [targetFile], this.next); |
697 }, | 752 }, |
698 // Copy the file. | 753 // Copy the file. |
699 function(result) { | 754 function(result) { |
700 chrome.test.assertTrue(result); | 755 chrome.test.assertTrue(result); |
701 callRemoteTestUtil('execCommand', appId, ['copy'], steps.shift()); | 756 callRemoteTestUtil('execCommand', appId, ['copy'], this.next); |
702 }, | 757 }, |
703 // Select the destination volume. | 758 // Select the destination volume. |
704 function(result) { | 759 function(result) { |
705 chrome.test.assertTrue(result); | 760 chrome.test.assertTrue(result); |
706 callRemoteTestUtil('selectVolume', appId, [dstName], steps.shift()); | 761 callRemoteTestUtil( |
| 762 'selectVolume', appId, [dstName], this.next); |
707 }, | 763 }, |
708 // Wait for the expected files to appear in the file list. | 764 // Wait for the expected files to appear in the file list. |
709 function(result) { | 765 function(result) { |
710 chrome.test.assertTrue(result); | 766 chrome.test.assertTrue(result); |
711 callRemoteTestUtil('waitForFiles', appId, [dstContents], steps.shift()); | 767 callRemoteTestUtil( |
| 768 'waitForFiles', appId, [dstContents], this.next); |
712 }, | 769 }, |
713 // Paste the file. | 770 // Paste the file. |
714 function(result) { | 771 function(result) { |
715 chrome.test.assertTrue(result); | 772 chrome.test.assertTrue(result); |
716 callRemoteTestUtil('execCommand', appId, ['paste'], steps.shift()); | 773 callRemoteTestUtil( |
| 774 'execCommand', appId, ['paste'], this.next); |
717 }, | 775 }, |
718 // Wait for the file list to change. | 776 // Wait for the file list to change. |
719 function(result) { | 777 function(result) { |
720 chrome.test.assertTrue(result); | 778 chrome.test.assertTrue(result); |
721 callRemoteTestUtil('waitForFileListChange', appId, | 779 callRemoteTestUtil('waitForFileListChange', |
722 [dstContents.length], steps.shift()); | 780 appId, |
| 781 [dstContents.length], |
| 782 this.next); |
723 }, | 783 }, |
724 // Check the last contents of file list. | 784 // Check the last contents of file list. |
725 function(actualFilesAfter) { | 785 function(actualFilesAfter) { |
726 chrome.test.assertEq(dstContents.length + 1, | 786 chrome.test.assertEq(dstContents.length + 1, |
727 actualFilesAfter.length); | 787 actualFilesAfter.length); |
728 var copiedItem = null; | 788 var copiedItem = null; |
729 for (var i = 0; i < srcContents.length; i++) { | 789 for (var i = 0; i < srcContents.length; i++) { |
730 if (srcContents[i][0] == targetFile) { | 790 if (srcContents[i][0] == targetFile) { |
731 copiedItem = srcContents[i]; | 791 copiedItem = srcContents[i]; |
732 break; | 792 break; |
(...skipping 11 matching lines...) Expand all Loading... |
744 // File size can not be obtained on drive_shared_with_me volume and | 804 // File size can not be obtained on drive_shared_with_me volume and |
745 // drive_offline. | 805 // drive_offline. |
746 var ignoreSize = srcName == 'drive_shared_with_me' || | 806 var ignoreSize = srcName == 'drive_shared_with_me' || |
747 dstName == 'drive_shared_with_me' || | 807 dstName == 'drive_shared_with_me' || |
748 srcName == 'drive_offline' || | 808 srcName == 'drive_offline' || |
749 dstName == 'drive_offline'; | 809 dstName == 'drive_offline'; |
750 for (var i = 0; i < actualFilesAfter.length; i++) { | 810 for (var i = 0; i < actualFilesAfter.length; i++) { |
751 if (actualFilesAfter[i][0] == copiedItem[0] && | 811 if (actualFilesAfter[i][0] == copiedItem[0] && |
752 (ignoreSize || actualFilesAfter[i][1] == copiedItem[1]) && | 812 (ignoreSize || actualFilesAfter[i][1] == copiedItem[1]) && |
753 actualFilesAfter[i][2] == copiedItem[2]) { | 813 actualFilesAfter[i][2] == copiedItem[2]) { |
754 chrome.test.succeed(); | 814 checkIfNoErrorsOccured(this.next); |
755 return; | 815 return; |
756 } | 816 } |
757 } | 817 } |
758 chrome.test.fail(); | 818 chrome.test.fail(); |
759 } | 819 } |
760 ]; | 820 ]); |
761 steps = steps.map(function(f) { return chrome.test.callbackPass(f); }); | |
762 steps.shift()(); | |
763 }; | 821 }; |
764 | 822 |
765 /** | 823 /** |
766 * Tests copy from drive's root to local's downloads. | 824 * Tests copy from drive's root to local's downloads. |
767 */ | 825 */ |
768 testcase.transferFromDriveToDownloads = function() { | 826 testcase.transferFromDriveToDownloads = function() { |
769 testcase.intermediate.copyBetweenVolumes('hello.txt', | 827 testcase.intermediate.copyBetweenVolumes('hello.txt', |
770 'drive', | 828 'drive', |
771 EXPECTED_FILES_BEFORE_DRIVE, | 829 EXPECTED_FILES_BEFORE_DRIVE, |
772 'downloads', | 830 'downloads', |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 /** | 900 /** |
843 * Tests copy from drive's offline to drive's root. | 901 * Tests copy from drive's offline to drive's root. |
844 */ | 902 */ |
845 testcase.transferFromOfflineToDrive = function() { | 903 testcase.transferFromOfflineToDrive = function() { |
846 testcase.intermediate.copyBetweenVolumes('Test Document.gdoc', | 904 testcase.intermediate.copyBetweenVolumes('Test Document.gdoc', |
847 'drive_offline', | 905 'drive_offline', |
848 EXPECTED_FILES_IN_OFFLINE, | 906 EXPECTED_FILES_IN_OFFLINE, |
849 'drive', | 907 'drive', |
850 EXPECTED_FILES_BEFORE_DRIVE); | 908 EXPECTED_FILES_BEFORE_DRIVE); |
851 }; | 909 }; |
OLD | NEW |