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/browser/ui/webui/options/options_browsertest.js

Issue 8503003: Seed test for SyncUI: sign in successfully with mocks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use makeAndRegisterMockHandler in new ChromeSendWebUITest. Created 9 years, 1 month 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
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(
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 ]);
25 39
26 /** 40 // Register stubs for methods expected to be called before our tests run.
27 * Create handler class with empty methods to allow mocking to register 41 // Specific expectations can be made in the tests themselves.
28 * expectations and for registration of handlers with chrome.send. 42 this.mockHandler.stubs().fetchPrefs(ANYTHING);
29 */ 43 this.mockHandler.stubs().observePrefs(ANYTHING);
30 function MockOptionsHandler() {} 44 this.mockHandler.stubs().coreOptionsInitialize();
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 }, 45 },
58 }; 46 };
59 47
60 // Crashes on Mac only. See http://crbug.com/79181 48 // Crashes on Mac only. See http://crbug.com/79181
61 GEN('#if defined(OS_MACOSX)'); 49 GEN('#if defined(OS_MACOSX)');
62 GEN('#define MAYBE_testSetBooleanPrefTriggers ' + 50 GEN('#define MAYBE_testSetBooleanPrefTriggers ' +
63 'DISABLED_testSetBooleanPrefTriggers'); 51 'DISABLED_testSetBooleanPrefTriggers');
64 GEN('#else'); 52 GEN('#else');
65 GEN('#define MAYBE_testSetBooleanPrefTriggers testSetBooleanPrefTriggers'); 53 GEN('#define MAYBE_testSetBooleanPrefTriggers testSetBooleanPrefTriggers');
66 GEN('#endif // defined(OS_MACOSX)'); 54 GEN('#endif // defined(OS_MACOSX)');
(...skipping 30 matching lines...) Expand all
97 item.onclick(); 85 item.onclick();
98 window.location.reload(); 86 window.location.reload();
99 var pageInstance = AdvancedOptions.getInstance(); 87 var pageInstance = AdvancedOptions.getInstance();
100 var topPage = OptionsPage.getTopmostVisiblePage(); 88 var topPage = OptionsPage.getTopmostVisiblePage();
101 var expectedTitle = pageInstance.title; 89 var expectedTitle = pageInstance.title;
102 var actualTitle = document.title; 90 var actualTitle = document.title;
103 assertEquals("chrome://settings/advanced", document.location.href); 91 assertEquals("chrome://settings/advanced", document.location.href);
104 assertEquals(expectedTitle, actualTitle); 92 assertEquals(expectedTitle, actualTitle);
105 assertEquals(pageInstance, topPage); 93 assertEquals(pageInstance, topPage);
106 }); 94 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/sync_setup_overlay.js ('k') | chrome/browser/ui/webui/sync_setup_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698