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. Change the PIN. | |
10 * 2. Connect with the new PIN. | |
11 * 3. Verify the connection succeeded. | |
12 * 4. Disconnect and reconnect with the old PIN. | |
13 * 5. Verify the connection failed. | |
14 */ | |
15 | |
16 'use strict'; | |
17 | |
18 /** @constructor */ | |
19 browserTest.Update_PIN = function(data) { | |
20 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.
| |
21 this.old_pin_ = data.old_pin; | |
22 this.new_pin_ = data.new_pin; | |
23 | |
24 browserTest.assert(this.new_pin_ != this.old_pin_, | |
25 'The new PIN and the old PIN cannot be the same'); | |
26 | |
27 this.bound_ = { | |
28 onPINSetup: this.onPINSetup_.bind(this), | |
29 onPINChanged: this.onPINChanged_.bind(this), | |
30 onPINPromptOldPIN: this.onPINPromptOldPIN_.bind(this), | |
31 onInvalidPIN: this.onInvalidPIN_.bind(this), | |
32 onPINPromptNewPIN: this.onPINPromptNewPIN_.bind(this), | |
33 onSessionConnected: this.onSessionConnected_.bind(this), | |
34 onSessionDisconnected: this.onSessionDisconnected_.bind(this) | |
35 }; | |
36 }; | |
37 | |
38 browserTest.Update_PIN.prototype.run = function() { | |
39 browserTest.waitForUIMode( | |
40 remoting.AppMode.HOST_SETUP_ASK_PIN, | |
41 this.bound_.onPINSetup); | |
42 browserTest.clickOnControl('change-daemon-pin'); | |
43 }; | |
44 | |
45 browserTest.Update_PIN.prototype.clickOnMe2MeHost_ = function() { | |
46 browserTest.clickOnControl('this-host-connect'); | |
47 }; | |
48 | |
49 browserTest.Update_PIN.prototype.onPINSetup_ = function() { | |
50 browserTest.waitForUIMode( | |
51 remoting.AppMode.HOST_SETUP_DONE, this.bound_.onPINChanged); | |
52 | |
53 document.getElementById('daemon-pin-entry').value = this.new_pin_; | |
54 document.getElementById('daemon-pin-confirm').value = this.new_pin_; | |
55 browserTest.clickOnControl('daemon-pin-ok'); | |
56 }; | |
57 | |
58 browserTest.Update_PIN.prototype.onPINChanged_ = function() { | |
59 browserTest.clickOnControl('host-config-done-dismiss'); | |
60 | |
61 // 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.
| |
62 // seconds so that the host can be ready for new connections again. | |
63 // TODO(kelvinp): Is there a better way to detect whether the host is ready | |
64 // 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
| |
65 window.setTimeout(this.connectWithNewPIN_.bind(this), 30000); | |
66 }; | |
67 | |
68 browserTest.Update_PIN.prototype.connectWithNewPIN_ = function() { | |
69 // Need to test for the success case first because connecting with an | |
70 // 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
| |
71 browserTest.waitForUIMode( | |
72 remoting.AppMode.CLIENT_PIN_PROMPT, this.bound_.onPINPromptNewPIN); | |
73 | |
74 this.clickOnMe2MeHost_(); | |
75 }; | |
76 | |
77 browserTest.Update_PIN.prototype.onPINPromptNewPIN_ = function() { | |
78 browserTest.waitForUIMode( | |
79 remoting.AppMode.IN_SESSION, this.bound_.onSessionConnected); | |
80 document.getElementById('pin-entry').value = this.new_pin_; | |
81 browserTest.clickOnControl('pin-connect-button'); | |
82 }; | |
83 | |
84 browserTest.Update_PIN.prototype.onSessionConnected_ = function() { | |
85 // disconnect the session | |
86 browserTest.waitForUIMode( | |
87 remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME, | |
88 this.bound_.onSessionDisconnected); | |
89 browserTest.clickOnControl('toolbar-disconnect'); | |
90 }; | |
91 | |
92 browserTest.Update_PIN.prototype.onSessionDisconnected_ = function() { | |
93 browserTest.waitForUIMode( | |
94 remoting.AppMode.CLIENT_PIN_PROMPT, this.bound_.onPINPromptOldPIN); | |
95 browserTest.clickOnControl('client-finished-me2me-button'); | |
96 this.clickOnMe2MeHost_(); | |
97 }; | |
98 | |
99 browserTest.Update_PIN.prototype.onPINPromptOldPIN_ = function() { | |
100 browserTest.waitForUIMode( | |
101 remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME, | |
102 this.bound_.onInvalidPIN); | |
103 | |
104 document.getElementById('pin-entry').value = this.old_pin_; | |
105 browserTest.clickOnControl('pin-connect-button'); | |
106 }; | |
107 | |
108 browserTest.Update_PIN.prototype.onInvalidPIN_ = function() { | |
109 var errorDiv = document.getElementById('connect-error-message'); | |
110 var actual = errorDiv.innerText; | |
111 var expected = l10n.getTranslationOrError(remoting.Error.INVALID_ACCESS_CODE); | |
112 browserTest.assert(actual == expected); | |
113 browserTest.pass(); | |
114 }; | |
OLD | NEW |