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

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: Made some utility methods to make mockHandler and mockGlobals generation simpler. 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
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..dc978d3aaac64df52ab329b7e593a906601c57c1
--- /dev/null
+++ b/chrome/browser/ui/webui/sync_setup_browsertest.js
@@ -0,0 +1,107 @@
+// 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.
James Hawkins 2011/11/09 17:15:56 Time to remove this.
Sheridan Rawlins 2011/11/09 23:51:00 Done.
+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() {
+ this.makeAndRegisterMockHandler(['stopSyncing',
+ 'SyncSetupDidClosePage',
+ 'SyncSetupSubmitAuth',
+ 'SyncSetupConfigure',
+ 'SyncSetupPassphrase',
+ 'SyncSetupPassphraseCancel',
+ 'SyncSetupAttachHandler',
+ 'SyncSetupShowErrorUI',
+ 'SyncSetupShowSetupUI',
+ ]);
+ },
+
+ /**
+ * 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.
James Hawkins 2011/11/09 17:15:56 Verifies
Sheridan Rawlins 2011/11/09 23:51:00 Done.
+ */
+ verifyUnsynced: function() {
+ assertFalse(PersonalOptions.getInstance().syncSetupCompleted);
+ },
+
+ /**
+ * 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.
+ */
+ startSyncing: function() {
+ var startStopSyncButton = $('start-stop-sync');
+ 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() {
James Hawkins 2011/11/09 17:15:56 Document the method.
Sheridan Rawlins 2011/11/09 23:51:00 Moved into test; moot.
+ // Find the DOM objects on the page.
+ var gaiaEmail = SyncSetupOverlay.getLoginEmail();
+ assertNotEquals(null, gaiaEmail);
+ var gaiaPasswd = SyncSetupOverlay.getLoginPasswd();
+ assertNotEquals(null, gaiaPasswd);
+ var signInButton = SyncSetupOverlay.getSignInButton();
+ assertNotEquals(null, signInButton);
+
+ // 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';
+ signInButton.click();
+ },
+};
+
+// Verify that initial state is unsynced, start syncing, then login.
+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
+ this.verifyUnsynced();
+ this.startSyncing();
+ this.gaiaLogin();
+});
+

Powered by Google App Engine
This is Rietveld 408576698