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