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