Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * @suppress {checkTypes} | 7 * @suppress {checkTypes} |
| 8 * Browser test for the scenario below: | 8 * Browser test for the scenario below: |
| 9 * 1. Change the PIN. | 9 * 1. Change the PIN. |
| 10 * 2. Connect with the new PIN. | 10 * 2. Connect with the new PIN. |
| 11 * 3. Verify the connection succeeded. | 11 * 3. Verify the connection succeeded. |
| 12 * 4. Disconnect and reconnect with the old PIN. | 12 * 4. Disconnect and reconnect with the old PIN. |
| 13 * 5. Verify the connection failed. | 13 * 5. Verify the connection failed. |
| 14 */ | 14 */ |
| 15 | 15 |
| 16 'use strict'; | 16 'use strict'; |
| 17 | 17 |
| 18 /** @constructor */ | 18 /** @constructor */ |
| 19 browserTest.Update_PIN = function() {}; | 19 browserTest.Update_PIN = function() {}; |
| 20 | 20 |
| 21 browserTest.Update_PIN.prototype.run = function(data) { | 21 browserTest.Update_PIN.prototype.run = function(data) { |
| 22 var LOGIN_BACKOFF_WAIT = 2000; | 22 var LOGIN_BACKOFF_WAIT = 2000; |
| 23 // Input validation | 23 // Input validation |
| 24 browserTest.expect(typeof data.new_pin == 'string'); | 24 browserTest.expect(typeof data.new_pin == 'string'); |
| 25 browserTest.expect(typeof data.old_pin == 'string'); | 25 browserTest.expect(typeof data.old_pin == 'string'); |
| 26 browserTest.expect(data.new_pin != data.old_pin, | 26 browserTest.expect(data.new_pin != data.old_pin, |
| 27 'The new PIN and the old PIN cannot be the same'); | 27 'The new PIN and the old PIN cannot be the same'); |
| 28 | 28 |
| 29 this.changePIN_(data.new_pin).then( | 29 this.changePIN_(data.new_pin).then( |
| 30 this.connect_.bind(this) | 30 browserTest.connectMe2Me |
| 31 ).then( | 31 ).then( |
| 32 this.enterPIN_.bind(this, data.old_pin, true /* expectError*/) | 32 this.enterPIN_.bind(this, data.old_pin, true /* expectError*/) |
| 33 ).then( | 33 ).then( |
| 34 // Sleep for two seconds to allow for the login backoff logic to reset. | 34 // Sleep for two seconds to allow for the login backoff logic to reset. |
| 35 base.Promise.sleep.bind(null, LOGIN_BACKOFF_WAIT) | 35 base.Promise.sleep.bind(null, LOGIN_BACKOFF_WAIT) |
| 36 ).then( | 36 ).then( |
| 37 this.connect_.bind(this) | 37 browserTest.connectMe2Me |
| 38 ).then( | 38 ).then( |
| 39 this.enterPIN_.bind(this, data.new_pin, false /* expectError*/) | 39 this.enterPIN_.bind(this, data.new_pin, false /* expectError*/) |
| 40 ).then( | 40 ).then( |
| 41 // Clean up the test by disconnecting and changing the PIN back | 41 // Clean up the test by disconnecting and changing the PIN back |
| 42 this.disconnect_.bind(this) | 42 browserTest.connectMe2Me |
|
Jamie
2014/07/11 19:33:22
Is this a copy/paste error? The previous code was
kelvinp
2014/07/11 21:11:22
My bad. Good catch.
| |
| 43 ).then( | 43 ).then( |
| 44 // The PIN must be restored regardless of success or failure. | 44 // The PIN must be restored regardless of success or failure. |
| 45 this.changePIN_.bind(this, data.old_pin), | 45 this.changePIN_.bind(this, data.old_pin), |
| 46 this.changePIN_.bind(this, data.old_pin) | 46 this.changePIN_.bind(this, data.old_pin) |
| 47 ).then( | 47 ).then( |
| 48 // On fulfilled. | 48 // On fulfilled. |
| 49 browserTest.pass, | 49 browserTest.pass, |
| 50 // On rejected. | 50 // On rejected. |
| 51 browserTest.fail | 51 browserTest.fail |
| 52 ); | 52 ); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 65 browserTest.clickOnControl('daemon-pin-ok'); | 65 browserTest.clickOnControl('daemon-pin-ok'); |
| 66 return onSetupDone; | 66 return onSetupDone; |
| 67 }).then(function() { | 67 }).then(function() { |
| 68 browserTest.clickOnControl('host-config-done-dismiss'); | 68 browserTest.clickOnControl('host-config-done-dismiss'); |
| 69 // On Linux, we restart the host after changing the PIN, need to sleep | 69 // On Linux, we restart the host after changing the PIN, need to sleep |
| 70 // for ten seconds before the host is ready for connection. | 70 // for ten seconds before the host is ready for connection. |
| 71 return base.Promise.sleep(HOST_RESTART_WAIT); | 71 return base.Promise.sleep(HOST_RESTART_WAIT); |
| 72 }); | 72 }); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 browserTest.Update_PIN.prototype.connect_ = function() { | |
| 76 browserTest.clickOnControl('this-host-connect'); | |
| 77 return browserTest.onUIMode(remoting.AppMode.CLIENT_PIN_PROMPT); | |
| 78 }; | |
| 79 | |
| 80 browserTest.Update_PIN.prototype.disconnect_ = function() { | 75 browserTest.Update_PIN.prototype.disconnect_ = function() { |
| 81 var AppMode = remoting.AppMode; | 76 var AppMode = remoting.AppMode; |
| 82 | 77 |
| 83 remoting.disconnect(); | 78 remoting.disconnect(); |
| 84 | 79 |
| 85 return browserTest.onUIMode(AppMode.CLIENT_SESSION_FINISHED_ME2ME) | 80 return browserTest.onUIMode(AppMode.CLIENT_SESSION_FINISHED_ME2ME) |
| 86 .then(function() { | 81 .then(function() { |
| 87 var onHome = browserTest.onUIMode(AppMode.HOME); | 82 var onHome = browserTest.onUIMode(AppMode.HOME); |
| 88 browserTest.clickOnControl('client-finished-me2me-button'); | 83 browserTest.clickOnControl('client-finished-me2me-button'); |
| 89 return onHome; | 84 return onHome; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 100 return base.Promise.sleep(CONNECT_PIN_WAIT).then(function() { | 95 return base.Promise.sleep(CONNECT_PIN_WAIT).then(function() { |
| 101 browserTest.clickOnControl('pin-connect-button'); | 96 browserTest.clickOnControl('pin-connect-button'); |
| 102 }).then(function() { | 97 }).then(function() { |
| 103 if (expectError) { | 98 if (expectError) { |
| 104 return browserTest.expectMe2MeError(remoting.Error.INVALID_ACCESS_CODE); | 99 return browserTest.expectMe2MeError(remoting.Error.INVALID_ACCESS_CODE); |
| 105 } else { | 100 } else { |
| 106 return browserTest.expectMe2MeConnected(); | 101 return browserTest.expectMe2MeConnected(); |
| 107 } | 102 } |
| 108 }); | 103 }); |
| 109 }; | 104 }; |
| OLD | NEW |