OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 /** | |
6 * TestFixture for OptionsPage WebUI testing. | |
7 * @extends {testing.Test} | |
8 * @constructor | |
9 */ | |
10 function OptionsWebUITest() {} | |
11 | |
12 OptionsWebUITest.prototype = { | |
13 __proto__: testing.Test.prototype, | |
14 | |
15 /** | |
16 * Browse to the options page & call our preLoad(). | |
17 */ | |
18 browsePreload: 'chrome://settings-frame', | |
19 | |
20 /** | |
21 * Register a mock handler to ensure expectations are met and options pages | |
22 * behave correctly. | |
23 */ | |
24 preLoad: function() { | |
25 this.makeAndRegisterMockHandler( | |
26 ['defaultZoomFactorAction', | |
27 'fetchPrefs', | |
28 'observePrefs', | |
29 'setBooleanPref', | |
30 'setIntegerPref', | |
31 'setDoublePref', | |
32 'setStringPref', | |
33 'setObjectPref', | |
34 'clearPref', | |
35 'coreOptionsUserMetricsAction', | |
36 ]); | |
37 | |
38 // Register stubs for methods expected to be called before/during tests. | |
39 // Specific expectations can be made in the tests themselves. | |
40 this.mockHandler.stubs().fetchPrefs(ANYTHING); | |
41 this.mockHandler.stubs().observePrefs(ANYTHING); | |
42 this.mockHandler.stubs().coreOptionsUserMetricsAction(ANYTHING); | |
43 }, | |
44 }; | |
45 | |
46 // Crashes on Mac only. See http://crbug.com/79181 | |
47 GEN('#if defined(OS_MACOSX)'); | |
48 GEN('#define MAYBE_testSetBooleanPrefTriggers ' + | |
49 'DISABLED_testSetBooleanPrefTriggers'); | |
50 GEN('#else'); | |
51 GEN('#define MAYBE_testSetBooleanPrefTriggers testSetBooleanPrefTriggers'); | |
52 GEN('#endif // defined(OS_MACOSX)'); | |
53 | |
54 TEST_F('OptionsWebUITest', 'MAYBE_testSetBooleanPrefTriggers', function() { | |
55 // TODO(dtseng): make generic to click all buttons. | |
56 var showHomeButton = $('show-home-button'); | |
57 var trueListValue = [ | |
58 'browser.show_home_button', | |
59 true, | |
60 'Options_Homepage_HomeButton', | |
61 ]; | |
62 // Note: this expectation is checked in testing::Test::tearDown. | |
63 this.mockHandler.expects(once()).setBooleanPref(trueListValue); | |
64 | |
65 // Cause the handler to be called. | |
66 showHomeButton.click(); | |
67 showHomeButton.blur(); | |
68 }); | |
69 | |
70 // Not meant to run on ChromeOS at this time. | |
71 // Not finishing in windows. http://crbug.com/81723 | |
72 TEST_F('OptionsWebUITest', 'DISABLED_testRefreshStaysOnCurrentPage', | |
73 function() { | |
74 assertTrue($('search-engine-manager-page').hidden); | |
75 var item = $('manage-default-search-engines'); | |
76 item.click(); | |
77 | |
78 assertFalse($('search-engine-manager-page').hidden); | |
79 | |
80 window.location.reload(); | |
81 | |
82 assertEquals('chrome://settings-frame/searchEngines', document.location.href); | |
83 assertFalse($('search-engine-manager-page').hidden); | |
84 }); | |
85 | |
86 /** | |
87 * Test the default zoom factor select element. | |
88 */ | |
89 TEST_F('OptionsWebUITest', 'testDefaultZoomFactor', function() { | |
90 // The expected minimum length of the |defaultZoomFactor| element. | |
91 var defaultZoomFactorMinimumLength = 10; | |
92 // Verify that the zoom factor element exists. | |
93 var defaultZoomFactor = $('defaultZoomFactor'); | |
94 assertNotEquals(defaultZoomFactor, null); | |
95 | |
96 // Verify that the zoom factor element has a reasonable number of choices. | |
97 expectGE(defaultZoomFactor.options.length, defaultZoomFactorMinimumLength); | |
98 | |
99 // Simulate a change event, selecting the highest zoom value. Verify that | |
100 // the javascript handler was invoked once. | |
101 this.mockHandler.expects(once()).defaultZoomFactorAction(NOT_NULL). | |
102 will(callFunction(function() { })); | |
103 defaultZoomFactor.selectedIndex = defaultZoomFactor.options.length - 1; | |
104 var event = { target: defaultZoomFactor }; | |
105 if (defaultZoomFactor.onchange) defaultZoomFactor.onchange(event); | |
106 }); | |
OLD | NEW |