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)');
8 * Test fixture for sync setup WebUI testing.
10 * @extends {testing.Test}
12 function SyncSetupWebUITest() {}
14 SyncSetupWebUITest.prototype = {
15 __proto__: testing.Test.prototype,
18 * Browse to the settings sub-frame.
20 browsePreload: 'chrome://settings-frame',
24 this.makeAndRegisterMockHandler(['SyncSetupConfigure',
25 'SyncSetupShowSetupUI',
26 'SyncSetupStartSignIn',
31 * Verifies starting point is not synced.
33 verifyUnsynced: function() {
34 assertFalse(BrowserOptions.getInstance().signedIn_);
38 * Clicks the "Sign in to Chrome" button.
40 startSyncing: function() {
41 var startStopSyncButton = BrowserOptions.getStartStopSyncButton();
42 assertNotEquals(null, startStopSyncButton);
43 startStopSyncButton.click();
48 * Async version of SyncSetupWebUITest.
49 * @extends {SyncSetupWebUITest}
52 function SyncSetupWebUITestAsync() {}
54 SyncSetupWebUITestAsync.prototype = {
55 __proto__: SyncSetupWebUITest.prototype,
61 * Verifies that initial state is unsynced and simulates signing in.
65 SyncSetupWebUITest.prototype.setUp.call(this);
67 // For testing, don't wait to execute timeouts.
68 var oldSetTimeout = setTimeout;
69 setTimeout = function(fn, timeout) {
73 // Make sure the user is not starting off in the signed in or syncing state.
74 this.verifyUnsynced();
76 // Handle SyncSetupShowSetupUI by navigating to chrome://settings/syncSetup.
77 this.mockHandler.expects(once()).SyncSetupShowSetupUI().will(callFunction(
79 PageManager.showPageByName('syncSetup');
84 TEST_F('SyncSetupWebUITestAsync', 'VerifySignIn', function() {
85 // Handle SyncSetupStartSignIn by displaying the sync setup dialog, verifying
86 // that a confirmation dialog appears, and clicking OK to dismiss the dialog.
87 // Note that this test doesn't actually do a gaia sign in.
88 this.mockHandler.expects(once()).SyncSetupStartSignIn().will(callFunction(
90 SyncSetupOverlay.showSyncSetupPage('configure');
91 var okButton = $('confirm-everything-ok');
92 assertNotEquals(null, okButton);
96 // The test completes after the sync config is sent out.
97 this.mockHandler.expects(once()).SyncSetupConfigure(ANYTHING).
98 will(callFunction(testDone));
100 // Click the "Sign in to Chrome..." button.
104 // Test that switching to and from "Sync everything" saves and restores types.
105 TEST_F('SyncSetupWebUITestAsync', 'RestoreSyncDataTypes', function() {
106 this.mockHandler.expects(once()).SyncSetupStartSignIn().will(callFunction(
108 SyncSetupOverlay.showSyncSetupPage('configure', {});
110 $('sync-select-datatypes').selectedIndex = 1;
111 cr.dispatchSimpleEvent($('sync-select-datatypes'), 'change', true);
113 $('bookmarks-checkbox').checked = false;
114 cr.dispatchSimpleEvent($('bookmarks-checkbox'), 'change', true);
116 $('sync-select-datatypes').selectedIndex = 0;
117 cr.dispatchSimpleEvent($('sync-select-datatypes'), 'change', true);
118 assertTrue($('bookmarks-checkbox').checked);
120 $('sync-select-datatypes').selectedIndex = 1;
121 cr.dispatchSimpleEvent($('sync-select-datatypes'), 'change', true);
122 assertFalse($('bookmarks-checkbox').checked);
130 GEN('#endif // OS_CHROMEOS');