Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / ui / webui / sync_setup_browsertest.js
blob437e3cf98da558c32ff00135e95bfc4c5e583534
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.
5 GEN('#if !defined(OS_CHROMEOS)');
7 /**
8 * Test fixture for sync setup WebUI testing.
9 * @constructor
10 * @extends {testing.Test}
12 function SyncSetupWebUITest() {}
14 SyncSetupWebUITest.prototype = {
15 __proto__: testing.Test.prototype,
17 /**
18 * Browse to the settings sub-frame.
20 browsePreload: 'chrome://settings-frame',
22 /** @override */
23 preLoad: function() {
24 this.makeAndRegisterMockHandler(['SyncSetupConfigure',
25 'SyncSetupShowSetupUI',
26 'SyncSetupStartSignIn',
27 ]);
30 /**
31 * Verifies starting point is not synced.
33 verifyUnsynced: function() {
34 assertFalse(BrowserOptions.getInstance().signedIn_);
37 /**
38 * Clicks the "Sign in to Chrome" button.
40 startSyncing: function() {
41 var startStopSyncButton = BrowserOptions.getStartStopSyncButton();
42 assertNotEquals(null, startStopSyncButton);
43 startStopSyncButton.click();
47 /**
48 * Async version of SyncSetupWebUITest.
49 * @extends {SyncSetupWebUITest}
50 * @constructor
52 function SyncSetupWebUITestAsync() {}
54 SyncSetupWebUITestAsync.prototype = {
55 __proto__: SyncSetupWebUITest.prototype,
57 /** @override */
58 isAsync: true,
61 // Verify that initial state is unsynced, click the sign in button, verify
62 // that the sync setup dialog appears, and dismiss it.
63 TEST_F('SyncSetupWebUITestAsync', 'VerifySignIn', function() {
64 // Make sure the user is not starting off in the signed in or syncing state.
65 this.verifyUnsynced();
67 // Handle SyncSetupShowSetupUI by navigating to chrome://settings/syncSetup.
68 this.mockHandler.expects(once()).SyncSetupShowSetupUI().
69 will(callFunction(function() {
70 PageManager.showPageByName('syncSetup');
71 }));
73 // Handle SyncSetupStartSignIn by displaying the sync setup dialog, verifying
74 // that a confirmation dialog appears, and clicking OK to dismiss the dialog.
75 // Note that this test doesn't actually do a gaia sign in.
76 this.mockHandler.expects(once()).SyncSetupStartSignIn().
77 will(callFunction(function() {
78 SyncSetupOverlay.showSyncSetupPage('configure');
79 var okButton = $('confirm-everything-ok');
80 assertNotEquals(null, okButton);
81 okButton.click();
82 }));
84 // The test completes after the sync config is sent out.
85 this.mockHandler.expects(once()).SyncSetupConfigure(ANYTHING).
86 will(callFunction(testDone));
88 // For testing, don't wait to execute timeouts.
89 var oldSetTimeout = setTimeout;
90 setTimeout = function(fn, timeout) {
91 oldSetTimeout(fn, 0);
94 // Kick off the test by clicking the "Sign in to Chrome..." button.
95 this.startSyncing();
96 });
98 GEN('#endif // OS_CHROMEOS');