1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
GEN('#if !defined(OS_CHROMEOS)');
/**
* Test fixture for sync setup WebUI testing.
* @constructor
* @extends {testing.Test}
*/
function SyncSetupWebUITest() {}
SyncSetupWebUITest.prototype = {
__proto__: testing.Test.prototype,
/**
* Browse to the settings sub-frame.
*/
browsePreload: 'chrome://settings-frame',
/** @override */
preLoad: function() {
this.makeAndRegisterMockHandler(['SyncSetupConfigure',
'SyncSetupShowSetupUI',
'SyncSetupStartSignIn',
]);
},
/**
* Verifies starting point is not synced.
*/
verifyUnsynced: function() {
assertFalse(BrowserOptions.getInstance().signedIn_);
},
/**
* Clicks the "Sign in to Chrome" button.
*/
startSyncing: function() {
var startStopSyncButton = BrowserOptions.getStartStopSyncButton();
assertNotEquals(null, startStopSyncButton);
startStopSyncButton.click();
},
};
/**
* Async version of SyncSetupWebUITest.
* @extends {SyncSetupWebUITest}
* @constructor
*/
function SyncSetupWebUITestAsync() {}
SyncSetupWebUITestAsync.prototype = {
__proto__: SyncSetupWebUITest.prototype,
/** @override */
isAsync: true,
/**
* Verifies that initial state is unsynced and simulates signing in.
* @override
*/
setUp: function() {
SyncSetupWebUITest.prototype.setUp.call(this);
// For testing, don't wait to execute timeouts.
var oldSetTimeout = setTimeout;
setTimeout = function(fn, timeout) {
oldSetTimeout(fn, 0);
};
// Make sure the user is not starting off in the signed in or syncing state.
this.verifyUnsynced();
// Handle SyncSetupShowSetupUI by navigating to chrome://settings/syncSetup.
this.mockHandler.expects(once()).SyncSetupShowSetupUI().will(callFunction(
function() {
PageManager.showPageByName('syncSetup');
}));
},
};
// This test is flaky on Linux bot. See crbug.com/579666
GEN('#if defined(OS_LINUX)');
GEN('#define MAYBE_VerifySignIn DISABLED_VerifySignIn');
GEN('#else');
GEN('#define MAYBE_VerifySignIn VerifySignIn');
GEN('#endif // defined(OS_LINUX)');
TEST_F('SyncSetupWebUITestAsync', 'MAYBE_VerifySignIn', function() {
// Handle SyncSetupStartSignIn by displaying the sync setup dialog, verifying
// that a confirmation dialog appears, and clicking OK to dismiss the dialog.
// Note that this test doesn't actually do a gaia sign in.
this.mockHandler.expects(once()).SyncSetupStartSignIn(
[false] /* createSupervisedUser */).will(callFunction(function() {
SyncSetupOverlay.showSyncSetupPage('configure');
var okButton = $('confirm-everything-ok');
assertNotEquals(null, okButton);
okButton.click();
}));
// The test completes after the sync config is sent out.
this.mockHandler.expects(once()).SyncSetupConfigure(ANYTHING).
will(callFunction(testDone));
// Click the "Sign in to Chrome..." button.
this.startSyncing();
});
// This test is flaky on Linux bot. See crbug.com/579666
GEN('#if defined(OS_LINUX)');
GEN('#define MAYBE_RestoreSyncDataTypes DISABLED_RestoreSyncDataTypes');
GEN('#else');
GEN('#define MAYBE_RestoreSyncDataTypes RestoreSyncDataTypes');
GEN('#endif // defined(OS_LINUX)');
// Test that switching to and from "Sync everything" saves and restores types.
TEST_F('SyncSetupWebUITestAsync', 'MAYBE_RestoreSyncDataTypes', function() {
this.mockHandler.expects(once()).SyncSetupStartSignIn(
[false] /* createSupervisedUser */).will(callFunction(function() {
SyncSetupOverlay.showSyncSetupPage('configure', {});
$('sync-select-datatypes').selectedIndex = 1;
cr.dispatchSimpleEvent($('sync-select-datatypes'), 'change', true);
$('bookmarks-checkbox').checked = false;
cr.dispatchSimpleEvent($('bookmarks-checkbox'), 'change', true);
$('sync-select-datatypes').selectedIndex = 0;
cr.dispatchSimpleEvent($('sync-select-datatypes'), 'change', true);
assertTrue($('bookmarks-checkbox').checked);
$('sync-select-datatypes').selectedIndex = 1;
cr.dispatchSimpleEvent($('sync-select-datatypes'), 'change', true);
assertFalse($('bookmarks-checkbox').checked);
testDone();
}));
this.startSyncing();
});
GEN('#endif // OS_CHROMEOS');
|