Chromium Code Reviews| 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. | |
|
Sheridan Rawlins
2011/11/08 06:58:14
I plan on removing this before commit, but it is u
| |
| 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 | |
|
James Hawkins
2011/11/08 17:08:37
Inconsistency: Blank line at beginning of method b
Sheridan Rawlins
2011/11/08 21:32:04
Done.
| |
| 28 function MockSyncSetupHandler() {} | |
| 29 | |
| 30 MockSyncSetupHandler.prototype = { | |
| 31 stopSyncing: function() {}, | |
| 32 SyncSetupDidClosePage: function() {}, | |
| 33 SyncSetupSubmitAuth: function() {}, | |
| 34 SyncSetupConfigure: function() {}, | |
| 35 SyncSetupPassphrase: function() {}, | |
| 36 SyncSetupPassphraseCancel: function() {}, | |
| 37 SyncSetupAttachHandler: function() {}, | |
| 38 SyncSetupShowErrorUI: function() {}, | |
| 39 SyncSetupShowSetupUI: function() {}, | |
|
Dan Beam
2011/11/08 21:54:48
Do we do this alot? Seems like we would. If we d
Sheridan Rawlins
2011/11/09 02:44:22
Thanks - cool suggestion to make it easier (& memo
| |
| 40 }; | |
| 41 var mockHandler = this.mockHandler = mock(MockSyncSetupHandler); | |
|
James Hawkins
2011/11/08 17:08:37
What's with this construct?
var mockHandler = thi
Sheridan Rawlins
2011/11/08 21:32:04
It's useful in other tests which set up several st
| |
| 42 | |
| 43 // Register mock as a handler of the chrome.send messages. | |
| 44 registerMockMessageCallbacks(mockHandler, MockSyncSetupHandler); | |
| 45 }, | |
| 46 | |
| 47 /** | |
| 48 * Debugging tool to see what's going on. | |
| 49 * TODO(scr) remove this code. | |
| 50 */ | |
| 51 testGenPostamble: function() { | |
| 52 if (runMessageLoop) | |
| 53 GEN('ui_test_utils::RunMessageLoop();'); | |
| 54 }, | |
| 55 | |
| 56 /** | |
| 57 * Verify starting point is not synced. | |
| 58 */ | |
| 59 verifyUnsynced: function() { | |
| 60 var customizeSyncButton = $('customize-sync'); | |
| 61 assertNotEquals(null, customizeSyncButton); | |
| 62 assertTrue(customizeSyncButton.hidden); | |
|
James Hawkins
2011/11/08 17:08:37
Testing wether elemenets are hidden or not (i.e.,
Sheridan Rawlins
2011/11/08 21:32:04
How 'bout checking syncSetupCompleted is false?
D
| |
| 63 }, | |
| 64 | |
| 65 /** | |
| 66 * Click the "Sign in to Chrome" button. | |
| 67 */ | |
| 68 startSyncing: function() { | |
| 69 var startStopSyncButton = $('start-stop-sync'); | |
|
James Hawkins
2011/11/08 17:08:37
I'm also hesitant to have tests reference element
Sheridan Rawlins
2011/11/08 21:32:04
Done.
| |
| 70 assertNotEquals(null, startStopSyncButton); | |
| 71 this.mockHandler.expects(once()).SyncSetupShowSetupUI(). | |
| 72 will(callFunction(function() { | |
| 73 OptionsPage.navigateToPage('syncSetup'); | |
| 74 })); | |
| 75 | |
| 76 this.mockHandler.expects(once()).SyncSetupAttachHandler(). | |
| 77 will(callFunction(function() { | |
| 78 SyncSetupOverlay.showSyncSetupPage( | |
| 79 'login', { | |
| 80 user: '', | |
| 81 error: 0, | |
| 82 editable_user: true, | |
| 83 }); | |
| 84 })); | |
| 85 startStopSyncButton.click(); | |
| 86 }, | |
| 87 | |
| 88 gaiaLogin: function() { | |
| 89 // Find the DOM objects on the page. | |
| 90 var gaiaEmail = $('gaia-email'); | |
| 91 assertNotEquals(null, gaiaEmail); | |
| 92 var gaiaPasswd = $('gaia-passwd'); | |
| 93 assertNotEquals(null, gaiaPasswd); | |
| 94 var signIn = $('sign-in'); | |
| 95 assertNotEquals(null, signIn); | |
| 96 | |
| 97 // Set up mock expectations | |
| 98 this.mockHandler.expects(once()).SyncSetupSubmitAuth(NOT_NULL). | |
| 99 will(callFunction(function() { | |
| 100 SyncSetupOverlay.showSuccessAndClose(); | |
| 101 })); | |
| 102 this.mockHandler.expects(once()).SyncSetupDidClosePage(); | |
| 103 | |
| 104 // set the email & password, then sign in. | |
| 105 gaiaEmail.value = 'foo@bar.baz'; | |
| 106 gaiaPasswd.value = 'foo@bar.baz'; | |
| 107 signIn.click(); | |
| 108 }, | |
| 109 }; | |
| 110 | |
| 111 // Verify that initial state is unsynced, start syncing, then login. | |
| 112 TEST_F('SyncSetupWebUITest', 'VerifySignIn', function() { | |
| 113 this.verifyUnsynced(); | |
| 114 this.startSyncing(); | |
| 115 this.gaiaLogin(); | |
| 116 }); | |
| 117 | |
| OLD | NEW |