OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 GEN_INCLUDE(['options_browsertest_base.js']); | |
6 GEN('#include "chrome/browser/ui/webui/options/options_browsertest.h"'); | 5 GEN('#include "chrome/browser/ui/webui/options/options_browsertest.h"'); |
7 | 6 |
8 /** @const */ var SUPERVISED_USERS_PREF = 'profile.managed_users'; | 7 /** @const */ var SUPERVISED_USERS_PREF = 'profile.managed_users'; |
9 | 8 |
10 /** | 9 /** |
11 * Wait for the method specified by |methodName|, on the |object| object, to be | 10 * Wait for the method specified by |methodName|, on the |object| object, to be |
12 * called, then execute |afterFunction|. | 11 * called, then execute |afterFunction|. |
13 * @param {*} object Object with callable property named |methodName|. | 12 * @param {*} object Object with callable property named |methodName|. |
14 * @param {string} methodName The name of the property on |object| to use as a | 13 * @param {string} methodName The name of the property on |object| to use as a |
15 * callback. | 14 * callback. |
(...skipping 21 matching lines...) Expand all Loading... |
37 } | 36 } |
38 | 37 |
39 /** | 38 /** |
40 * TestFixture for OptionsPage WebUI testing. | 39 * TestFixture for OptionsPage WebUI testing. |
41 * @extends {testing.Test} | 40 * @extends {testing.Test} |
42 * @constructor | 41 * @constructor |
43 */ | 42 */ |
44 function OptionsWebUITest() {} | 43 function OptionsWebUITest() {} |
45 | 44 |
46 OptionsWebUITest.prototype = { | 45 OptionsWebUITest.prototype = { |
47 __proto__: OptionsBrowsertestBase.prototype, | 46 __proto__: testing.Test.prototype, |
| 47 |
| 48 /** @override */ |
| 49 accessibilityIssuesAreErrors: true, |
| 50 |
| 51 /** @override */ |
| 52 setUp: function() { |
| 53 // user-image-stream is a streaming video element used for capturing a |
| 54 // user image during OOBE. |
| 55 this.accessibilityAuditConfig.ignoreSelectors('videoWithoutCaptions', |
| 56 '.user-image-stream'); |
| 57 }, |
48 | 58 |
49 /** | 59 /** |
50 * Browse to the options page & call our preLoad(). | 60 * Browse to the options page & call our preLoad(). |
51 * @override | |
52 */ | 61 */ |
53 browsePreload: 'chrome://settings-frame', | 62 browsePreload: 'chrome://settings-frame', |
54 | 63 |
55 /** @override */ | |
56 isAsync: true, | 64 isAsync: true, |
57 | 65 |
58 /** | 66 /** |
59 * Register a mock handler to ensure expectations are met and options pages | 67 * Register a mock handler to ensure expectations are met and options pages |
60 * behave correctly. | 68 * behave correctly. |
61 */ | 69 */ |
62 preLoad: function() { | 70 preLoad: function() { |
63 this.makeAndRegisterMockHandler( | 71 this.makeAndRegisterMockHandler( |
64 ['defaultZoomFactorAction', | 72 ['defaultZoomFactorAction', |
65 'fetchPrefs', | 73 'fetchPrefs', |
66 'observePrefs', | 74 'observePrefs', |
67 'setBooleanPref', | 75 'setBooleanPref', |
68 'setIntegerPref', | 76 'setIntegerPref', |
69 'setDoublePref', | 77 'setDoublePref', |
70 'setStringPref', | 78 'setStringPref', |
71 'setObjectPref', | 79 'setObjectPref', |
72 'clearPref', | 80 'clearPref', |
73 'coreOptionsUserMetricsAction', | 81 'coreOptionsUserMetricsAction', |
74 ]); | 82 ]); |
75 | 83 |
76 // Register stubs for methods expected to be called before/during tests. | 84 // Register stubs for methods expected to be called before/during tests. |
77 // Specific expectations can be made in the tests themselves. | 85 // Specific expectations can be made in the tests themselves. |
78 this.mockHandler.stubs().fetchPrefs(ANYTHING); | 86 this.mockHandler.stubs().fetchPrefs(ANYTHING); |
79 this.mockHandler.stubs().observePrefs(ANYTHING); | 87 this.mockHandler.stubs().observePrefs(ANYTHING); |
80 this.mockHandler.stubs().coreOptionsUserMetricsAction(ANYTHING); | 88 this.mockHandler.stubs().coreOptionsUserMetricsAction(ANYTHING); |
81 }, | 89 }, |
82 }; | 90 }; |
83 | 91 |
84 /** | |
85 * Wait for overlay-container-1 and overlay-container-2 to be hidden. | |
86 */ | |
87 function waitForOverlaysToHide() { | |
88 var overlay1 = $('overlay-container-1'); | |
89 var overlay2 = $('overlay-container-2'); | |
90 | |
91 document.addEventListener('webkitTransitionEnd', function f(e) { | |
92 if ((e.target.id == overlay1.id || e.target.id == overlay2.id) && | |
93 overlay1.hidden && overlay2.hidden) { | |
94 document.removeEventListener(f, 'webkitTransitionEnd'); | |
95 testDone(); | |
96 } | |
97 }); | |
98 | |
99 if (!overlay1.hidden) | |
100 ensureTransitionEndEvent(overlay1, 500); | |
101 if (!overlay2.hidden) | |
102 ensureTransitionEndEvent(overlay2, 500); | |
103 } | |
104 | |
105 // Crashes on Mac only. See http://crbug.com/79181 | 92 // Crashes on Mac only. See http://crbug.com/79181 |
106 GEN('#if defined(OS_MACOSX)'); | 93 GEN('#if defined(OS_MACOSX)'); |
107 GEN('#define MAYBE_testSetBooleanPrefTriggers ' + | 94 GEN('#define MAYBE_testSetBooleanPrefTriggers ' + |
108 'DISABLED_testSetBooleanPrefTriggers'); | 95 'DISABLED_testSetBooleanPrefTriggers'); |
109 GEN('#else'); | 96 GEN('#else'); |
110 GEN('#define MAYBE_testSetBooleanPrefTriggers testSetBooleanPrefTriggers'); | 97 GEN('#define MAYBE_testSetBooleanPrefTriggers testSetBooleanPrefTriggers'); |
111 GEN('#endif // defined(OS_MACOSX)'); | 98 GEN('#endif // defined(OS_MACOSX)'); |
112 | 99 |
113 TEST_F('OptionsWebUITest', 'MAYBE_testSetBooleanPrefTriggers', function() { | 100 TEST_F('OptionsWebUITest', 'MAYBE_testSetBooleanPrefTriggers', function() { |
114 // TODO(dtseng): make generic to click all buttons. | 101 // TODO(dtseng): make generic to click all buttons. |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 /** | 356 /** |
370 * TestFixture for OptionsPage WebUI testing including tab history and support | 357 * TestFixture for OptionsPage WebUI testing including tab history and support |
371 * for preference manipulation. If you don't need the features in the C++ | 358 * for preference manipulation. If you don't need the features in the C++ |
372 * fixture, use the simpler OptionsWebUITest (above) instead. | 359 * fixture, use the simpler OptionsWebUITest (above) instead. |
373 * @extends {testing.Test} | 360 * @extends {testing.Test} |
374 * @constructor | 361 * @constructor |
375 */ | 362 */ |
376 function OptionsWebUIExtendedTest() {} | 363 function OptionsWebUIExtendedTest() {} |
377 | 364 |
378 OptionsWebUIExtendedTest.prototype = { | 365 OptionsWebUIExtendedTest.prototype = { |
379 __proto__: OptionsWebUITest.prototype, | 366 __proto__: testing.Test.prototype, |
| 367 |
| 368 /** @override */ |
| 369 browsePreload: 'chrome://settings-frame', |
380 | 370 |
381 /** @override */ | 371 /** @override */ |
382 typedefCppFixture: 'OptionsBrowserTest', | 372 typedefCppFixture: 'OptionsBrowserTest', |
383 | 373 |
384 testGenPreamble: function() { | 374 testGenPreamble: function() { |
385 // Start with no supervised users managed by this profile. | 375 // Start with no supervised users managed by this profile. |
386 GEN(' ClearPref("' + SUPERVISED_USERS_PREF + '");'); | 376 GEN(' ClearPref("' + SUPERVISED_USERS_PREF + '");'); |
387 }, | 377 }, |
388 | 378 |
| 379 /** @override */ |
| 380 isAsync: true, |
| 381 |
| 382 /** @override */ |
| 383 setUp: function() { |
| 384 // user-image-stream is a streaming video element used for capturing a |
| 385 // user image during OOBE. |
| 386 this.accessibilityAuditConfig.ignoreSelectors('videoWithoutCaptions', |
| 387 '.user-image-stream'); |
| 388 }, |
| 389 |
389 /** | 390 /** |
390 * Asserts that two non-nested arrays are equal. The arrays must contain only | 391 * Asserts that two non-nested arrays are equal. The arrays must contain only |
391 * plain data types, no nested arrays or other objects. | 392 * plain data types, no nested arrays or other objects. |
392 * @param {Array} expected An array of expected values. | 393 * @param {Array} expected An array of expected values. |
393 * @param {Array} result An array of actual values. | 394 * @param {Array} result An array of actual values. |
394 * @param {boolean} doSort If true, the arrays will be sorted before being | 395 * @param {boolean} doSort If true, the arrays will be sorted before being |
395 * compared. | 396 * compared. |
396 * @param {string} description A brief description for the array of actual | 397 * @param {string} description A brief description for the array of actual |
397 * values, to use in an error message if the arrays differ. | 398 * values, to use in an error message if the arrays differ. |
398 * @private | 399 * @private |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 PageManager.closeOverlay(); | 669 PageManager.closeOverlay(); |
669 self.verifyOpenPages_(['settings', 'languages']); | 670 self.verifyOpenPages_(['settings', 'languages']); |
670 self.verifyHistory_( | 671 self.verifyHistory_( |
671 ['', 'languages', 'addLanguage', 'languages'], | 672 ['', 'languages', 'addLanguage', 'languages'], |
672 function() { | 673 function() { |
673 // Close the layer-1 overlay. | 674 // Close the layer-1 overlay. |
674 PageManager.closeOverlay(); | 675 PageManager.closeOverlay(); |
675 self.verifyOpenPages_(['settings'], ''); | 676 self.verifyOpenPages_(['settings'], ''); |
676 self.verifyHistory_( | 677 self.verifyHistory_( |
677 ['', 'languages', 'addLanguage', 'languages', ''], | 678 ['', 'languages', 'addLanguage', 'languages', ''], |
678 waitForOverlaysToHide); | 679 testDone); |
679 }); | 680 }); |
680 }); | 681 }); |
681 }); | 682 }); |
682 | 683 |
683 // Hashes are maintained separately for each page and are preserved when | 684 // Hashes are maintained separately for each page and are preserved when |
684 // overlays close. | 685 // overlays close. |
685 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayWithHashes', function() { | 686 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayWithHashes', function() { |
686 // Open an overlay on top of the search page. | 687 // Open an overlay on top of the search page. |
687 PageManager.showPageByName('search', true, {hash: '#1'}); | 688 PageManager.showPageByName('search', true, {hash: '#1'}); |
688 this.verifyOpenPages_(['settings', 'search'], 'search#1'); | 689 this.verifyOpenPages_(['settings', 'search'], 'search#1'); |
(...skipping 11 matching lines...) Expand all Loading... |
700 this.verifyOpenPages_(['settings', 'search', 'languages'], 'languages#2'); | 701 this.verifyOpenPages_(['settings', 'search', 'languages'], 'languages#2'); |
701 this.verifyHistory_( | 702 this.verifyHistory_( |
702 ['', 'search#1', 'languages#2', 'addLanguage#3', 'languages#2'], | 703 ['', 'search#1', 'languages#2', 'addLanguage#3', 'languages#2'], |
703 function() { | 704 function() { |
704 // Close the layer-1 overlay. | 705 // Close the layer-1 overlay. |
705 PageManager.closeOverlay(); | 706 PageManager.closeOverlay(); |
706 this.verifyOpenPages_(['settings', 'search'], 'search#1'); | 707 this.verifyOpenPages_(['settings', 'search'], 'search#1'); |
707 this.verifyHistory_( | 708 this.verifyHistory_( |
708 ['', 'search#1', 'languages#2', 'addLanguage#3', 'languages#2', | 709 ['', 'search#1', 'languages#2', 'addLanguage#3', 'languages#2', |
709 'search#1'], | 710 'search#1'], |
710 waitForOverlaysToHide); | 711 testDone); |
711 }.bind(this)); | 712 }.bind(this)); |
712 }.bind(this)); | 713 }.bind(this)); |
713 }); | 714 }); |
714 | 715 |
715 // Test that closing an overlay that did not push history when opening does not | 716 // Test that closing an overlay that did not push history when opening does not |
716 // again push history. | 717 // again push history. |
717 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayNoHistory', function() { | 718 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayNoHistory', function() { |
718 // Open the do not track confirmation prompt. | 719 // Open the do not track confirmation prompt. |
719 PageManager.showPageByName('doNotTrackConfirm', false); | 720 PageManager.showPageByName('doNotTrackConfirm', false); |
720 | 721 |
721 // Opening the prompt does not add to the history. | 722 // Opening the prompt does not add to the history. |
722 this.verifyHistory_([''], function() { | 723 this.verifyHistory_([''], function() { |
723 // Close the overlay. | 724 // Close the overlay. |
724 PageManager.closeOverlay(); | 725 PageManager.closeOverlay(); |
725 // Still no history changes. | 726 // Still no history changes. |
726 this.verifyHistory_([''], waitForOverlaysToHide); | 727 this.verifyHistory_([''], testDone); |
727 }.bind(this)); | 728 }.bind(this)); |
728 }); | 729 }); |
729 | 730 |
730 // Make sure an overlay isn't closed (even temporarily) when another overlay is | 731 // Make sure an overlay isn't closed (even temporarily) when another overlay is |
731 // opened on top. | 732 // opened on top. |
732 TEST_F('OptionsWebUIExtendedTest', 'OverlayAboveNoReset', function() { | 733 TEST_F('OptionsWebUIExtendedTest', 'OverlayAboveNoReset', function() { |
733 // Open a layer-1 overlay. | 734 // Open a layer-1 overlay. |
734 PageManager.showPageByName('languages', true); | 735 PageManager.showPageByName('languages', true); |
735 this.verifyOpenPages_(['settings', 'languages']); | 736 this.verifyOpenPages_(['settings', 'languages']); |
736 | 737 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 __proto__: OptionsWebUIExtendedTest.prototype, | 873 __proto__: OptionsWebUIExtendedTest.prototype, |
873 | 874 |
874 /** @override */ | 875 /** @override */ |
875 browsePreload: 'chrome://settings-frame/nonexistantPage', | 876 browsePreload: 'chrome://settings-frame/nonexistantPage', |
876 }; | 877 }; |
877 | 878 |
878 TEST_F('OptionsWebUIRedirectTest', 'TestURL', function() { | 879 TEST_F('OptionsWebUIRedirectTest', 'TestURL', function() { |
879 assertEquals('chrome://settings-frame/', document.location.href); | 880 assertEquals('chrome://settings-frame/', document.location.href); |
880 this.verifyHistory_([''], testDone); | 881 this.verifyHistory_([''], testDone); |
881 }); | 882 }); |
OLD | NEW |