Chromium Code Reviews| Index: remoting/webapp/browser_test/cancel_pin_browser_test.js |
| diff --git a/remoting/webapp/browser_test/cancel_pin_browser_test.js b/remoting/webapp/browser_test/cancel_pin_browser_test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..443bb27d87bccf0075a6bb29959f93421834d15d |
| --- /dev/null |
| +++ b/remoting/webapp/browser_test/cancel_pin_browser_test.js |
| @@ -0,0 +1,73 @@ |
| +// 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. Attempt to connect. |
| + * 2. Hit cancel at the PIN prompt. |
| + * 3. Reconnect with the PIN. |
| + * 4. Verify that the session is connected. |
| + */ |
| + |
| +'use strict'; |
| + |
| +/** @constructor */ |
| +browserTest.Cancel_PIN = function(data) { |
| + browserTest.assert(typeof data.pin == 'string'); |
| + this.data_ = data; |
| + this.bound_ = { |
| + onPINPrompt: this.onPINPrompt_.bind(this), |
| + onPINCancel: this.onPINCancel_.bind(this), |
| + onPINPromptReconnect: this.onPINPromptReconnect_.bind(this), |
| + onSessionConnected: this.onSessionConnected_.bind(this), |
| + onSessionError: this.onSessionError_.bind(this) |
|
Jamie
2014/05/09 01:02:18
I don't think there's a lot of value in pre-bindin
|
| + }; |
| +}; |
| + |
| +browserTest.Cancel_PIN.prototype.run = function() { |
| + browserTest.waitForUIMode( |
| + remoting.AppMode.CLIENT_PIN_PROMPT, |
| + this.bound_.onPINPrompt); |
| + |
| + // Fail the test if there are any connection failures. |
| + browserTest.waitForUIMode( |
| + remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME, |
| + this.bound_.onSessionError); |
|
Jamie
2014/05/09 01:02:18
What's the default time-out for waitForUIMode? If
kelvinp
2014/05/12 21:08:34
Done.
|
| + |
| + this.clickOnMe2MeHost_(); |
| +}; |
| + |
| +browserTest.Cancel_PIN.prototype.clickOnMe2MeHost_ = function() { |
| + browserTest.clickOnControl('this-host-connect'); |
| +}; |
| + |
| +browserTest.Cancel_PIN.prototype.onPINPrompt_ = function() { |
| + browserTest.waitForUIMode( |
| + remoting.AppMode.HOME, this.bound_.onPINCancel); |
| + browserTest.clickOnControl('cancel-pin-entry-button'); |
| +}; |
| + |
| +browserTest.Cancel_PIN.prototype.onPINCancel_ = function() { |
| + browserTest.waitForUIMode( |
| + remoting.AppMode.CLIENT_PIN_PROMPT, this.bound_.onPINPromptReconnect); |
| + this.clickOnMe2MeHost_(); |
| +}; |
| + |
| +browserTest.Cancel_PIN.prototype.onPINPromptReconnect_ = function() { |
| + browserTest.waitForUIMode( |
| + remoting.AppMode.IN_SESSION, this.bound_.onSessionConnected); |
| + document.getElementById('pin-entry').value = this.data_.pin; |
| + browserTest.clickOnControl('pin-connect-button'); |
| +}; |
| + |
| +browserTest.Cancel_PIN.prototype.onSessionConnected_ = function() { |
| + browserTest.pass(); |
| +}; |
| + |
| +browserTest.Cancel_PIN.prototype.onSessionError_= function() { |
| + var errorDiv = document.getElementById('connect-error-message'); |
| + browserTest.fail(errorDiv.innerText); |
| +}; |