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.
7 * Browser test for the scenario below:
8 * 1. Generates an access code.
9 * 2. Launches another chromoting app instance.
10 * 3. Connects with the generated access code.
11 * 4. Verifies that the session is connected.
17 browserTest
.ConnectIt2Me = function() {};
20 * @param {{pin: string, accessCode: string}} data
22 browserTest
.ConnectIt2Me
.prototype.run = function(data
) {
23 browserTest
.expect(typeof data
.accessCode
== 'string',
24 'The access code should be an non-empty string');
25 browserTest
.clickOnControl('get-started-it2me');
27 browserTest
.ConnectIt2Me
.clickOnAccessButton().then(function() {
28 return that
.enterAccessCode_(data
.accessCode
);
30 return browserTest
.disconnect();
33 }, function(/** * */reason
) {
34 browserTest
.fail(/** @type {Error} */(reason
));
38 /** @return {Promise} */
39 browserTest
.ConnectIt2Me
.clickOnAccessButton = function() {
40 browserTest
.clickOnControl('access-mode-button');
41 return browserTest
.onUIMode(remoting
.AppMode
.CLIENT_UNCONNECTED
);
45 * @param {string} code
49 browserTest
.ConnectIt2Me
.prototype.enterAccessCode_ = function(code
) {
50 document
.getElementById('access-code-entry').value
= code
;
51 browserTest
.clickOnControl('connect-button');
52 return browserTest
.expectConnected();
56 browserTest
.InvalidAccessCode = function() {};
59 * @param {{pin: string, accessCode: string}} data
61 browserTest
.InvalidAccessCode
.prototype.run = function(data
) {
62 browserTest
.expect(typeof data
.accessCode
== 'string',
63 'The access code should be an non-empty string');
64 browserTest
.ConnectIt2Me
.clickOnAccessButton().then(function() {
65 document
.getElementById('access-code-entry').value
= data
.accessCode
;
66 browserTest
.clickOnControl('connect-button');
67 var ErrorTag
= remoting
.Error
.Tag
;
68 return browserTest
.expectConnectionError(
69 remoting
.DesktopRemoting
.Mode
.IT2ME
,
70 [ErrorTag
.INVALID_ACCESS_CODE
, ErrorTag
.HOST_IS_OFFLINE
]);
73 }, function(/** * */reason
) {
74 browserTest
.fail(/** @type {Error} */(reason
));
79 browserTest
.GetAccessCode = function() {};
81 browserTest
.GetAccessCode
.prototype.run = function() {
82 browserTest
.clickOnControl('get-started-it2me');
84 // Wait for the email address of the local user to become available. The
85 // email address is required in an It2Me connection for domain policy
86 // enforcement. TODO:(kelvinp) Fix this awkward behavior in the production
87 // code so that this hack is no longer required.
88 remoting
.identity
.getUserInfo().then(function(info
) {
89 browserTest
.clickOnControl('share-button');
91 return browserTest
.onUIMode(remoting
.AppMode
.HOST_WAITING_FOR_CONNECTION
);
93 var accessCode
= document
.getElementById('access-code-display').innerText
;
94 var numericAccessCode
= parseFloat(accessCode
);
95 browserTest
.expect(accessCode
.length
=== 12,
96 "The access code should be 12 digits long.");
98 Number
.isInteger(numericAccessCode
) && numericAccessCode
> 0,
99 "The access code should be a positive integer.");
101 }).catch(function(/** Error */ reason
) {
102 browserTest
.fail(reason
);
107 browserTest
.CancelShare = function() {};
109 browserTest
.CancelShare
.prototype.run = function() {
110 browserTest
.clickOnControl('cancel-share-button');
111 browserTest
.onUIMode(remoting
.AppMode
.HOST_SHARE_FINISHED
).then(function() {
113 }).catch(function(/** Error */ reason
) {
114 browserTest
.fail(reason
);