OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 /** | |
6 * @fileoverview | |
7 * @suppress {checkTypes} | |
8 * Browser test for the scenario below: | |
9 * 1. Generates an access code. | |
10 * 2. Launches another chromoting app instance. | |
11 * 3. Connects with the generated access code. | |
12 * 4. Verifies that the session is connected. | |
13 */ | |
14 | |
15 'use strict'; | |
16 | |
17 /** @constructor */ | |
18 browserTest.CONNECT_IT2ME = function() {}; | |
19 | |
20 browserTest.CONNECT_IT2ME.prototype.run = function(data) { | |
21 browserTest.expect(typeof data.accessCode == 'string', | |
22 'The access code should be an non-empty string'); | |
23 browserTest.clickOnControl('get-started-it2me'); | |
24 var that = this; | |
25 this.clickOnAccessButton().then(function() { | |
26 return that.enterAccessCode(data.accessCode); | |
27 }).then(function() { | |
28 return browserTest.disconnect(); | |
29 }).then(function() { | |
30 browserTest.pass(); | |
31 }, function(reason) { | |
32 browserTest.fail(reason); | |
33 }); | |
34 }; | |
35 | |
36 browserTest.CONNECT_IT2ME.prototype.clickOnAccessButton = function() { | |
Jamie
2015/01/06 22:18:52
These two methods (and onUserInfoReady) should be
kelvinp
2015/01/09 22:21:30
Done.
Jamie
2015/01/10 00:14:23
No you haven't ;)
| |
37 browserTest.clickOnControl('access-mode-button'); | |
38 return browserTest.onUIMode(remoting.AppMode.CLIENT_UNCONNECTED); | |
39 }; | |
40 | |
41 browserTest.CONNECT_IT2ME.prototype.enterAccessCode = function(code) { | |
42 document.getElementById('access-code-entry').value = code; | |
43 browserTest.clickOnControl('connect-button'); | |
44 return browserTest.expectConnected(); | |
45 }; | |
46 | |
47 /** @constructor */ | |
48 browserTest.GET_ACCESS_CODE = function() {}; | |
49 | |
50 browserTest.GET_ACCESS_CODE.prototype.run = function() { | |
51 browserTest.clickOnControl('get-started-it2me'); | |
52 this.onUserInfoReady().then(function() { | |
53 browserTest.clickOnControl('share-button'); | |
54 }).then(function(){ | |
55 return browserTest.onUIMode(remoting.AppMode.HOST_WAITING_FOR_CONNECTION); | |
56 }).then(function() { | |
57 var accessCode = document.getElementById('access-code-display').innerText; | |
58 browserTest.expect(accessCode.length === 12, | |
59 "The access code should be 12 digits long."); | |
60 browserTest.expect(!isNaN(accessCode), | |
61 "The access code should be numeric."); | |
Jamie
2015/01/06 22:18:52
It has to be a positive integer, so this test coul
kelvinp
2015/01/09 22:21:30
Done.
| |
62 browserTest.pass(accessCode); | |
63 },function(reason) { | |
64 browserTest.fail(reason); | |
65 }); | |
66 }; | |
67 | |
68 // Wait for the email address of the local user to become available. The email | |
69 // address is required in an It2Me connection for domain policy enforcement. | |
70 browserTest.GET_ACCESS_CODE.prototype.onUserInfoReady = function() { | |
71 return new Promise(function(resolve, reject){ | |
72 remoting.identity.getUserInfo(resolve, reject); | |
Jamie
2015/01/06 22:18:52
getUserInfo doesn't cache anything, so I'm not sur
kelvinp
2015/01/09 22:21:30
It2me currently calls getCachedEmail() to provide
| |
73 }); | |
74 }; | |
OLD | NEW |