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

Unified Diff: remoting/webapp/browser_test/update_pin_browser_test.js

Issue 273753002: Implement 3 PIN browser tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: PIN Browser Tests Created 6 years, 7 months 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: remoting/webapp/browser_test/update_pin_browser_test.js
diff --git a/remoting/webapp/browser_test/update_pin_browser_test.js b/remoting/webapp/browser_test/update_pin_browser_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..28006434c99a6332cdab8b19ad70e6bb65bdfaa9
--- /dev/null
+++ b/remoting/webapp/browser_test/update_pin_browser_test.js
@@ -0,0 +1,114 @@
+// Copyright 2014 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.
+
+/**
+ * @fileoverview
+ * @suppress {checkTypes}
+ * Browser test for the scenario below:
+ * 1. Change the PIN.
+ * 2. Connect with the new PIN.
+ * 3. Verify the connection succeeded.
+ * 4. Disconnect and reconnect with the old PIN.
+ * 5. Verify the connection failed.
+ */
+
+'use strict';
+
+/** @constructor */
+browserTest.Update_PIN = function(data) {
+ browserTest.assert(typeof data.pin != undefined);
Jamie 2014/05/09 01:02:18 Copy/paste bug from the other tests?
kelvinp 2014/05/12 21:08:34 Done.
+ this.old_pin_ = data.old_pin;
+ this.new_pin_ = data.new_pin;
+
+ browserTest.assert(this.new_pin_ != this.old_pin_,
+ 'The new PIN and the old PIN cannot be the same');
+
+ this.bound_ = {
+ onPINSetup: this.onPINSetup_.bind(this),
+ onPINChanged: this.onPINChanged_.bind(this),
+ onPINPromptOldPIN: this.onPINPromptOldPIN_.bind(this),
+ onInvalidPIN: this.onInvalidPIN_.bind(this),
+ onPINPromptNewPIN: this.onPINPromptNewPIN_.bind(this),
+ onSessionConnected: this.onSessionConnected_.bind(this),
+ onSessionDisconnected: this.onSessionDisconnected_.bind(this)
+ };
+};
+
+browserTest.Update_PIN.prototype.run = function() {
+ browserTest.waitForUIMode(
+ remoting.AppMode.HOST_SETUP_ASK_PIN,
+ this.bound_.onPINSetup);
+ browserTest.clickOnControl('change-daemon-pin');
+};
+
+browserTest.Update_PIN.prototype.clickOnMe2MeHost_ = function() {
+ browserTest.clickOnControl('this-host-connect');
+};
+
+browserTest.Update_PIN.prototype.onPINSetup_ = function() {
+ browserTest.waitForUIMode(
+ remoting.AppMode.HOST_SETUP_DONE, this.bound_.onPINChanged);
+
+ document.getElementById('daemon-pin-entry').value = this.new_pin_;
+ document.getElementById('daemon-pin-confirm').value = this.new_pin_;
+ browserTest.clickOnControl('daemon-pin-ok');
+};
+
+browserTest.Update_PIN.prototype.onPINChanged_ = function() {
+ browserTest.clickOnControl('host-config-done-dismiss');
+
+ // On Linux, we restart the host when the PIN is changed. Sleep for five
Jamie 2014/05/09 01:02:18 You're actually sleeping for 30s.
kelvinp 2014/05/12 21:08:34 Done.
+ // seconds so that the host can be ready for new connections again.
+ // TODO(kelvinp): Is there a better way to detect whether the host is ready
+ // for new incoming connections?
Jamie 2014/05/09 01:02:18 You could poll the daemon state. Better still, add
kelvinp 2014/05/12 21:08:34 Discussed offline. Will follow up with a differen
+ window.setTimeout(this.connectWithNewPIN_.bind(this), 30000);
+};
+
+browserTest.Update_PIN.prototype.connectWithNewPIN_ = function() {
+ // Need to test for the success case first because connecting with an
+ // invalid PIN temporarily blocks future logins.
Jamie 2014/05/09 01:02:18 Actually, this is worse because you're temporarily
kelvinp 2014/05/12 21:08:34 Done. In practice, it should be fine because the
+ browserTest.waitForUIMode(
+ remoting.AppMode.CLIENT_PIN_PROMPT, this.bound_.onPINPromptNewPIN);
+
+ this.clickOnMe2MeHost_();
+};
+
+browserTest.Update_PIN.prototype.onPINPromptNewPIN_ = function() {
+ browserTest.waitForUIMode(
+ remoting.AppMode.IN_SESSION, this.bound_.onSessionConnected);
+ document.getElementById('pin-entry').value = this.new_pin_;
+ browserTest.clickOnControl('pin-connect-button');
+};
+
+browserTest.Update_PIN.prototype.onSessionConnected_ = function() {
+ // disconnect the session
+ browserTest.waitForUIMode(
+ remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME,
+ this.bound_.onSessionDisconnected);
+ browserTest.clickOnControl('toolbar-disconnect');
+};
+
+browserTest.Update_PIN.prototype.onSessionDisconnected_ = function() {
+ browserTest.waitForUIMode(
+ remoting.AppMode.CLIENT_PIN_PROMPT, this.bound_.onPINPromptOldPIN);
+ browserTest.clickOnControl('client-finished-me2me-button');
+ this.clickOnMe2MeHost_();
+};
+
+browserTest.Update_PIN.prototype.onPINPromptOldPIN_ = function() {
+ browserTest.waitForUIMode(
+ remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME,
+ this.bound_.onInvalidPIN);
+
+ document.getElementById('pin-entry').value = this.old_pin_;
+ browserTest.clickOnControl('pin-connect-button');
+};
+
+browserTest.Update_PIN.prototype.onInvalidPIN_ = function() {
+ var errorDiv = document.getElementById('connect-error-message');
+ var actual = errorDiv.innerText;
+ var expected = l10n.getTranslationOrError(remoting.Error.INVALID_ACCESS_CODE);
+ browserTest.assert(actual == expected);
+ browserTest.pass();
+};

Powered by Google App Engine
This is Rietveld 408576698