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

Side by Side Diff: remoting/webapp/unittests/it2me_helpee_channel_unittest.js

Issue 973333002: Remove Hangout Remote Desktop integration code from the webapp. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + manifest changes Created 5 years, 9 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|checkVars|reportUnknownTypes|visibility}
8 */
9
10 (function() {
11
12 'use strict';
13
14 var hostInstaller = null;
15 var hangoutPort = null;
16 var host = null;
17 var helpeeChannel = null;
18 var onDisposedCallback = null;
19
20 module('It2MeHelpeeChannel', {
21 setup: function() {
22 // HangoutPort
23 hangoutPort = new chromeMocks.runtime.Port();
24 hangoutPort.postMessage = sinon.spy(hangoutPort, 'postMessage');
25 hangoutPort.disconnect = sinon.spy(hangoutPort, 'disconnect');
26
27 // onDisposedCallback callback
28 onDisposedCallback = sinon.spy();
29
30 // Host
31 host = {
32 initialize: function() {},
33 initialized: function() {},
34 connect: function() {},
35 disconnect: function() {},
36 getAccessCode: function() {},
37 unhookCallbacks: function() {}
38 };
39
40 // HostInstaller
41 hostInstaller = {
42 download: function() {}
43 };
44
45 // HelpeeChannel
46 helpeeChannel = new remoting.It2MeHelpeeChannel(
47 hangoutPort,
48 host,
49 hostInstaller,
50 onDisposedCallback);
51 helpeeChannel.init();
52
53 // remoting.settings
54 remoting.settings = new remoting.Settings();
55 remoting.identity = new remoting.Identity();
56 },
57 tearDown: function() {
58 remoting.settings = null;
59 remoting.identity = null;
60 }
61 });
62
63 test('hello() should return supportedFeatures', function() {
64 hangoutPort.onMessage.mock$fire(
65 { method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.HELLO });
66
67 sinon.assert.calledWith(hangoutPort.postMessage, {
68 method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.HELLO_RESPONSE,
69 supportedFeatures: base.values(remoting.It2MeHelperChannel.Features)
70 });
71 });
72
73 QUnit.asyncTest(
74 'isHostInstalled() should return false if host is not installed',
75 function() {
76 sinon.stub(remoting.HostInstaller, 'isInstalled')
77 .returns(Promise.resolve(false));
78
79 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes;
80 hangoutPort.onMessage.mock$fire({
81 method: MessageTypes.IS_HOST_INSTALLED
82 });
83
84 window.requestAnimationFrame(function() {
85 remoting.HostInstaller.isInstalled.restore();
86 sinon.assert.calledWith(hangoutPort.postMessage, {
87 method: MessageTypes.IS_HOST_INSTALLED_RESPONSE,
88 result: false
89 });
90 QUnit.start();
91 });
92 });
93
94 QUnit.asyncTest('isHostInstalled() should return true if host is installed',
95 function() {
96 sinon.stub(remoting.HostInstaller, 'isInstalled')
97 .returns(Promise.resolve(true));
98
99 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes;
100 hangoutPort.onMessage.mock$fire({
101 method: MessageTypes.IS_HOST_INSTALLED
102 });
103
104 window.requestAnimationFrame(function() {
105 remoting.HostInstaller.isInstalled.restore();
106 sinon.assert.calledWith(hangoutPort.postMessage, {
107 method: MessageTypes.IS_HOST_INSTALLED_RESPONSE,
108 result: true
109 });
110 QUnit.start();
111 });
112 });
113
114 test('downloadHost() should trigger a host download',
115 function() {
116 sinon.stub(hostInstaller, 'download').returns(Promise.resolve(true));
117
118 hangoutPort.onMessage.mock$fire({
119 method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.DOWNLOAD_HOST
120 });
121
122 sinon.assert.called(hostInstaller.download);
123 });
124
125 QUnit.asyncTest('connect() should return access code',
126 function() {
127 // Stubs authentication.
128 sinon.stub(base, 'isAppsV2').returns(true);
129 sinon.stub(chrome.identity, 'getAuthToken')
130 .callsArgWith(1, 'token');
131 sinon.stub(remoting.identity, 'getToken')
132 .returns(Promise.resolve('token'));
133 sinon.stub(remoting.identity, 'getEmail')
134 .returns(Promise.resolve('test@chromium.org'));
135 // Stubs Host behavior.
136 sinon.stub(host, 'initialized').returns(true);
137 sinon.stub(host, 'connect')
138 .callsArgWith(2, remoting.HostSession.State.RECEIVED_ACCESS_CODE);
139 sinon.stub(host, 'getAccessCode').returns('accessCode');
140
141 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes;
142 hangoutPort.onMessage.mock$fire({
143 method: MessageTypes.CONNECT,
144 hangoutBounds: {widht: 10, height: 10, left:10, top: 10}
145 });
146
147 window.requestAnimationFrame(function(){
148 // Verify that access code is correct in the response.
149 sinon.assert.calledWithMatch(hangoutPort.postMessage, {
150 method: MessageTypes.CONNECT_RESPONSE,
151 accessCode: 'accessCode'
152 });
153
154 chrome.identity.getAuthToken.restore();
155 base.isAppsV2.restore();
156 QUnit.start();
157 });
158 });
159
160 test('should disconnect the session if Hangout crashes', function() {
161 sinon.spy(host, 'disconnect');
162 hangoutPort.onDisconnect.mock$fire();
163
164 sinon.assert.called(onDisposedCallback);
165 sinon.assert.called(host.disconnect);
166 });
167
168 })();
OLDNEW
« no previous file with comments | « remoting/webapp/crd/manifest.json.jinja2 ('k') | remoting/webapp/unittests/it2me_helper_channel_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698