| OLD | NEW |
| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 sinon.assert.calledWithMatch(hangoutPort.postMessage, { | 123 sinon.assert.calledWithMatch(hangoutPort.postMessage, { |
| 124 method: MessageTypes.ERROR | 124 method: MessageTypes.ERROR |
| 125 }); | 125 }); |
| 126 }); | 126 }); |
| 127 | 127 |
| 128 QUnit.asyncTest('connect() should return access code', | 128 QUnit.asyncTest('connect() should return access code', |
| 129 function() { | 129 function() { |
| 130 // Stubs authentication. | 130 // Stubs authentication. |
| 131 sinon.stub(base, 'isAppsV2').returns(true); | 131 sinon.stub(base, 'isAppsV2').returns(true); |
| 132 sinon.stub(remoting.MessageWindow, 'showConfirmWindow') | 132 sinon.stub(remoting.HangoutConsentDialog, 'getInstance').returns({ |
| 133 .callsArgWith(4, 1 /* 1 for OK. */); | 133 show : function() { |
| 134 return Promise.resolve(); |
| 135 } |
| 136 }); |
| 134 sinon.stub(chrome.identity, 'getAuthToken') | 137 sinon.stub(chrome.identity, 'getAuthToken') |
| 135 .callsArgWith(1, 'token'); | 138 .callsArgWith(1, 'token'); |
| 136 // Stubs Host behavior. | 139 // Stubs Host behavior. |
| 137 sinon.stub(host, 'initialized').returns(true); | 140 sinon.stub(host, 'initialized').returns(true); |
| 138 sinon.stub(host, 'connect') | 141 sinon.stub(host, 'connect') |
| 139 .callsArgWith(2, remoting.HostSession.State.RECEIVED_ACCESS_CODE); | 142 .callsArgWith(2, remoting.HostSession.State.RECEIVED_ACCESS_CODE); |
| 140 sinon.stub(host, 'getAccessCode').returns('accessCode'); | 143 sinon.stub(host, 'getAccessCode').returns('accessCode'); |
| 141 | 144 |
| 142 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes; | 145 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes; |
| 143 hangoutPort.onMessage.mock$fire({ | 146 hangoutPort.onMessage.mock$fire({ |
| 144 method: MessageTypes.CONNECT, | 147 method: MessageTypes.CONNECT, |
| 145 email: 'test@chromium.org' | 148 email: 'test@chromium.org' |
| 146 }); | 149 }); |
| 147 | 150 |
| 148 window.requestAnimationFrame(function(){ | 151 window.requestAnimationFrame(function(){ |
| 149 // Verify that access code is correct in the response. | 152 // Verify that access code is correct in the response. |
| 150 sinon.assert.calledWithMatch(hangoutPort.postMessage, { | 153 sinon.assert.calledWithMatch(hangoutPort.postMessage, { |
| 151 method: MessageTypes.CONNECT_RESPONSE, | 154 method: MessageTypes.CONNECT_RESPONSE, |
| 152 accessCode: 'accessCode' | 155 accessCode: 'accessCode' |
| 153 }); | 156 }); |
| 154 | 157 |
| 155 chrome.identity.getAuthToken.restore(); | 158 chrome.identity.getAuthToken.restore(); |
| 156 base.isAppsV2.restore(); | 159 base.isAppsV2.restore(); |
| 157 remoting.MessageWindow.showConfirmWindow.restore(); | |
| 158 QUnit.start(); | 160 QUnit.start(); |
| 159 }); | 161 }); |
| 160 }); | 162 }); |
| 161 | 163 |
| 162 test('should disconnect the session if Hangout crashes', function() { | 164 test('should disconnect the session if Hangout crashes', function() { |
| 163 sinon.spy(host, 'disconnect'); | 165 sinon.spy(host, 'disconnect'); |
| 164 hangoutPort.onDisconnect.mock$fire(); | 166 hangoutPort.onDisconnect.mock$fire(); |
| 165 | 167 |
| 166 sinon.assert.called(onDisposedCallback); | 168 sinon.assert.called(onDisposedCallback); |
| 167 sinon.assert.called(host.disconnect); | 169 sinon.assert.called(host.disconnect); |
| 168 }); | 170 }); |
| 169 | 171 |
| 170 })(); | 172 })(); |
| OLD | NEW |