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

Side by Side Diff: chrome/test/data/webui/options.js

Issue 8333013: Allow generator javascript test files to go anywhere in the source tree (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix escaping from windows file paths. Created 9 years, 2 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
(Empty)
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
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
26 /**
27 * Create handler class with empty methods to allow mocking to register
28 * expectations and for registration of handlers with chrome.send.
29 */
30 function MockOptionsHandler() {}
31
32 MockOptionsHandler.prototype = {
33 coreOptionsInitialize: function() {},
34 fetchPrefs: function() {},
35 observePrefs: function() {},
36 setBooleanPref: function() {},
37 setIntegerPref: function() {},
38 setDoublePref: function() {},
39 setStringPref: function() {},
40 setObjectPref: function() {},
41 clearPref: function() {},
42 coreOptionsUserMetricsAction: function() {},
43 // TODO(scr): Handle this new message:
44 // getInstantFieldTrialStatus: function() {},
45 };
46
47 // Create the actual mock and register stubs for methods expected to be
48 // called before our tests run. Specific expectations can be made in the
49 // tests themselves.
50 var mockHandler = this.mockHandler = mock(MockOptionsHandler);
51 mockHandler.stubs().fetchPrefs(ANYTHING);
52 mockHandler.stubs().observePrefs(ANYTHING);
53 mockHandler.stubs().coreOptionsInitialize();
54
55 // Register our mock as a handler of the chrome.send messages.
56 registerMockMessageCallbacks(mockHandler, MockOptionsHandler);
57 },
58 };
59
60 // Crashes on Mac only. See http://crbug.com/79181
61 GEN('#if defined(OS_MACOSX)');
62 GEN('#define MAYBE_testSetBooleanPrefTriggers ' +
63 'DISABLED_testSetBooleanPrefTriggers');
64 GEN('#else');
65 GEN('#define MAYBE_testSetBooleanPrefTriggers testSetBooleanPrefTriggers');
66 GEN('#endif // defined(OS_MACOSX)');
67
68 TEST_F('OptionsWebUITest', 'MAYBE_testSetBooleanPrefTriggers', function() {
69 // TODO(dtseng): make generic to click all buttons.
70 var showHomeButton = $('toolbarShowHomeButton');
71 var trueListValue = [
72 'browser.show_home_button',
73 true,
74 'Options_Homepage_HomeButton',
75 ];
76 // Note: this expectation is checked in testing::Test::tearDown.
77 this.mockHandler.expects(once()).setBooleanPref(trueListValue);
78
79 // Cause the handler to be called.
80 showHomeButton.click();
81 showHomeButton.blur();
82 });
83
84 // Not meant to run on ChromeOS at this time.
85 // Not finishing in windows. http://crbug.com/81723
86 GEN('#if defined(OS_CHROMEOS) || defined(OS_MACOSX) || defined(OS_WIN) \\');
87 GEN(' || defined(TOUCH_UI)');
88 GEN('#define MAYBE_testRefreshStaysOnCurrentPage \\');
89 GEN(' DISABLED_testRefreshStaysOnCurrentPage');
90 GEN('#else');
91 GEN('#define MAYBE_testRefreshStaysOnCurrentPage ' +
92 'testRefreshStaysOnCurrentPage');
93 GEN('#endif');
94
95 TEST_F('OptionsWebUITest', 'MAYBE_testRefreshStaysOnCurrentPage', function() {
96 var item = $('advancedPageNav');
97 item.onclick();
98 window.location.reload();
99 var pageInstance = AdvancedOptions.getInstance();
100 var topPage = OptionsPage.getTopmostVisiblePage();
101 var expectedTitle = pageInstance.title;
102 var actualTitle = document.title;
103 assertEquals("chrome://settings/advanced", document.location.href);
104 assertEquals(expectedTitle, actualTitle);
105 assertEquals(pageInstance, topPage);
106 });
107
108 // Test that there are no console errors after opening all registered pages.
109 // Crashes on chromium os, flaky on other platforms. See crbug.com/90420.
110 // Disabling on Mac OS X since the failure rate is now >50%.
111 GEN('#if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX)');
112 GEN('#define MAYBE_testOpenAllOptionsPages DISABLED_testOpenAllOptionsPages');
113 GEN('#else');
114 GEN('#define MAYBE_testOpenAllOptionsPages FLAKY_testOpenAllOptionsPages');
115 GEN('#endif // defined(TOOLKIT_VIEWS)');
116 TEST_F('OptionsWebUITest', 'MAYBE_testOpenAllOptionsPages', function() {
117 expectTrue(!!OptionsPage.registeredPages);
118 for (var name in OptionsPage.registeredPages) {
119 OptionsPage.showPageByName(name, false);
120 }
121 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698