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', | |
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 ['coreOptionsInitialize', | |
27 'fetchPrefs', | |
28 'observePrefs', | |
29 'setBooleanPref', | |
30 'setIntegerPref', | |
31 'setDoublePref', | |
32 'setStringPref', | |
33 'setObjectPref', | |
34 'clearPref', | |
35 'coreOptionsUserMetricsAction', | |
36 // TODO(scr): Handle this new message: | |
37 // getInstantFieldTrialStatus: function() {}, | |
38 ]); | |
39 | |
40 // Register stubs for methods expected to be called before our tests run. | |
41 // Specific expectations can be made in the tests themselves. | |
42 this.mockHandler.stubs().fetchPrefs(ANYTHING); | |
43 this.mockHandler.stubs().observePrefs(ANYTHING); | |
44 this.mockHandler.stubs().coreOptionsInitialize(); | |
45 }, | |
46 }; | |
47 | |
48 // Crashes on Mac only. See http://crbug.com/79181 | |
49 GEN('#if defined(OS_MACOSX)'); | |
50 GEN('#define MAYBE_testSetBooleanPrefTriggers ' + | |
51 'DISABLED_testSetBooleanPrefTriggers'); | |
52 GEN('#else'); | |
53 GEN('#define MAYBE_testSetBooleanPrefTriggers testSetBooleanPrefTriggers'); | |
54 GEN('#endif // defined(OS_MACOSX)'); | |
55 | |
56 TEST_F('OptionsWebUITest', 'MAYBE_testSetBooleanPrefTriggers', function() { | |
57 // TODO(dtseng): make generic to click all buttons. | |
58 var showHomeButton = $('toolbarShowHomeButton'); | |
59 var trueListValue = [ | |
60 'browser.show_home_button', | |
61 true, | |
62 'Options_Homepage_HomeButton', | |
63 ]; | |
64 // Note: this expectation is checked in testing::Test::tearDown. | |
65 this.mockHandler.expects(once()).setBooleanPref(trueListValue); | |
66 | |
67 // Cause the handler to be called. | |
68 showHomeButton.click(); | |
69 showHomeButton.blur(); | |
70 }); | |
71 | |
72 // Not meant to run on ChromeOS at this time. | |
73 // Not finishing in windows, mac, linux, and WebKit bots. http://crbug.com/81723 | |
74 TEST_F('OptionsWebUITest', 'DISABLED_testRefreshStaysOnCurrentPage', | |
75 function() { | |
76 var item = $('advancedPageNav'); | |
77 item.onclick(); | |
78 window.location.reload(); | |
79 var pageInstance = AdvancedOptions.getInstance(); | |
80 var topPage = OptionsPage.getTopmostVisiblePage(); | |
81 var expectedTitle = pageInstance.title; | |
82 var actualTitle = document.title; | |
83 assertEquals("chrome://settings/advanced", document.location.href); | |
84 assertEquals(expectedTitle, actualTitle); | |
85 assertEquals(pageInstance, topPage); | |
86 }); | |
OLD | NEW |