OLD | NEW |
---|---|
(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 // TODO(scr) remove this debugging tool. | |
James Hawkins
2011/11/09 17:15:56
Time to remove this.
Sheridan Rawlins
2011/11/09 23:51:00
Done.
| |
6 var runMessageLoop = false; | |
7 if (runMessageLoop) | |
8 GEN('#include "chrome/test/base/ui_test_utils.h"'); | |
9 | |
10 /** | |
11 * Test fixture for sync setup WebUI testing. | |
12 * @constructor | |
13 * @extends {testing.Test} | |
14 */ | |
15 function SyncSetupWebUITest() {} | |
16 | |
17 SyncSetupWebUITest.prototype = { | |
18 __proto__: testing.Test.prototype, | |
19 | |
20 /** | |
21 * Browse to personal options. | |
22 **/ | |
23 browsePreload: 'chrome://settings/personal', | |
24 | |
25 /** @inheritDoc */ | |
26 preLoad: function() { | |
27 this.makeAndRegisterMockHandler(['stopSyncing', | |
28 'SyncSetupDidClosePage', | |
29 'SyncSetupSubmitAuth', | |
30 'SyncSetupConfigure', | |
31 'SyncSetupPassphrase', | |
32 'SyncSetupPassphraseCancel', | |
33 'SyncSetupAttachHandler', | |
34 'SyncSetupShowErrorUI', | |
35 'SyncSetupShowSetupUI', | |
36 ]); | |
37 }, | |
38 | |
39 /** | |
40 * Debugging tool to see what's going on. | |
41 * TODO(scr) remove this code. | |
42 */ | |
43 testGenPostamble: function() { | |
44 if (runMessageLoop) | |
45 GEN('ui_test_utils::RunMessageLoop();'); | |
46 }, | |
47 | |
48 /** | |
49 * Verify starting point is not synced. | |
James Hawkins
2011/11/09 17:15:56
Verifies
Sheridan Rawlins
2011/11/09 23:51:00
Done.
| |
50 */ | |
51 verifyUnsynced: function() { | |
52 assertFalse(PersonalOptions.getInstance().syncSetupCompleted); | |
53 }, | |
54 | |
55 /** | |
56 * Click the "Sign in to Chrome" button. | |
James Hawkins
2011/11/09 17:15:56
Clicks
Sheridan Rawlins
2011/11/09 23:51:00
Done.
| |
57 */ | |
58 startSyncing: function() { | |
59 var startStopSyncButton = $('start-stop-sync'); | |
60 assertNotEquals(null, startStopSyncButton); | |
61 this.mockHandler.expects(once()).SyncSetupShowSetupUI(). | |
62 will(callFunction(function() { | |
63 OptionsPage.navigateToPage('syncSetup'); | |
64 })); | |
65 | |
66 this.mockHandler.expects(once()).SyncSetupAttachHandler(). | |
67 will(callFunction(function() { | |
68 SyncSetupOverlay.showSyncSetupPage( | |
69 'login', { | |
70 user: '', | |
71 error: 0, | |
72 editable_user: true, | |
73 }); | |
74 })); | |
75 startStopSyncButton.click(); | |
76 }, | |
77 | |
78 gaiaLogin: function() { | |
James Hawkins
2011/11/09 17:15:56
Document the method.
Sheridan Rawlins
2011/11/09 23:51:00
Moved into test; moot.
| |
79 // Find the DOM objects on the page. | |
80 var gaiaEmail = SyncSetupOverlay.getLoginEmail(); | |
81 assertNotEquals(null, gaiaEmail); | |
82 var gaiaPasswd = SyncSetupOverlay.getLoginPasswd(); | |
83 assertNotEquals(null, gaiaPasswd); | |
84 var signInButton = SyncSetupOverlay.getSignInButton(); | |
85 assertNotEquals(null, signInButton); | |
86 | |
87 // Set up mock expectations | |
88 this.mockHandler.expects(once()).SyncSetupSubmitAuth(NOT_NULL). | |
89 will(callFunction(function() { | |
90 SyncSetupOverlay.showSuccessAndClose(); | |
91 })); | |
92 this.mockHandler.expects(once()).SyncSetupDidClosePage(); | |
93 | |
94 // set the email & password, then sign in. | |
95 gaiaEmail.value = 'foo@bar.baz'; | |
96 gaiaPasswd.value = 'foo@bar.baz'; | |
97 signInButton.click(); | |
98 }, | |
99 }; | |
100 | |
101 // Verify that initial state is unsynced, start syncing, then login. | |
102 TEST_F('SyncSetupWebUITest', 'VerifySignIn', function() { | |
James Hawkins
2011/11/09 17:15:56
This test method looks weird...it just calls other
Sheridan Rawlins
2011/11/09 23:51:00
I had the feeling that further tests might need to
| |
103 this.verifyUnsynced(); | |
104 this.startSyncing(); | |
105 this.gaiaLogin(); | |
106 }); | |
107 | |
OLD | NEW |