| 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. Generates an access code. | 9 * 1. Generates an access code. |
| 10 * 2. Launches another chromoting app instance. | 10 * 2. Launches another chromoting app instance. |
| 11 * 3. Connects with the generated access code. | 11 * 3. Connects with the generated access code. |
| 12 * 4. Verifies that the session is connected. | 12 * 4. Verifies that the session is connected. |
| 13 */ | 13 */ |
| 14 | 14 |
| 15 'use strict'; | 15 'use strict'; |
| 16 | 16 |
| 17 /** @constructor */ | 17 /** @constructor */ |
| 18 browserTest.ConnectIt2Me = function() {}; | 18 browserTest.ConnectIt2Me = function() {}; |
| 19 | 19 |
| 20 /** |
| 21 * @param {{pin: string, accessCode: string}} data |
| 22 */ |
| 20 browserTest.ConnectIt2Me.prototype.run = function(data) { | 23 browserTest.ConnectIt2Me.prototype.run = function(data) { |
| 21 browserTest.expect(typeof data.accessCode == 'string', | 24 browserTest.expect(typeof data.accessCode == 'string', |
| 22 'The access code should be an non-empty string'); | 25 'The access code should be an non-empty string'); |
| 23 browserTest.clickOnControl('get-started-it2me'); | 26 browserTest.clickOnControl('get-started-it2me'); |
| 24 var that = this; | 27 var that = this; |
| 25 browserTest.ConnectIt2Me.clickOnAccessButton().then(function() { | 28 browserTest.ConnectIt2Me.clickOnAccessButton().then(function() { |
| 26 return that.enterAccessCode_(data.accessCode); | 29 return that.enterAccessCode_(data.accessCode); |
| 27 }).then(function() { | 30 }).then(function() { |
| 28 return browserTest.disconnect(); | 31 return browserTest.disconnect(); |
| 29 }).then(function() { | 32 }).then(function() { |
| 30 browserTest.pass(); | 33 browserTest.pass(); |
| 34 /** @param {*} reason */ |
| 31 }, function(reason) { | 35 }, function(reason) { |
| 32 browserTest.fail(reason); | 36 browserTest.fail(reason); |
| 33 }); | 37 }); |
| 34 }; | 38 }; |
| 35 | 39 |
| 40 /** @return {Promise} */ |
| 36 browserTest.ConnectIt2Me.clickOnAccessButton = function() { | 41 browserTest.ConnectIt2Me.clickOnAccessButton = function() { |
| 37 browserTest.clickOnControl('access-mode-button'); | 42 browserTest.clickOnControl('access-mode-button'); |
| 38 return browserTest.onUIMode(remoting.AppMode.CLIENT_UNCONNECTED); | 43 return browserTest.onUIMode(remoting.AppMode.CLIENT_UNCONNECTED); |
| 39 }; | 44 }; |
| 40 | 45 |
| 41 /** @private */ | 46 /** |
| 47 * @param {string} code |
| 48 * @return {Promise} |
| 49 * @private |
| 50 */ |
| 42 browserTest.ConnectIt2Me.prototype.enterAccessCode_ = function(code) { | 51 browserTest.ConnectIt2Me.prototype.enterAccessCode_ = function(code) { |
| 43 document.getElementById('access-code-entry').value = code; | 52 document.getElementById('access-code-entry').value = code; |
| 44 browserTest.clickOnControl('connect-button'); | 53 browserTest.clickOnControl('connect-button'); |
| 45 return browserTest.expectConnected(); | 54 return browserTest.expectConnected(); |
| 46 }; | 55 }; |
| 47 | 56 |
| 48 /** @constructor */ | 57 /** @constructor */ |
| 49 browserTest.InvalidAccessCode = function() {}; | 58 browserTest.InvalidAccessCode = function() {}; |
| 50 | 59 |
| 60 /** |
| 61 * @param {{pin: string, accessCode: string}} data |
| 62 */ |
| 51 browserTest.InvalidAccessCode.prototype.run = function(data) { | 63 browserTest.InvalidAccessCode.prototype.run = function(data) { |
| 52 browserTest.expect(typeof data.accessCode == 'string', | 64 browserTest.expect(typeof data.accessCode == 'string', |
| 53 'The access code should be an non-empty string'); | 65 'The access code should be an non-empty string'); |
| 54 browserTest.ConnectIt2Me.clickOnAccessButton().then(function() { | 66 browserTest.ConnectIt2Me.clickOnAccessButton().then(function() { |
| 55 document.getElementById('access-code-entry').value = data.accessCode; | 67 document.getElementById('access-code-entry').value = data.accessCode; |
| 56 browserTest.clickOnControl('connect-button'); | 68 browserTest.clickOnControl('connect-button'); |
| 57 return browserTest.expectConnectionError( | 69 return browserTest.expectConnectionError( |
| 58 remoting.ClientSession.Mode.IT2ME, remoting.Error.INVALID_ACCESS_CODE); | 70 remoting.DesktopConnectedView.Mode.IT2ME, |
| 71 remoting.Error.INVALID_ACCESS_CODE); |
| 59 }).then(function() { | 72 }).then(function() { |
| 60 browserTest.pass(); | 73 browserTest.pass(); |
| 61 }, function(reason) { | 74 }, function(reason) { |
| 62 browserTest.fail(reason); | 75 browserTest.fail(reason); |
| 63 }); | 76 }); |
| 64 }; | 77 }; |
| 65 | 78 |
| 66 /** @constructor */ | 79 /** @constructor */ |
| 67 browserTest.GetAccessCode = function() {}; | 80 browserTest.GetAccessCode = function() {}; |
| 68 | 81 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 79 "The access code should be 12 digits long."); | 92 "The access code should be 12 digits long."); |
| 80 browserTest.expect( | 93 browserTest.expect( |
| 81 Number.isInteger(numericAccessCode) && numericAccessCode > 0, | 94 Number.isInteger(numericAccessCode) && numericAccessCode > 0, |
| 82 "The access code should be a positive integer."); | 95 "The access code should be a positive integer."); |
| 83 browserTest.pass(accessCode); | 96 browserTest.pass(accessCode); |
| 84 },function(reason) { | 97 },function(reason) { |
| 85 browserTest.fail(reason); | 98 browserTest.fail(reason); |
| 86 }); | 99 }); |
| 87 }; | 100 }; |
| 88 | 101 |
| 89 // Wait for the email address of the local user to become available. The email | 102 /** |
| 90 // address is required in an It2Me connection for domain policy enforcement. | 103 * Wait for the email address of the local user to become available. The email |
| 91 // TODO:(kelvinp) Fix this awkward behavior in the production code so that this | 104 * address is required in an It2Me connection for domain policy enforcement. |
| 92 // hack is no longer required. | 105 * TODO:(kelvinp) Fix this awkward behavior in the production code so that this |
| 93 /** @private */ | 106 * hack is no longer required. |
| 107 * |
| 108 * @return {Promise} |
| 109 * @private |
| 110 */ |
| 94 browserTest.GetAccessCode.prototype.onUserInfoReady_ = function() { | 111 browserTest.GetAccessCode.prototype.onUserInfoReady_ = function() { |
| 95 return new Promise(function(resolve, reject){ | 112 return new Promise(function(resolve, reject){ |
| 96 remoting.identity.getUserInfo(resolve, reject); | 113 remoting.identity.getUserInfo(resolve, reject); |
| 97 }); | 114 }); |
| 98 }; | 115 }; |
| OLD | NEW |