Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Unified Diff: chrome/browser/ui/webui/sync_setup_browsertest.js

Issue 8503003: Seed test for SyncUI: sign in successfully with mocks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/sync_setup_browsertest.js
diff --git a/chrome/browser/ui/webui/sync_setup_browsertest.js b/chrome/browser/ui/webui/sync_setup_browsertest.js
new file mode 100644
index 0000000000000000000000000000000000000000..e828a527087aa043d115f5d3334392d459d3eafe
--- /dev/null
+++ b/chrome/browser/ui/webui/sync_setup_browsertest.js
@@ -0,0 +1,117 @@
+// Copyright (c) 2011 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.
+
+// 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
+var runMessageLoop = false;
+if (runMessageLoop)
+ GEN('#include "chrome/test/base/ui_test_utils.h"');
+
+/**
+ * Test fixture for sync setup WebUI testing.
+ * @constructor
+ * @extends {testing.Test}
+ */
+function SyncSetupWebUITest() {}
+
+SyncSetupWebUITest.prototype = {
+ __proto__: testing.Test.prototype,
+
+ /**
+ * Browse to personal options.
+ **/
+ browsePreload: 'chrome://settings/personal',
+
+ /** @inheritDoc */
+ preLoad: function() {
+
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.
+ function MockSyncSetupHandler() {}
+
+ MockSyncSetupHandler.prototype = {
+ stopSyncing: function() {},
+ SyncSetupDidClosePage: function() {},
+ SyncSetupSubmitAuth: function() {},
+ SyncSetupConfigure: function() {},
+ SyncSetupPassphrase: function() {},
+ SyncSetupPassphraseCancel: function() {},
+ SyncSetupAttachHandler: function() {},
+ SyncSetupShowErrorUI: function() {},
+ 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
+ };
+ 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
+
+ // Register mock as a handler of the chrome.send messages.
+ registerMockMessageCallbacks(mockHandler, MockSyncSetupHandler);
+ },
+
+ /**
+ * Debugging tool to see what's going on.
+ * TODO(scr) remove this code.
+ */
+ testGenPostamble: function() {
+ if (runMessageLoop)
+ GEN('ui_test_utils::RunMessageLoop();');
+ },
+
+ /**
+ * Verify starting point is not synced.
+ */
+ verifyUnsynced: function() {
+ var customizeSyncButton = $('customize-sync');
+ assertNotEquals(null, customizeSyncButton);
+ 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
+ },
+
+ /**
+ * Click the "Sign in to Chrome" button.
+ */
+ startSyncing: function() {
+ 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.
+ assertNotEquals(null, startStopSyncButton);
+ this.mockHandler.expects(once()).SyncSetupShowSetupUI().
+ will(callFunction(function() {
+ OptionsPage.navigateToPage('syncSetup');
+ }));
+
+ this.mockHandler.expects(once()).SyncSetupAttachHandler().
+ will(callFunction(function() {
+ SyncSetupOverlay.showSyncSetupPage(
+ 'login', {
+ user: '',
+ error: 0,
+ editable_user: true,
+ });
+ }));
+ startStopSyncButton.click();
+ },
+
+ gaiaLogin: function() {
+ // Find the DOM objects on the page.
+ var gaiaEmail = $('gaia-email');
+ assertNotEquals(null, gaiaEmail);
+ var gaiaPasswd = $('gaia-passwd');
+ assertNotEquals(null, gaiaPasswd);
+ var signIn = $('sign-in');
+ assertNotEquals(null, signIn);
+
+ // Set up mock expectations
+ this.mockHandler.expects(once()).SyncSetupSubmitAuth(NOT_NULL).
+ will(callFunction(function() {
+ SyncSetupOverlay.showSuccessAndClose();
+ }));
+ this.mockHandler.expects(once()).SyncSetupDidClosePage();
+
+ // set the email & password, then sign in.
+ gaiaEmail.value = 'foo@bar.baz';
+ gaiaPasswd.value = 'foo@bar.baz';
+ signIn.click();
+ },
+};
+
+// Verify that initial state is unsynced, start syncing, then login.
+TEST_F('SyncSetupWebUITest', 'VerifySignIn', function() {
+ this.verifyUnsynced();
+ this.startSyncing();
+ this.gaiaLogin();
+});
+
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698