blob: dc04dfd08d2b95eb93cae528114c8ff269be478b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview
* Browser test for the scenario below:
* 1. Generates an access code.
* 2. Launches another chromoting app instance.
* 3. Connects with the generated access code.
* 4. Verifies that the session is connected.
*/
'use strict';
/** @constructor */
browserTest.ConnectIt2Me = function() {};
/**
* @param {{pin: string, accessCode: string}} data
*/
browserTest.ConnectIt2Me.prototype.run = function(data) {
browserTest.expect(typeof data.accessCode == 'string',
'The access code should be an non-empty string');
browserTest.clickOnControl('get-started-it2me');
var that = this;
browserTest.ConnectIt2Me.clickOnAccessButton().then(function() {
return that.enterAccessCode_(data.accessCode);
}).then(function() {
return browserTest.disconnect();
}).then(function() {
browserTest.pass();
}, function(/** * */reason) {
browserTest.fail(/** @type {Error} */(reason));
});
};
/** @return {Promise} */
browserTest.ConnectIt2Me.clickOnAccessButton = function() {
browserTest.clickOnControl('access-mode-button');
return browserTest.onUIMode(remoting.AppMode.CLIENT_UNCONNECTED);
};
/**
* @param {string} code
* @return {Promise}
* @private
*/
browserTest.ConnectIt2Me.prototype.enterAccessCode_ = function(code) {
document.getElementById('access-code-entry').value = code;
browserTest.clickOnControl('connect-button');
return browserTest.expectConnected();
};
/** @constructor */
browserTest.InvalidAccessCode = function() {};
/**
* @param {{pin: string, accessCode: string}} data
*/
browserTest.InvalidAccessCode.prototype.run = function(data) {
browserTest.expect(typeof data.accessCode == 'string',
'The access code should be an non-empty string');
browserTest.ConnectIt2Me.clickOnAccessButton().then(function() {
document.getElementById('access-code-entry').value = data.accessCode;
browserTest.clickOnControl('connect-button');
var ErrorTag = remoting.Error.Tag;
return browserTest.expectConnectionError(
remoting.DesktopRemoting.Mode.IT2ME,
[ErrorTag.INVALID_ACCESS_CODE, ErrorTag.HOST_IS_OFFLINE]);
}).then(function() {
browserTest.pass();
}, function(/** * */reason) {
browserTest.fail(/** @type {Error} */(reason));
});
};
/** @constructor */
browserTest.GetAccessCode = function() {};
browserTest.GetAccessCode.prototype.run = function() {
browserTest.clickOnControl('get-started-it2me');
// Wait for the email address of the local user to become available. The
// email address is required in an It2Me connection for domain policy
// enforcement. TODO:(kelvinp) Fix this awkward behavior in the production
// code so that this hack is no longer required.
remoting.identity.getUserInfo().then(function(info) {
browserTest.clickOnControl('share-button');
}).then(function(){
return browserTest.onUIMode(remoting.AppMode.HOST_WAITING_FOR_CONNECTION);
}).then(function() {
var accessCode = document.getElementById('access-code-display').innerText;
var numericAccessCode = parseFloat(accessCode);
browserTest.expect(accessCode.length === 12,
"The access code should be 12 digits long.");
browserTest.expect(
Number.isInteger(numericAccessCode) && numericAccessCode > 0,
"The access code should be a positive integer.");
browserTest.pass();
}).catch(function(/** Error */ reason) {
browserTest.fail(reason);
});
};
/** @constructor */
browserTest.CancelShare = function() {};
browserTest.CancelShare.prototype.run = function() {
browserTest.clickOnControl('cancel-share-button');
browserTest.onUIMode(remoting.AppMode.HOST_SHARE_FINISHED).then(function() {
browserTest.pass();
}).catch(function(/** Error */ reason) {
browserTest.fail(reason);
});
};
|