OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 /** | |
6 * @fileoverview | |
7 * @suppress {checkTypes} | |
8 * Browser test for the scenario below: | |
9 * 1. Attempt to connect. | |
10 * 2. Enter |data.pin| at the PIN prompt. | |
11 * 3. Verify that there is connection error due to invalid access code. | |
12 */ | |
13 | |
14 'use strict'; | |
15 | |
16 /** @constructor */ | |
17 browserTest.Invalid_PIN = function(data) { | |
18 browserTest.assert(typeof data.pin == 'string'); | |
19 | |
20 this.data_ = data; | |
21 this.bound_ = { | |
22 onPINPrompt: this.onPINPrompt_.bind(this), | |
23 onSessionConnected: this.onSessionConnected_.bind(this), | |
24 onSessionError: this.onSessionError_.bind(this) | |
25 }; | |
26 }; | |
27 | |
28 browserTest.Invalid_PIN.prototype.run = function() { | |
29 browserTest.waitForUIMode( | |
30 remoting.AppMode.CLIENT_PIN_PROMPT, | |
31 this.bound_.onPINPrompt); | |
32 this.clickOnMe2MeHost_(); | |
33 }; | |
34 | |
35 browserTest.Invalid_PIN.prototype.clickOnMe2MeHost_ = function() { | |
36 browserTest.clickOnControl('this-host-connect'); | |
37 }; | |
38 | |
39 browserTest.Invalid_PIN.prototype.onPINPrompt_ = function() { | |
40 browserTest.waitForUIMode( | |
41 remoting.AppMode.IN_SESSION, this.bound_.onSessionConnected, | |
42 browserTest.Timeout.NONE); | |
43 | |
44 browserTest.waitForUIMode( | |
45 remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME, | |
46 this.bound_.onSessionError); | |
47 | |
48 document.getElementById('pin-entry').value = this.data_.pin; | |
49 browserTest.clickOnControl('pin-connect-button'); | |
50 }; | |
51 | |
52 browserTest.Invalid_PIN.prototype.onSessionConnected_ = function() { | |
53 browserTest.fail('Expect the session to disconnect due to invalid PIN.'); | |
54 }; | |
55 | |
56 browserTest.Invalid_PIN.prototype.onSessionError_= function() { | |
57 var errorDiv = document.getElementById('connect-error-message'); | |
58 var actual = errorDiv.innerText; | |
59 var expected = l10n.getTranslationOrError(remoting.Error.INVALID_ACCESS_CODE); | |
60 browserTest.assert(actual == expected); | |
Jamie
2014/05/09 01:02:18
This should not be an assertion. If the error is n
kelvinp
2014/05/12 21:08:34
Rename to expect equal
| |
61 browserTest.pass(); | |
62 }; | |
OLD | NEW |