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

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

Issue 132453007: Migrate fullPaths to URLs in appState. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @enum {string} 8 * @enum {string}
9 * @const 9 * @const
10 */ 10 */
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 * with "shared-with-me". 212 * with "shared-with-me".
213 * 213 *
214 * @type {Array.<TestEntryInfo>} 214 * @type {Array.<TestEntryInfo>}
215 * @const 215 * @const
216 */ 216 */
217 var SHARED_WITH_ME_ENTRY_SET = [ 217 var SHARED_WITH_ME_ENTRY_SET = [
218 ENTRIES.testSharedDocument 218 ENTRIES.testSharedDocument
219 ]; 219 ];
220 220
221 /** 221 /**
222 * Opens a Files.app's main window and waits until it is initialized. 222 * Opens a Files.app's main window.
223 *
224 * TODO(mtomasz): Pass a volumeId or an enum value instead of full paths.
225 *
226 * @param {Object} appState App state to be passed with on opening Files.app.
227 * Can be null.
228 * @param {?string} initialRoot Root path to be used as a default current
229 * directory during initialization. Can be null, for no default path.
230 * @param {function(string)} Callback with the app id.
231 */
232 function openNewWindow(appState, initialRoot, callback) {
233 var appId;
234
235 // TODO(mtomasz): Migrate from full paths to a pair of a volumeId and a
236 // relative path. To compose the URL communicate via messages with
237 // file_manager_browser_test.cc.
238 var processedAppState = appState || {};
239 if (initialRoot) {
240 processedAppState.currentDirectoryURL =
241 'filesystem:chrome-extension://' + FILE_MANAGER_EXTENSIONS_ID +
242 '/external' + initialRoot;
243 }
244
245 callRemoteTestUtil('openMainWindow', null, [processedAppState], callback);
246 }
247
248 /**
249 * Opens a Files.app's main window and waits until it is initialized. Fills
250 * the window with initial files. Should be called for the first window only.
223 * 251 *
224 * TODO(hirono): Add parameters to specify the entry set to be prepared. 252 * TODO(hirono): Add parameters to specify the entry set to be prepared.
253 * TODO(mtomasz): Pass a volumeId or an enum value instead of full paths.
225 * 254 *
226 * @param {Object} appState App state to be passed with on opening Files.app. 255 * @param {Object} appState App state to be passed with on opening Files.app.
256 * Can be null.
257 * @param {?string} initialRoot Root path to be used as a default current
258 * directory during initialization. Can be null, for no default path.
227 * @param {function(string, Array.<Array.<string>>)} Callback with the app id 259 * @param {function(string, Array.<Array.<string>>)} Callback with the app id
228 * and with the file list. 260 * and with the file list.
229 */ 261 */
230 function setupAndWaitUntilReady(appState, callback) { 262 function setupAndWaitUntilReady(appState, initialRoot, callback) {
231 var appId; 263 var appId;
232 var steps = [ 264
265 StepsRunner.run([
233 function() { 266 function() {
234 callRemoteTestUtil('openMainWindow', null, [appState], steps.shift()); 267 openNewWindow(appState, initialRoot, this.next);
235 }, 268 },
236 function(inAppId) { 269 function(inAppId) {
237 appId = inAppId; 270 appId = inAppId;
238 addEntries(['local'], BASIC_LOCAL_ENTRY_SET, steps.shift()); 271 addEntries(['local'], BASIC_LOCAL_ENTRY_SET, this.next);
239 }, 272 },
240 function(success) { 273 function(success) {
241 chrome.test.assertTrue(success); 274 chrome.test.assertTrue(success);
242 addEntries(['drive'], BASIC_DRIVE_ENTRY_SET, steps.shift()); 275 addEntries(['drive'], BASIC_DRIVE_ENTRY_SET, this.next);
243 }, 276 },
244 function(success) { 277 function(success) {
245 chrome.test.assertTrue(success); 278 chrome.test.assertTrue(success);
246 callRemoteTestUtil('waitForFileListChange', appId, [0], steps.shift()); 279 callRemoteTestUtil('waitForFileListChange', appId, [0], this.next);
247 }, 280 },
248 function(fileList) { 281 function(fileList) {
249 callback(appId, fileList); 282 callback(appId, fileList);
283 this.next();
250 } 284 }
251 ]; 285 ]);
252 steps.shift()();
253 } 286 }
254 287
255 /** 288 /**
256 * Verifies if there are no Javascript errors in any of the app windows. 289 * Verifies if there are no Javascript errors in any of the app windows.
257 * @param {function()} Completion callback. 290 * @param {function()} Completion callback.
258 */ 291 */
259 function checkIfNoErrorsOccured(callback) { 292 function checkIfNoErrorsOccured(callback) {
260 callRemoteTestUtil('getErrorCount', null, [], function(count) { 293 callRemoteTestUtil('getErrorCount', null, [], function(count) {
261 chrome.test.assertEq(0, count); 294 chrome.test.assertEq(0, count);
262 callback(); 295 callback();
263 }); 296 });
264 } 297 }
265 298
266
267
268 /** 299 /**
269 * Returns the name of the given file list entry. 300 * Returns the name of the given file list entry.
270 * @param {Array.<string>} file An entry in a file list. 301 * @param {Array.<string>} file An entry in a file list.
271 * @return {string} Name of the file. 302 * @return {string} Name of the file.
272 */ 303 */
273 function getFileName(fileListEntry) { 304 function getFileName(fileListEntry) {
274 return fileListEntry[0]; 305 return fileListEntry[0];
275 } 306 }
276 307
277 /** 308 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 344
314 var expectedFilesBefore = 345 var expectedFilesBefore =
315 TestEntryInfo.getExpectedRows(path == '/drive/root' ? 346 TestEntryInfo.getExpectedRows(path == '/drive/root' ?
316 BASIC_DRIVE_ENTRY_SET : BASIC_LOCAL_ENTRY_SET).sort(); 347 BASIC_DRIVE_ENTRY_SET : BASIC_LOCAL_ENTRY_SET).sort();
317 348
318 var expectedFilesAfter = 349 var expectedFilesAfter =
319 expectedFilesBefore.concat([ENTRIES.newlyAdded.getExpectedRow()]).sort(); 350 expectedFilesBefore.concat([ENTRIES.newlyAdded.getExpectedRow()]).sort();
320 351
321 StepsRunner.run([ 352 StepsRunner.run([
322 function() { 353 function() {
323 var appState = {currentDirectoryPath: path}; 354 setupAndWaitUntilReady(null, path, this.next);
324 setupAndWaitUntilReady(appState, this.next);
325 }, 355 },
326 // Notify that the list has been verified and a new file can be added 356 // Notify that the list has been verified and a new file can be added
327 // in file_manager_browsertest.cc. 357 // in file_manager_browsertest.cc.
328 function(inAppId, actualFilesBefore) { 358 function(inAppId, actualFilesBefore) {
329 appId = inAppId; 359 appId = inAppId;
330 chrome.test.assertEq(expectedFilesBefore, actualFilesBefore); 360 chrome.test.assertEq(expectedFilesBefore, actualFilesBefore);
331 addEntries(['local', 'drive'], [ENTRIES.newlyAdded], this.next); 361 addEntries(['local', 'drive'], [ENTRIES.newlyAdded], this.next);
332 }, 362 },
333 function(result) { 363 function(result) {
334 chrome.test.assertTrue(result); 364 chrome.test.assertTrue(result);
(...skipping 14 matching lines...) Expand all
349 /** 379 /**
350 * Tests if the gallery shows up for the selected image and that the image 380 * Tests if the gallery shows up for the selected image and that the image
351 * gets displayed. 381 * gets displayed.
352 * 382 *
353 * @param {string} path Directory path to be tested. 383 * @param {string} path Directory path to be tested.
354 */ 384 */
355 testcase.intermediate.galleryOpen = function(path) { 385 testcase.intermediate.galleryOpen = function(path) {
356 var appId; 386 var appId;
357 StepsRunner.run([ 387 StepsRunner.run([
358 function() { 388 function() {
359 var appState = {currentDirectoryPath: path}; 389 setupAndWaitUntilReady(null, path, this.next);
360 setupAndWaitUntilReady(appState, this.next);
361 }, 390 },
362 // Resize the window to desired dimensions to avoid flakyness. 391 // Resize the window to desired dimensions to avoid flakyness.
363 function(inAppId) { 392 function(inAppId) {
364 appId = inAppId; 393 appId = inAppId;
365 callRemoteTestUtil('resizeWindow', 394 callRemoteTestUtil('resizeWindow',
366 appId, 395 appId,
367 [320, 320], 396 [320, 320],
368 this.next); 397 this.next);
369 }, 398 },
370 // Select the image. 399 // Select the image.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 * Tests if the audio player shows up for the selected image and that the audio 437 * Tests if the audio player shows up for the selected image and that the audio
409 * is loaded successfully. 438 * is loaded successfully.
410 * 439 *
411 * @param {string} path Directory path to be tested. 440 * @param {string} path Directory path to be tested.
412 */ 441 */
413 testcase.intermediate.audioOpen = function(path) { 442 testcase.intermediate.audioOpen = function(path) {
414 var appId; 443 var appId;
415 var audioAppId; 444 var audioAppId;
416 StepsRunner.run([ 445 StepsRunner.run([
417 function() { 446 function() {
418 var appState = {currentDirectoryPath: path}; 447 setupAndWaitUntilReady(null, path, this.next);
419 setupAndWaitUntilReady(appState, this.next);
420 }, 448 },
421 // Select the song. 449 // Select the song.
422 function(inAppId) { 450 function(inAppId) {
423 appId = inAppId; 451 appId = inAppId;
424 callRemoteTestUtil( 452 callRemoteTestUtil(
425 'openFile', appId, ['Beautiful Song.ogg'], this.next); 453 'openFile', appId, ['Beautiful Song.ogg'], this.next);
426 }, 454 },
427 // Wait for the audio player. 455 // Wait for the audio player.
428 function(result) { 456 function(result) {
429 chrome.test.assertTrue(result); 457 chrome.test.assertTrue(result);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 * Tests if the video player shows up for the selected movie and that it is 499 * Tests if the video player shows up for the selected movie and that it is
472 * loaded successfully. 500 * loaded successfully.
473 * 501 *
474 * @param {string} path Directory path to be tested. 502 * @param {string} path Directory path to be tested.
475 */ 503 */
476 testcase.intermediate.videoOpen = function(path) { 504 testcase.intermediate.videoOpen = function(path) {
477 var appId; 505 var appId;
478 var videoAppId; 506 var videoAppId;
479 StepsRunner.run([ 507 StepsRunner.run([
480 function() { 508 function() {
481 var appState = {currentDirectoryPath: path}; 509 setupAndWaitUntilReady(null, path, this.next);
482 setupAndWaitUntilReady(appState, this.next);
483 }, 510 },
484 function(inAppId) { 511 function(inAppId) {
485 appId = inAppId; 512 appId = inAppId;
486 // Select the song. 513 // Select the song.
487 callRemoteTestUtil( 514 callRemoteTestUtil(
488 'openFile', appId, ['world.ogv'], this.next); 515 'openFile', appId, ['world.ogv'], this.next);
489 }, 516 },
490 function(result) { 517 function(result) {
491 chrome.test.assertTrue(result); 518 chrome.test.assertTrue(result);
492 // Wait for the video player. 519 // Wait for the video player.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 var expectedFilesBefore = 559 var expectedFilesBefore =
533 TestEntryInfo.getExpectedRows(path == '/drive/root' ? 560 TestEntryInfo.getExpectedRows(path == '/drive/root' ?
534 BASIC_DRIVE_ENTRY_SET : BASIC_LOCAL_ENTRY_SET).sort(); 561 BASIC_DRIVE_ENTRY_SET : BASIC_LOCAL_ENTRY_SET).sort();
535 var expectedFilesAfter = 562 var expectedFilesAfter =
536 expectedFilesBefore.concat([['world (1).ogv', '59 KB', 'OGG video']]); 563 expectedFilesBefore.concat([['world (1).ogv', '59 KB', 'OGG video']]);
537 564
538 var appId, fileListBefore; 565 var appId, fileListBefore;
539 StepsRunner.run([ 566 StepsRunner.run([
540 // Set up File Manager. 567 // Set up File Manager.
541 function() { 568 function() {
542 var appState = {currentDirectoryPath: path}; 569 setupAndWaitUntilReady(null, path, this.next);
543 setupAndWaitUntilReady(appState, this.next);
544 }, 570 },
545 // Copy the file. 571 // Copy the file.
546 function(inAppId, inFileListBefore) { 572 function(inAppId, inFileListBefore) {
547 appId = inAppId; 573 appId = inAppId;
548 fileListBefore = inFileListBefore; 574 fileListBefore = inFileListBefore;
549 chrome.test.assertEq(expectedFilesBefore, inFileListBefore); 575 chrome.test.assertEq(expectedFilesBefore, inFileListBefore);
550 callRemoteTestUtil('copyFile', appId, [filename], this.next); 576 callRemoteTestUtil('copyFile', appId, [filename], this.next);
551 }, 577 },
552 // Wait for a file list change. 578 // Wait for a file list change.
553 function(result) { 579 function(result) {
(...skipping 24 matching lines...) Expand all
578 } 604 }
579 return false; 605 return false;
580 }; 606 };
581 607
582 var filename = 'world.ogv'; 608 var filename = 'world.ogv';
583 var directoryName = 'photos'; 609 var directoryName = 'photos';
584 var appId, fileListBefore; 610 var appId, fileListBefore;
585 StepsRunner.run([ 611 StepsRunner.run([
586 // Set up File Manager. 612 // Set up File Manager.
587 function() { 613 function() {
588 var appState = {currentDirectoryPath: path}; 614 setupAndWaitUntilReady(null, path, this.next);
589 setupAndWaitUntilReady(appState, this.next);
590 }, 615 },
591 // Delete the file. 616 // Delete the file.
592 function(inAppId, inFileListBefore) { 617 function(inAppId, inFileListBefore) {
593 appId = inAppId; 618 appId = inAppId;
594 fileListBefore = inFileListBefore; 619 fileListBefore = inFileListBefore;
595 chrome.test.assertTrue(isFilePresent(filename, fileListBefore)); 620 chrome.test.assertTrue(isFilePresent(filename, fileListBefore));
596 callRemoteTestUtil( 621 callRemoteTestUtil(
597 'deleteFile', appId, [filename], this.next); 622 'deleteFile', appId, [filename], this.next);
598 }, 623 },
599 // Reply to a dialog. 624 // Reply to a dialog.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 /** 710 /**
686 * Tests opening the "Recent" on the sidebar navigation by clicking the icon, 711 * Tests opening the "Recent" on the sidebar navigation by clicking the icon,
687 * and verifies the directory contents. We test if there are only files, since 712 * and verifies the directory contents. We test if there are only files, since
688 * directories are not allowed in "Recent". This test is only available for 713 * directories are not allowed in "Recent". This test is only available for
689 * Drive. 714 * Drive.
690 */ 715 */
691 testcase.openSidebarRecent = function() { 716 testcase.openSidebarRecent = function() {
692 var appId; 717 var appId;
693 StepsRunner.run([ 718 StepsRunner.run([
694 function() { 719 function() {
695 var appState = {currentDirectoryPath: '/drive/root'}; 720 setupAndWaitUntilReady(null, '/drive/root', this.next);
696 setupAndWaitUntilReady(appState, this.next);
697 }, 721 },
698 // Click the icon of the Recent volume. 722 // Click the icon of the Recent volume.
699 function(inAppId) { 723 function(inAppId) {
700 appId = inAppId; 724 appId = inAppId;
701 callRemoteTestUtil( 725 callRemoteTestUtil(
702 'selectVolume', appId, ['drive_recent'], this.next); 726 'selectVolume', appId, ['drive_recent'], this.next);
703 }, 727 },
704 // Wait until the file list is updated. 728 // Wait until the file list is updated.
705 function(result) { 729 function(result) {
706 chrome.test.assertFalse(!result); 730 chrome.test.assertFalse(!result);
(...skipping 16 matching lines...) Expand all
723 /** 747 /**
724 * Tests opening the "Offline" on the sidebar navigation by clicking the icon, 748 * Tests opening the "Offline" on the sidebar navigation by clicking the icon,
725 * and checks contenets of the file list. Only the entries "available offline" 749 * and checks contenets of the file list. Only the entries "available offline"
726 * should be shown. "Available offline" entires are hosted documents and the 750 * should be shown. "Available offline" entires are hosted documents and the
727 * entries cached by DriveCache. 751 * entries cached by DriveCache.
728 */ 752 */
729 testcase.openSidebarOffline = function() { 753 testcase.openSidebarOffline = function() {
730 var appId; 754 var appId;
731 StepsRunner.run([ 755 StepsRunner.run([
732 function() { 756 function() {
733 var appState = {currentDirectoryPath: '/drive/root/'}; 757 setupAndWaitUntilReady(null, '/drive/root', this.next);
734 setupAndWaitUntilReady(appState, this.next);
735 }, 758 },
736 // Click the icon of the Offline volume. 759 // Click the icon of the Offline volume.
737 function(inAppId) { 760 function(inAppId) {
738 appId = inAppId; 761 appId = inAppId;
739 callRemoteTestUtil( 762 callRemoteTestUtil(
740 'selectVolume', appId, ['drive_offline'], this.next); 763 'selectVolume', appId, ['drive_offline'], this.next);
741 }, 764 },
742 // Wait until the file list is updated. 765 // Wait until the file list is updated.
743 function(result) { 766 function(result) {
744 chrome.test.assertFalse(!result); 767 chrome.test.assertFalse(!result);
(...skipping 15 matching lines...) Expand all
760 783
761 /** 784 /**
762 * Tests opening the "Shared with me" on the sidebar navigation by clicking the 785 * Tests opening the "Shared with me" on the sidebar navigation by clicking the
763 * icon, and checks contents of the file list. Only the entries labeled with 786 * icon, and checks contents of the file list. Only the entries labeled with
764 * "shared-with-me" should be shown. 787 * "shared-with-me" should be shown.
765 */ 788 */
766 testcase.openSidebarSharedWithMe = function() { 789 testcase.openSidebarSharedWithMe = function() {
767 var appId; 790 var appId;
768 StepsRunner.run([ 791 StepsRunner.run([
769 function() { 792 function() {
770 var appState = {currentDirectoryPath: '/drive/root/'}; 793 setupAndWaitUntilReady(null, '/drive/root', this.next);
771 setupAndWaitUntilReady(appState, this.next);
772 }, 794 },
773 // Click the icon of the Shared With Me volume. 795 // Click the icon of the Shared With Me volume.
774 function(inAppId) { 796 function(inAppId) {
775 appId = inAppId; 797 appId = inAppId;
776 // Use the icon for a click target. 798 // Use the icon for a click target.
777 callRemoteTestUtil('selectVolume', 799 callRemoteTestUtil('selectVolume',
778 appId, 800 appId,
779 ['drive_shared_with_me'], this.next); 801 ['drive_shared_with_me'], this.next);
780 }, 802 },
781 // Wait until the file list is updated. 803 // Wait until the file list is updated.
(...skipping 20 matching lines...) Expand all
802 * Drive. 824 * Drive.
803 */ 825 */
804 testcase.autocomplete = function() { 826 testcase.autocomplete = function() {
805 var EXPECTED_AUTOCOMPLETE_LIST = [ 827 var EXPECTED_AUTOCOMPLETE_LIST = [
806 '\'hello\' - search Drive\n', 828 '\'hello\' - search Drive\n',
807 'hello.txt\n', 829 'hello.txt\n',
808 ]; 830 ];
809 831
810 StepsRunner.run([ 832 StepsRunner.run([
811 function() { 833 function() {
812 var appState = {currentDirectoryPath: '/drive/root'}; 834 setupAndWaitUntilReady(null, '/drive/root', this.next);
813 setupAndWaitUntilReady(appState, this.next);
814 }, 835 },
815 // Perform an auto complete test and wait until the list changes. 836 // Perform an auto complete test and wait until the list changes.
816 // TODO(mtomasz): Move the operation from test_util.js to tests_cases.js. 837 // TODO(mtomasz): Move the operation from test_util.js to tests_cases.js.
817 function(appId, list) { 838 function(appId, list) {
818 callRemoteTestUtil('performAutocompleteAndWait', 839 callRemoteTestUtil('performAutocompleteAndWait',
819 appId, 840 appId,
820 ['hello', EXPECTED_AUTOCOMPLETE_LIST.length], 841 ['hello', EXPECTED_AUTOCOMPLETE_LIST.length],
821 this.next); 842 this.next);
822 }, 843 },
823 // Verify the list contents. 844 // Verify the list contents.
(...skipping 20 matching lines...) Expand all
844 srcEntries, 865 srcEntries,
845 dstName, 866 dstName,
846 dstEntries) { 867 dstEntries) {
847 var srcContents = TestEntryInfo.getExpectedRows(srcEntries).sort(); 868 var srcContents = TestEntryInfo.getExpectedRows(srcEntries).sort();
848 var dstContents = TestEntryInfo.getExpectedRows(dstEntries).sort(); 869 var dstContents = TestEntryInfo.getExpectedRows(dstEntries).sort();
849 870
850 var appId; 871 var appId;
851 StepsRunner.run([ 872 StepsRunner.run([
852 // Set up File Manager. 873 // Set up File Manager.
853 function() { 874 function() {
854 var appState = {currentDirectoryPath: '/Downloads'}; 875 setupAndWaitUntilReady(null, '/Downloads', this.next);
855 setupAndWaitUntilReady(appState, this.next);
856 }, 876 },
857 // Select the source volume. 877 // Select the source volume.
858 function(inAppId) { 878 function(inAppId) {
859 appId = inAppId; 879 appId = inAppId;
860 callRemoteTestUtil( 880 callRemoteTestUtil(
861 'selectVolume', appId, [srcName], this.next); 881 'selectVolume', appId, [srcName], this.next);
862 }, 882 },
863 // Wait for the expected files to appear in the file list. 883 // Wait for the expected files to appear in the file list.
864 function(result) { 884 function(result) {
865 chrome.test.assertTrue(result); 885 chrome.test.assertTrue(result);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 962
943 /** 963 /**
944 * Test sharing dialog for a file or directory on Drive 964 * Test sharing dialog for a file or directory on Drive
945 * @param {string} path Path for a file or a directory to be shared. 965 * @param {string} path Path for a file or a directory to be shared.
946 */ 966 */
947 testcase.intermediate.share = function(path) { 967 testcase.intermediate.share = function(path) {
948 var appId; 968 var appId;
949 StepsRunner.run([ 969 StepsRunner.run([
950 // Set up File Manager. 970 // Set up File Manager.
951 function() { 971 function() {
952 var appState = {currentDirectoryPath: '/drive/root/'}; 972 setupAndWaitUntilReady(null, '/drive/root', this.next);
953 setupAndWaitUntilReady(appState, this.next);
954 }, 973 },
955 // Select the source file. 974 // Select the source file.
956 function(inAppId) { 975 function(inAppId) {
957 appId = inAppId; 976 appId = inAppId;
958 callRemoteTestUtil( 977 callRemoteTestUtil(
959 'selectFile', appId, [path], this.next); 978 'selectFile', appId, [path], this.next);
960 }, 979 },
961 // Wait for the share button. 980 // Wait for the share button.
962 function(result) { 981 function(result) {
963 chrome.test.assertTrue(result); 982 chrome.test.assertTrue(result);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 }, 1033 },
1015 // Check for Javascript errros. 1034 // Check for Javascript errros.
1016 function() { 1035 function() {
1017 checkIfNoErrorsOccured(this.next); 1036 checkIfNoErrorsOccured(this.next);
1018 } 1037 }
1019 ]); 1038 ]);
1020 }; 1039 };
1021 1040
1022 /** 1041 /**
1023 * Test utility for traverse tests. 1042 * Test utility for traverse tests.
1043 * @param {string} path Root path to be traversed.
1024 */ 1044 */
1025 testcase.intermediate.traverseDirectories = function(root) { 1045 testcase.intermediate.traverseDirectories = function(path) {
1026 var appId; 1046 var appId;
1027 StepsRunner.run([ 1047 StepsRunner.run([
1028 // Set up File Manager. 1048 // Set up File Manager. Do not add initial files.
1029 function() { 1049 function() {
1030 var appState = {currentDirectoryPath: root}; 1050 openNewWindow(null, path, this.next);
1031 callRemoteTestUtil('openMainWindow', null, [appState], this.next);
1032 }, 1051 },
1033 // Check the initial view. 1052 // Check the initial view.
1034 function(inAppId) { 1053 function(inAppId) {
1035 appId = inAppId; 1054 appId = inAppId;
1036 addEntries(['local', 'drive'], NESTED_ENTRY_SET, this.next); 1055 addEntries(['local', 'drive'], NESTED_ENTRY_SET, this.next);
1037 }, 1056 },
1038 function(result) { 1057 function(result) {
1039 chrome.test.assertTrue(result); 1058 chrome.test.assertTrue(result);
1040 callRemoteTestUtil('waitForFiles', 1059 callRemoteTestUtil('waitForFiles',
1041 appId, 1060 appId,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 testcase.executeDefaultTaskOnDrive = function(root) { 1197 testcase.executeDefaultTaskOnDrive = function(root) {
1179 testcase.intermediate.executeDefaultTask(true); 1198 testcase.intermediate.executeDefaultTask(true);
1180 }; 1199 };
1181 1200
1182 testcase.executeDefaultTaskOnDownloads = function(root) { 1201 testcase.executeDefaultTaskOnDownloads = function(root) {
1183 testcase.intermediate.executeDefaultTask(false); 1202 testcase.intermediate.executeDefaultTask(false);
1184 }; 1203 };
1185 1204
1186 /** 1205 /**
1187 * Tests executing the default task when there is only one task. 1206 * Tests executing the default task when there is only one task.
1207 * @param {boolean} drive Whether to test Drive or Downloads.
1188 */ 1208 */
1189 testcase.intermediate.executeDefaultTask = function(drive) { 1209 testcase.intermediate.executeDefaultTask = function(drive) {
1190 var root = drive ? '/drive/root' : '/Downloads'; 1210 var path = drive ? '/drive/root' : '/Downloads';
1191 var taskId = drive ? 'dummytaskid|drive|open-with' : 'dummytaskid|open-with' 1211 var taskId = drive ? 'dummytaskid|drive|open-with' : 'dummytaskid|open-with'
1192 var appId; 1212 var appId;
1193 StepsRunner.run([ 1213 StepsRunner.run([
1194 // Set up File Manager. 1214 // Set up File Manager.
1195 function() { 1215 function() {
1196 var appState = { 1216 setupAndWaitUntilReady(null, path, this.next);
1197 currentDirectoryPath: root
1198 };
1199 setupAndWaitUntilReady(appState, this.next);
1200 }, 1217 },
1201 // Override tasks list with a dummy task. 1218 // Override tasks list with a dummy task.
1202 function(inAppId, inFileListBefore) { 1219 function(inAppId, inFileListBefore) {
1203 appId = inAppId; 1220 appId = inAppId;
1204 1221
1205 callRemoteTestUtil( 1222 callRemoteTestUtil(
1206 'overrideTasks', 1223 'overrideTasks',
1207 appId, 1224 appId,
1208 [[ 1225 [[
1209 { 1226 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 function() { 1274 function() {
1258 chrome.test.sendMessage( 1275 chrome.test.sendMessage(
1259 JSON.stringify({name: 'getCwsWidgetContainerMockUrl'}), 1276 JSON.stringify({name: 'getCwsWidgetContainerMockUrl'}),
1260 this.next); 1277 this.next);
1261 }, 1278 },
1262 // Override the container URL with the mock. 1279 // Override the container URL with the mock.
1263 function(json) { 1280 function(json) {
1264 var data = JSON.parse(json); 1281 var data = JSON.parse(json);
1265 1282
1266 var appState = { 1283 var appState = {
1267 currentDirectoryPath: '/drive/root',
1268 suggestAppsDialogState: { 1284 suggestAppsDialogState: {
1269 overrideCwsContainerUrlForTest: data.url, 1285 overrideCwsContainerUrlForTest: data.url,
1270 overrideCwsContainerOriginForTest: data.origin 1286 overrideCwsContainerOriginForTest: data.origin
1271 } 1287 }
1272 }; 1288 };
1273 setupAndWaitUntilReady(appState, this.next); 1289 setupAndWaitUntilReady(appState, '/drive/root', this.next);
1274 }, 1290 },
1275 function(inAppId, inFileListBefore) { 1291 function(inAppId, inFileListBefore) {
1276 appId = inAppId; 1292 appId = inAppId;
1277 1293
1278 callRemoteTestUtil( 1294 callRemoteTestUtil(
1279 'selectFile', appId, ['unsupported.foo'], this.next); 1295 'selectFile', appId, ['unsupported.foo'], this.next);
1280 }, 1296 },
1281 // Double-click the file. 1297 // Double-click the file.
1282 function(result) { 1298 function(result) {
1283 chrome.test.assertTrue(result); 1299 chrome.test.assertTrue(result);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 }; 1387 };
1372 1388
1373 /** 1389 /**
1374 * Tests hiding the search box. 1390 * Tests hiding the search box.
1375 */ 1391 */
1376 testcase.hideSearchBox = function() { 1392 testcase.hideSearchBox = function() {
1377 var appId; 1393 var appId;
1378 StepsRunner.run([ 1394 StepsRunner.run([
1379 // Set up File Manager. 1395 // Set up File Manager.
1380 function() { 1396 function() {
1381 var appState = {currentDirectoryPath: '/Downloads'}; 1397 setupAndWaitUntilReady(null, '/Downloads', this.next);
1382 setupAndWaitUntilReady(appState, this.next);
1383 }, 1398 },
1384 // Resize the window. 1399 // Resize the window.
1385 function(inAppId, inFileListBefore) { 1400 function(inAppId, inFileListBefore) {
1386 appId = inAppId; 1401 appId = inAppId;
1387 callRemoteTestUtil('resizeWindow', appId, [100, 100], this.next); 1402 callRemoteTestUtil('resizeWindow', appId, [100, 100], this.next);
1388 }, 1403 },
1389 // Wait for the style change. 1404 // Wait for the style change.
1390 function(result) { 1405 function(result) {
1391 chrome.test.assertTrue(result); 1406 chrome.test.assertTrue(result);
1392 callRemoteTestUtil('waitForStyles', 1407 callRemoteTestUtil('waitForStyles',
(...skipping 19 matching lines...) Expand all
1412 var EXPECTED_FILES = TestEntryInfo.getExpectedRows([ 1427 var EXPECTED_FILES = TestEntryInfo.getExpectedRows([
1413 ENTRIES.world, 1428 ENTRIES.world,
1414 ENTRIES.photos, 1429 ENTRIES.photos,
1415 ENTRIES.desktop, 1430 ENTRIES.desktop,
1416 ENTRIES.hello, 1431 ENTRIES.hello,
1417 ENTRIES.beautiful 1432 ENTRIES.beautiful
1418 ]); 1433 ]);
1419 StepsRunner.run([ 1434 StepsRunner.run([
1420 // Set up File Manager. 1435 // Set up File Manager.
1421 function() { 1436 function() {
1422 var appState = {currentDirectoryPath: '/Downloads'}; 1437 setupAndWaitUntilReady(null, '/Downloads', this.next);
1423 setupAndWaitUntilReady(appState, this.next);
1424 }, 1438 },
1425 // Sort by name. 1439 // Sort by name.
1426 function(inAppId) { 1440 function(inAppId) {
1427 appId = inAppId; 1441 appId = inAppId;
1428 callRemoteTestUtil('fakeMouseClick', 1442 callRemoteTestUtil('fakeMouseClick',
1429 appId, 1443 appId,
1430 ['.table-header-cell:nth-of-type(1)'], 1444 ['.table-header-cell:nth-of-type(1)'],
1431 this.next); 1445 this.next);
1432 }, 1446 },
1433 // Check the sorted style of the header. 1447 // Check the sorted style of the header.
(...skipping 19 matching lines...) Expand all
1453 }, 1467 },
1454 // Check the sorted files. 1468 // Check the sorted files.
1455 function() { 1469 function() {
1456 callRemoteTestUtil('waitForFiles', 1470 callRemoteTestUtil('waitForFiles',
1457 appId, 1471 appId,
1458 [EXPECTED_FILES, {orderCheck: true}], 1472 [EXPECTED_FILES, {orderCheck: true}],
1459 this.next); 1473 this.next);
1460 }, 1474 },
1461 // Open another window, where the sorted column should be restored. 1475 // Open another window, where the sorted column should be restored.
1462 function() { 1476 function() {
1463 var appState = {currentDirectoryPath: '/Downloads'}; 1477 setupAndWaitUntilReady(null, '/Downloads', this.next);
1464 setupAndWaitUntilReady(appState, this.next);
1465 }, 1478 },
1466 // Check the sorted style of the header. 1479 // Check the sorted style of the header.
1467 function(inAppId) { 1480 function(inAppId) {
1468 appId = inAppId; 1481 appId = inAppId;
1469 callRemoteTestUtil('waitForElement', 1482 callRemoteTestUtil('waitForElement',
1470 appId, 1483 appId,
1471 ['.table-header-sort-image-desc'], 1484 ['.table-header-sort-image-desc'],
1472 this.next); 1485 this.next);
1473 }, 1486 },
1474 // Check the sorted files. 1487 // Check the sorted files.
(...skipping 11 matching lines...) Expand all
1486 }; 1499 };
1487 1500
1488 /** 1501 /**
1489 * Tests restoring the current view (the file list or the thumbnail grid). 1502 * Tests restoring the current view (the file list or the thumbnail grid).
1490 */ 1503 */
1491 testcase.restoreCurrentView = function() { 1504 testcase.restoreCurrentView = function() {
1492 var appId; 1505 var appId;
1493 StepsRunner.run([ 1506 StepsRunner.run([
1494 // Set up File Manager. 1507 // Set up File Manager.
1495 function() { 1508 function() {
1496 var appState = {currentDirectoryPath: '/Downloads'}; 1509 setupAndWaitUntilReady(null, '/Downloads', this.next);
1497 setupAndWaitUntilReady(appState, this.next);
1498 }, 1510 },
1499 // Check the initial view. 1511 // Check the initial view.
1500 function(inAppId) { 1512 function(inAppId) {
1501 appId = inAppId; 1513 appId = inAppId;
1502 callRemoteTestUtil('waitForElement', 1514 callRemoteTestUtil('waitForElement',
1503 appId, 1515 appId,
1504 ['.thumbnail-grid[hidden]'], 1516 ['.thumbnail-grid[hidden]'],
1505 this.next); 1517 this.next);
1506 }, 1518 },
1507 // Opens the gear menu. 1519 // Opens the gear menu.
(...skipping 13 matching lines...) Expand all
1521 // Check the new current view. 1533 // Check the new current view.
1522 function(result) { 1534 function(result) {
1523 chrome.test.assertTrue(result); 1535 chrome.test.assertTrue(result);
1524 callRemoteTestUtil('waitForElement', 1536 callRemoteTestUtil('waitForElement',
1525 appId, 1537 appId,
1526 ['.detail-table[hidden]'], 1538 ['.detail-table[hidden]'],
1527 this.next); 1539 this.next);
1528 }, 1540 },
1529 // Open another window, where the current view is restored. 1541 // Open another window, where the current view is restored.
1530 function() { 1542 function() {
1531 var appState = {currentDirectoryPath: '/Downloads'}; 1543 openNewWindow(null, '/Downloads', this.next);
1532 callRemoteTestUtil('openMainWindow', null, [appState], this.next);
1533 }, 1544 },
1534 // Check the current view. 1545 // Check the current view.
1535 function(inAppId) { 1546 function(inAppId) {
1536 appId = inAppId; 1547 appId = inAppId;
1537 callRemoteTestUtil('waitForElement', 1548 callRemoteTestUtil('waitForElement',
1538 appId, 1549 appId,
1539 ['.detail-table[hidden]'], 1550 ['.detail-table[hidden]'],
1540 this.next); 1551 this.next);
1541 }, 1552 },
1542 // Check the error. 1553 // Check the error.
1543 function() { 1554 function() {
1544 checkIfNoErrorsOccured(this.next); 1555 checkIfNoErrorsOccured(this.next);
1545 } 1556 }
1546 ]); 1557 ]);
1547 }; 1558 };
1548 1559
1549 /** 1560 /**
1550 * Tests keyboard operations of the navigation list. 1561 * Tests keyboard operations of the navigation list.
1551 */ 1562 */
1552 testcase.traverseNavigationList = function() { 1563 testcase.traverseNavigationList = function() {
1553 var appId; 1564 var appId;
1554 StepsRunner.run([ 1565 StepsRunner.run([
1555 // Set up File Manager. 1566 // Set up File Manager.
1556 function() { 1567 function() {
1557 var appState = {currentDirectoryPath: '/drive/root'}; 1568 setupAndWaitUntilReady(null, '/drive/root', this.next);
1558 setupAndWaitUntilReady(appState, this.next);
1559 }, 1569 },
1560 // Wait until Google Drive is selected. 1570 // Wait until Google Drive is selected.
1561 function(inAppId) { 1571 function(inAppId) {
1562 appId = inAppId; 1572 appId = inAppId;
1563 callRemoteTestUtil( 1573 callRemoteTestUtil(
1564 'waitForElement', 1574 'waitForElement',
1565 appId, 1575 appId,
1566 ['#navigation-list > .root-item > ' + 1576 ['#navigation-list > .root-item > ' +
1567 '.volume-icon[volume-type-icon="drive"]'], 1577 '.volume-icon[volume-type-icon="drive"]'],
1568 this.next); 1578 this.next);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 1653
1644 /** 1654 /**
1645 * Tests restoring geometry of the Files app. 1655 * Tests restoring geometry of the Files app.
1646 */ 1656 */
1647 testcase.restoreGeometry = function() { 1657 testcase.restoreGeometry = function() {
1648 var appId; 1658 var appId;
1649 var appId2; 1659 var appId2;
1650 StepsRunner.run([ 1660 StepsRunner.run([
1651 // Set up File Manager. 1661 // Set up File Manager.
1652 function() { 1662 function() {
1653 var appState = {currentDirectoryPath: '/Downloads'}; 1663 setupAndWaitUntilReady(null, '/Downloads', this.next);
1654 setupAndWaitUntilReady(appState, this.next);
1655 }, 1664 },
1656 // Resize the window to minimal dimensions. 1665 // Resize the window to minimal dimensions.
1657 function(inAppId) { 1666 function(inAppId) {
1658 appId = inAppId; 1667 appId = inAppId;
1659 callRemoteTestUtil( 1668 callRemoteTestUtil(
1660 'resizeWindow', appId, [640, 480], this.next); 1669 'resizeWindow', appId, [640, 480], this.next);
1661 }, 1670 },
1662 // Check the current window's size. 1671 // Check the current window's size.
1663 function(inAppId) { 1672 function(inAppId) {
1664 callRemoteTestUtil('waitForWindowGeometry', 1673 callRemoteTestUtil('waitForWindowGeometry',
1665 appId, 1674 appId,
1666 [640, 480], 1675 [640, 480],
1667 this.next); 1676 this.next);
1668 }, 1677 },
1669 // Enlarge the window by 10 pixels. 1678 // Enlarge the window by 10 pixels.
1670 function(result) { 1679 function(result) {
1671 callRemoteTestUtil( 1680 callRemoteTestUtil(
1672 'resizeWindow', appId, [650, 490], this.next); 1681 'resizeWindow', appId, [650, 490], this.next);
1673 }, 1682 },
1674 // Check the current window's size. 1683 // Check the current window's size.
1675 function() { 1684 function() {
1676 callRemoteTestUtil('waitForWindowGeometry', 1685 callRemoteTestUtil('waitForWindowGeometry',
1677 appId, 1686 appId,
1678 [650, 490], 1687 [650, 490],
1679 this.next); 1688 this.next);
1680 }, 1689 },
1681 // Open another window, where the current view is restored. 1690 // Open another window, where the current view is restored.
1682 function() { 1691 function() {
1683 var appState = {currentDirectoryPath: '/Downloads'}; 1692 openNewWindow(null, '/Downloads', this.next);
1684 setupAndWaitUntilReady(appState, this.next);
1685 }, 1693 },
1686 // Check the next window's size. 1694 // Check the next window's size.
1687 function(inAppId) { 1695 function(inAppId) {
1688 appId2 = inAppId; 1696 appId2 = inAppId;
1689 callRemoteTestUtil('waitForWindowGeometry', 1697 callRemoteTestUtil('waitForWindowGeometry',
1690 appId2, 1698 appId2,
1691 [650, 490], 1699 [650, 490],
1692 this.next); 1700 this.next);
1693 }, 1701 },
1694 // Check for errors. 1702 // Check for errors.
(...skipping 16 matching lines...) Expand all
1711 testcase.intermediate.traverseDirectories.bind(null, '/drive/root'); 1719 testcase.intermediate.traverseDirectories.bind(null, '/drive/root');
1712 1720
1713 /** 1721 /**
1714 * Tests the focus behavior of the search box. 1722 * Tests the focus behavior of the search box.
1715 */ 1723 */
1716 testcase.searchBoxFocus = function() { 1724 testcase.searchBoxFocus = function() {
1717 var appId; 1725 var appId;
1718 StepsRunner.run([ 1726 StepsRunner.run([
1719 // Set up File Manager. 1727 // Set up File Manager.
1720 function() { 1728 function() {
1721 var appState = {currentDirectoryPath: '/drive/root'}; 1729 setupAndWaitUntilReady(null, '/drive/root', this.next);
1722 setupAndWaitUntilReady(appState, this.next);
1723 }, 1730 },
1724 // Check that the file list has the focus on launch. 1731 // Check that the file list has the focus on launch.
1725 function(inAppId) { 1732 function(inAppId) {
1726 appId = inAppId; 1733 appId = inAppId;
1727 callRemoteTestUtil( 1734 callRemoteTestUtil(
1728 'waitForElement', appId, ['#file-list:focus'], this.next); 1735 'waitForElement', appId, ['#file-list:focus'], this.next);
1729 }, 1736 },
1730 // Press the Ctrl-F key. 1737 // Press the Ctrl-F key.
1731 function(element) { 1738 function(element) {
1732 callRemoteTestUtil('fakeKeyDown', 1739 callRemoteTestUtil('fakeKeyDown',
(...skipping 28 matching lines...) Expand all
1761 }; 1768 };
1762 1769
1763 /** 1770 /**
1764 * Tests if a thumbnail for the selected item shows up in the preview panel. 1771 * Tests if a thumbnail for the selected item shows up in the preview panel.
1765 * This thumbnail is fetched via the image loader. 1772 * This thumbnail is fetched via the image loader.
1766 */ 1773 */
1767 testcase.thumbnailsDownloads = function() { 1774 testcase.thumbnailsDownloads = function() {
1768 var appId; 1775 var appId;
1769 StepsRunner.run([ 1776 StepsRunner.run([
1770 function() { 1777 function() {
1771 var appState = {currentDirectoryPath: '/Downloads'}; 1778 setupAndWaitUntilReady(null, '/Downloads', this.next);
1772 setupAndWaitUntilReady(appState, this.next);
1773 }, 1779 },
1774 // Select the image. 1780 // Select the image.
1775 function(inAppId) { 1781 function(inAppId) {
1776 appId = inAppId; 1782 appId = inAppId;
1777 callRemoteTestUtil('selectFile', 1783 callRemoteTestUtil('selectFile',
1778 appId, 1784 appId,
1779 ['My Desktop Background.png'], 1785 ['My Desktop Background.png'],
1780 this.next); 1786 this.next);
1781 }, 1787 },
1782 // Wait until the thumbnail shows up. 1788 // Wait until the thumbnail shows up.
1783 function(result) { 1789 function(result) {
1784 chrome.test.assertTrue(result); 1790 chrome.test.assertTrue(result);
1785 callRemoteTestUtil('waitForElement', 1791 callRemoteTestUtil('waitForElement',
1786 appId, 1792 appId,
1787 ['.preview-thumbnails .img-container img'], 1793 ['.preview-thumbnails .img-container img'],
1788 this.next); 1794 this.next);
1789 }, 1795 },
1790 // Verify the thumbnail. 1796 // Verify the thumbnail.
1791 function(element) { 1797 function(element) {
1792 chrome.test.assertTrue(element.attributes.src.indexOf( 1798 chrome.test.assertTrue(element.attributes.src.indexOf(
1793 'data:image/jpeg') === 0); 1799 'data:image/jpeg') === 0);
1794 checkIfNoErrorsOccured(this.next); 1800 checkIfNoErrorsOccured(this.next);
1795 } 1801 }
1796 ]); 1802 ]);
1797 }; 1803 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698