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 appLauncher = null; | 9 var appLauncher = null; |
10 var hangoutPort = null; | 10 var hangoutPort = null; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 }); | 54 }); |
55 | 55 |
56 function promiseResolveSynchronous(value) { | 56 function promiseResolveSynchronous(value) { |
57 return { | 57 return { |
58 then: function(callback) { | 58 then: function(callback) { |
59 callback('tabId'); | 59 callback('tabId'); |
60 } | 60 } |
61 }; | 61 }; |
62 } | 62 } |
63 | 63 |
64 test('onHangoutMessage_("hello") should return supportedFeatures', function() { | |
65 hangoutPort.onMessage.mock$fire( | |
66 { method: remoting.It2MeHelperChannel.HangoutMessageTypes.HELLO }); | |
67 | |
68 var spyCall = hangoutPort.postMessage.firstCall; | |
69 var message = spyCall.args[0]; | |
70 | |
71 QUnit.equal(message.method, 'helloResponse'); | |
Jamie
2014/08/15 21:57:31
remoting.It2MeHelperChannel.HangoutMessageTypes.HE
kelvinp
2014/08/15 23:25:01
Done.
| |
72 QUnit.ok(message.supportedFeatures instanceof Array); | |
Jamie
2014/08/15 21:57:31
I think it might be worth checking that it's equal
kelvinp
2014/08/15 23:25:01
Done.
| |
73 }); | |
74 | |
64 test('onHangoutMessage_(|connect|) should launch the webapp', | 75 test('onHangoutMessage_(|connect|) should launch the webapp', |
65 function() { | 76 function() { |
66 sinon.assert.called(appLauncher.launch); | 77 sinon.assert.called(appLauncher.launch); |
67 QUnit.equal(helperChannel.instanceId(), 'tabId'); | 78 QUnit.equal(helperChannel.instanceId(), 'tabId'); |
68 }); | 79 }); |
69 | 80 |
70 test('onWebappMessage() should forward messages to hangout', function() { | 81 test('onWebappMessage() should forward messages to hangout', function() { |
71 // Execute. | 82 // Execute. |
72 helperChannel.onWebappConnect(webappPort); | 83 helperChannel.onWebappConnect(webappPort); |
73 webappPort.onMessage.mock$fire({ | 84 webappPort.onMessage.mock$fire({ |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 state:remoting.ClientSession.State.CLOSED | 124 state:remoting.ClientSession.State.CLOSED |
114 }); | 125 }); |
115 | 126 |
116 webappPort.onDisconnect.mock$fire(); | 127 webappPort.onDisconnect.mock$fire(); |
117 | 128 |
118 // Verify events are forwarded. | 129 // Verify events are forwarded. |
119 sinon.assert.calledWith(hangoutPort.postMessage, { | 130 sinon.assert.calledWith(hangoutPort.postMessage, { |
120 method:'sessionStateChanged', | 131 method:'sessionStateChanged', |
121 state:remoting.ClientSession.State.CLOSED | 132 state:remoting.ClientSession.State.CLOSED |
122 }); | 133 }); |
134 | |
135 sinon.assert.neverCalledWith(hangoutPort.postMessage, { | |
136 method:'sessionStateChanged', | |
137 state:remoting.ClientSession.State.FAILED | |
138 }); | |
Jamie
2014/08/15 21:57:32
Is this related to this CL?
kelvinp
2014/08/15 23:25:01
Done.
| |
139 | |
123 sinon.assert.called(hangoutPort.disconnect); | 140 sinon.assert.called(hangoutPort.disconnect); |
124 sinon.assert.calledOnce(disconnectCallback); | 141 sinon.assert.calledOnce(disconnectCallback); |
125 }); | 142 }); |
126 | 143 |
127 test('should notify hangout when the session has error', function() { | 144 test('should notify hangout when the session has error', function() { |
128 helperChannel.onWebappConnect(webappPort); | 145 helperChannel.onWebappConnect(webappPort); |
129 webappPort.onMessage.mock$fire({ | 146 webappPort.onMessage.mock$fire({ |
130 method:'sessionStateChanged', | 147 method:'sessionStateChanged', |
131 state:remoting.ClientSession.State.FAILED | 148 state:remoting.ClientSession.State.FAILED |
132 }); | 149 }); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 hangoutPort.onDisconnect.mock$fire(); | 187 hangoutPort.onDisconnect.mock$fire(); |
171 | 188 |
172 sinon.assert.calledOnce(appLauncher.close); | 189 sinon.assert.calledOnce(appLauncher.close); |
173 sinon.assert.calledOnce(disconnectCallback); | 190 sinon.assert.calledOnce(disconnectCallback); |
174 | 191 |
175 sinon.assert.called(hangoutPort.disconnect); | 192 sinon.assert.called(hangoutPort.disconnect); |
176 sinon.assert.called(webappPort.disconnect); | 193 sinon.assert.called(webappPort.disconnect); |
177 }); | 194 }); |
178 | 195 |
179 })(); | 196 })(); |
OLD | NEW |