Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: remoting/webapp/browser_test/it2me_browser_test.js

Issue 838543002: Implement browser test for It2Me (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix merge conflicts Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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.ConnectIt2Me = function() {};
19
20 browserTest.ConnectIt2Me.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 browserTest.ConnectIt2Me.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.ConnectIt2Me.clickOnAccessButton = function() {
37 browserTest.clickOnControl('access-mode-button');
38 return browserTest.onUIMode(remoting.AppMode.CLIENT_UNCONNECTED);
39 };
40
41 /** @private */
42 browserTest.ConnectIt2Me.prototype.enterAccessCode_ = function(code) {
43 document.getElementById('access-code-entry').value = code;
44 browserTest.clickOnControl('connect-button');
45 return browserTest.expectConnected();
46 };
47
48 /** @constructor */
49 browserTest.InvalidAccessCode = function() {};
50
51 browserTest.InvalidAccessCode.prototype.run = function(data) {
52 browserTest.expect(typeof data.accessCode == 'string',
53 'The access code should be an non-empty string');
54 browserTest.ConnectIt2Me.clickOnAccessButton().then(function() {
55 document.getElementById('access-code-entry').value = data.accessCode;
56 browserTest.clickOnControl('connect-button');
57 return browserTest.expectConnectionError(
58 remoting.ClientSession.Mode.IT2ME, remoting.Error.INVALID_ACCESS_CODE);
59 }).then(function() {
60 browserTest.pass();
61 }, function(reason) {
62 browserTest.fail(reason);
63 });
64 };
65
66 /** @constructor */
67 browserTest.GetAccessCode = function() {};
68
69 browserTest.GetAccessCode.prototype.run = function() {
70 browserTest.clickOnControl('get-started-it2me');
71 this.onUserInfoReady_().then(function() {
72 browserTest.clickOnControl('share-button');
73 }).then(function(){
74 return browserTest.onUIMode(remoting.AppMode.HOST_WAITING_FOR_CONNECTION);
75 }).then(function() {
76 var accessCode = document.getElementById('access-code-display').innerText;
77 var numericAccessCode = parseFloat(accessCode);
78 browserTest.expect(accessCode.length === 12,
79 "The access code should be 12 digits long.");
80 browserTest.expect(
81 Number.isInteger(numericAccessCode) && numericAccessCode > 0,
82 "The access code should be a positive integer.");
83 browserTest.pass(accessCode);
84 },function(reason) {
85 browserTest.fail(reason);
86 });
87 };
88
89 // Wait for the email address of the local user to become available. The email
90 // address is required in an It2Me connection for domain policy enforcement.
91 // TODO:(kelvinp) Fix this awkward behavior in the production code so that this
92 // hack is no longer required.
93 /** @private */
94 browserTest.GetAccessCode.prototype.onUserInfoReady_ = function() {
95 return new Promise(function(resolve, reject){
96 remoting.identity.getUserInfo(resolve, reject);
97 });
98 };
OLDNEW
« no previous file with comments | « remoting/webapp/browser_test/browser_test.js ('k') | remoting/webapp/browser_test/timeout_waiter.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698