OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 * TestFixture for OptionsPage WebUI testing. | 6 * TestFixture for OptionsPage WebUI testing. |
7 * @extends {testing.Test} | 7 * @extends {testing.Test} |
8 * @constructor | 8 * @constructor |
9 */ | 9 */ |
10 function OptionsWebUITest() {} | 10 function OptionsWebUITest() {} |
11 | 11 |
12 OptionsWebUITest.prototype = { | 12 OptionsWebUITest.prototype = { |
13 __proto__: testing.Test.prototype, | 13 __proto__: testing.Test.prototype, |
14 | 14 |
15 /** | 15 /** |
16 * Browse to the options page & call our preLoad(). | 16 * Browse to the options page & call our preLoad(). |
17 */ | 17 */ |
18 browsePreload: 'chrome://settings', | 18 browsePreload: 'chrome://settings', |
19 | 19 |
20 /** | 20 /** |
21 * Register a mock handler to ensure expectations are met and options pages | 21 * Register a mock handler to ensure expectations are met and options pages |
22 * behave correctly. | 22 * behave correctly. |
23 */ | 23 */ |
24 preLoad: function() { | 24 preLoad: function() { |
25 this.makeAndRegisterMockHandler( | 25 this.makeAndRegisterMockHandler( |
26 ['coreOptionsInitialize', | 26 ['coreOptionsInitialize', |
| 27 'defaultZoomFactorAction', |
27 'fetchPrefs', | 28 'fetchPrefs', |
28 'observePrefs', | 29 'observePrefs', |
29 'setBooleanPref', | 30 'setBooleanPref', |
30 'setIntegerPref', | 31 'setIntegerPref', |
31 'setDoublePref', | 32 'setDoublePref', |
32 'setStringPref', | 33 'setStringPref', |
33 'setObjectPref', | 34 'setObjectPref', |
34 'clearPref', | 35 'clearPref', |
35 'coreOptionsUserMetricsAction', | 36 'coreOptionsUserMetricsAction', |
36 // TODO(scr): Handle this new message: | 37 // TODO(scr): Handle this new message: |
(...skipping 27 matching lines...) Expand all Loading... |
64 // Note: this expectation is checked in testing::Test::tearDown. | 65 // Note: this expectation is checked in testing::Test::tearDown. |
65 this.mockHandler.expects(once()).setBooleanPref(trueListValue); | 66 this.mockHandler.expects(once()).setBooleanPref(trueListValue); |
66 | 67 |
67 // Cause the handler to be called. | 68 // Cause the handler to be called. |
68 showHomeButton.click(); | 69 showHomeButton.click(); |
69 showHomeButton.blur(); | 70 showHomeButton.blur(); |
70 }); | 71 }); |
71 | 72 |
72 // Not meant to run on ChromeOS at this time. | 73 // Not meant to run on ChromeOS at this time. |
73 // Not finishing in windows. http://crbug.com/81723 | 74 // Not finishing in windows. http://crbug.com/81723 |
74 GEN('#if defined(OS_CHROMEOS) || defined(OS_MACOSX) || defined(OS_WIN)'); | 75 // TODO(csilv): Redo logic for uber page. |
75 GEN('#define MAYBE_testRefreshStaysOnCurrentPage \\'); | 76 TEST_F('OptionsWebUITest', 'DISABLED_testRefreshStaysOnCurrentPage', |
76 GEN(' DISABLED_testRefreshStaysOnCurrentPage'); | 77 function() { |
77 GEN('#else'); | |
78 GEN('#define MAYBE_testRefreshStaysOnCurrentPage ' + | |
79 'testRefreshStaysOnCurrentPage'); | |
80 GEN('#endif'); | |
81 | |
82 TEST_F('OptionsWebUITest', 'MAYBE_testRefreshStaysOnCurrentPage', function() { | |
83 var item = $('advancedPageNav'); | 78 var item = $('advancedPageNav'); |
84 item.onclick(); | 79 item.onclick(); |
85 window.location.reload(); | 80 window.location.reload(); |
86 var pageInstance = AdvancedOptions.getInstance(); | 81 var pageInstance = AdvancedOptions.getInstance(); |
87 var topPage = OptionsPage.getTopmostVisiblePage(); | 82 var topPage = OptionsPage.getTopmostVisiblePage(); |
88 var expectedTitle = pageInstance.title; | 83 var expectedTitle = pageInstance.title; |
89 var actualTitle = document.title; | 84 var actualTitle = document.title; |
90 assertEquals("chrome://settings/advanced", document.location.href); | 85 assertEquals("chrome://settings/advanced", document.location.href); |
91 assertEquals(expectedTitle, actualTitle); | 86 assertEquals(expectedTitle, actualTitle); |
92 assertEquals(pageInstance, topPage); | 87 assertEquals(pageInstance, topPage); |
93 }); | 88 }); |
| 89 |
| 90 /** |
| 91 * Test the default zoom factor select element. |
| 92 */ |
| 93 TEST_F('OptionsWebUITest', 'testDefaultZoomFactor', function() { |
| 94 // The expected minimum length of the |defaultZoomFactor| element. |
| 95 var defaultZoomFactorMinimumLength = 10; |
| 96 // Verify that the zoom factor element exists. |
| 97 var defaultZoomFactor = $('defaultZoomFactor'); |
| 98 assertNotEquals(defaultZoomFactor, null); |
| 99 |
| 100 // Verify that the zoom factor element has a reasonable number of choices. |
| 101 expectGE(defaultZoomFactor.options.length, defaultZoomFactorMinimumLength); |
| 102 |
| 103 // Simulate a change event, selecting the highest zoom value. Verify that |
| 104 // the javascript handler was invoked once. |
| 105 this.mockHandler.expects(once()).defaultZoomFactorAction(NOT_NULL). |
| 106 will(callFunction(function() { })); |
| 107 defaultZoomFactor.selectedIndex = defaultZoomFactor.options.length - 1; |
| 108 var event = { target: defaultZoomFactor }; |
| 109 if (defaultZoomFactor.onchange) defaultZoomFactor.onchange(event); |
| 110 }); |
OLD | NEW |