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

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

Issue 896003002: Use the local user's email when connecting to It2MeHelpeeChannel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@HRD_V2Auth
Patch Set: Created 5 years, 10 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() { 5 (function() {
6 6
7 'use strict'; 7 'use strict';
8 8
9 var hostInstaller = null; 9 var hostInstaller = null;
10 var hangoutPort = null; 10 var hangoutPort = null;
(...skipping 29 matching lines...) Expand all
40 // HelpeeChannel 40 // HelpeeChannel
41 helpeeChannel = new remoting.It2MeHelpeeChannel( 41 helpeeChannel = new remoting.It2MeHelpeeChannel(
42 hangoutPort, 42 hangoutPort,
43 host, 43 host,
44 hostInstaller, 44 hostInstaller,
45 onDisposedCallback); 45 onDisposedCallback);
46 helpeeChannel.init(); 46 helpeeChannel.init();
47 47
48 // remoting.settings 48 // remoting.settings
49 remoting.settings = new remoting.Settings(); 49 remoting.settings = new remoting.Settings();
50 remoting.identity = new remoting.Identity();
51 },
52 tearDown: function() {
53 remoting.settings = null;
54 remoting.identity = null;
50 } 55 }
51 }); 56 });
52 57
53 test('hello() should return supportedFeatures', function() { 58 test('hello() should return supportedFeatures', function() {
54 hangoutPort.onMessage.mock$fire( 59 hangoutPort.onMessage.mock$fire(
55 { method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.HELLO }); 60 { method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.HELLO });
56 61
57 sinon.assert.calledWith(hangoutPort.postMessage, { 62 sinon.assert.calledWith(hangoutPort.postMessage, {
58 method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.HELLO_RESPONSE, 63 method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.HELLO_RESPONSE,
59 supportedFeatures: base.values(remoting.It2MeHelperChannel.Features) 64 supportedFeatures: base.values(remoting.It2MeHelperChannel.Features)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 function() { 134 function() {
130 // Stubs authentication. 135 // Stubs authentication.
131 sinon.stub(base, 'isAppsV2').returns(true); 136 sinon.stub(base, 'isAppsV2').returns(true);
132 sinon.stub(remoting.HangoutConsentDialog, 'getInstance').returns({ 137 sinon.stub(remoting.HangoutConsentDialog, 'getInstance').returns({
133 show : function() { 138 show : function() {
134 return Promise.resolve(); 139 return Promise.resolve();
135 } 140 }
136 }); 141 });
137 sinon.stub(chrome.identity, 'getAuthToken') 142 sinon.stub(chrome.identity, 'getAuthToken')
138 .callsArgWith(1, 'token'); 143 .callsArgWith(1, 'token');
144 sinon.stub(remoting.identity, 'callWithToken')
145 .callsArgWith(0, 'token');
146 sinon.stub(remoting.identity, 'getEmail')
147 .callsArgWith(0, {token: 'token', email: 'test@chromium.org'});
139 // Stubs Host behavior. 148 // Stubs Host behavior.
140 sinon.stub(host, 'initialized').returns(true); 149 sinon.stub(host, 'initialized').returns(true);
141 sinon.stub(host, 'connect') 150 sinon.stub(host, 'connect')
142 .callsArgWith(2, remoting.HostSession.State.RECEIVED_ACCESS_CODE); 151 .callsArgWith(2, remoting.HostSession.State.RECEIVED_ACCESS_CODE);
143 sinon.stub(host, 'getAccessCode').returns('accessCode'); 152 sinon.stub(host, 'getAccessCode').returns('accessCode');
144 153
145 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes; 154 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes;
146 hangoutPort.onMessage.mock$fire({ 155 hangoutPort.onMessage.mock$fire({
147 method: MessageTypes.CONNECT, 156 method: MessageTypes.CONNECT,
148 email: 'test@chromium.org',
149 hangoutBounds: {widht: 10, height: 10, left:10, top: 10} 157 hangoutBounds: {widht: 10, height: 10, left:10, top: 10}
150 }); 158 });
151 159
152 window.requestAnimationFrame(function(){ 160 window.requestAnimationFrame(function(){
153 // Verify that access code is correct in the response. 161 // Verify that access code is correct in the response.
154 sinon.assert.calledWithMatch(hangoutPort.postMessage, { 162 sinon.assert.calledWithMatch(hangoutPort.postMessage, {
155 method: MessageTypes.CONNECT_RESPONSE, 163 method: MessageTypes.CONNECT_RESPONSE,
156 accessCode: 'accessCode' 164 accessCode: 'accessCode'
157 }); 165 });
158 166
159 chrome.identity.getAuthToken.restore(); 167 chrome.identity.getAuthToken.restore();
160 base.isAppsV2.restore(); 168 base.isAppsV2.restore();
161 QUnit.start(); 169 QUnit.start();
162 }); 170 });
163 }); 171 });
164 172
165 test('should disconnect the session if Hangout crashes', function() { 173 test('should disconnect the session if Hangout crashes', function() {
166 sinon.spy(host, 'disconnect'); 174 sinon.spy(host, 'disconnect');
167 hangoutPort.onDisconnect.mock$fire(); 175 hangoutPort.onDisconnect.mock$fire();
168 176
169 sinon.assert.called(onDisposedCallback); 177 sinon.assert.called(onDisposedCallback);
170 sinon.assert.called(host.disconnect); 178 sinon.assert.called(host.disconnect);
171 }); 179 });
172 180
173 })(); 181 })();
OLDNEW
« remoting/webapp/crd/js/it2me_helpee_channel.js ('K') | « remoting/webapp/crd/js/it2me_service.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698