| 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 /** |
| 6 * @fileoverview |
| 7 * @suppress {checkTypes|checkVars|reportUnknownTypes|visibility} |
| 8 */ |
| 9 |
| 5 (function() { | 10 (function() { |
| 6 | 11 |
| 7 'use strict'; | 12 'use strict'; |
| 8 | 13 |
| 9 var appLauncher = null; | 14 var appLauncher = null; |
| 10 var hangoutPort = null; | 15 var hangoutPort = null; |
| 11 var webappPort = null; | 16 var webappPort = null; |
| 12 var helperChannel = null; | 17 var helperChannel = null; |
| 13 var disconnectCallback = null; | 18 var disconnectCallback = null; |
| 14 | 19 |
| 15 module('It2MeHelperChannel', { | 20 module('It2MeHelperChannel', { |
| 16 setup: function() { | 21 setup: function() { |
| 17 // App Launcher. | 22 // App Launcher. |
| 18 appLauncher = { | 23 appLauncher = { |
| 19 launch: function () { | 24 launch: function () { |
| 20 return promiseResolveSynchronous('tabId'); | 25 return promiseResolveSynchronous('tabId'); |
| 21 }, | 26 }, |
| 22 close: function () {} | 27 close: function () {} |
| 23 }; | 28 }; |
| 24 appLauncher.launch = sinon.spy(appLauncher, 'launch'); | 29 appLauncher.launch = sinon.spy(appLauncher, 'launch'); |
| 25 appLauncher.close = sinon.spy(appLauncher, 'close'); | 30 appLauncher.close = sinon.spy(appLauncher, 'close'); |
| 26 | 31 |
| 27 // HangoutPort. | 32 // HangoutPort. |
| 28 hangoutPort = new chromeMocks.runtime.Port(); | 33 hangoutPort = new chrome.runtime.Port(); |
| 29 hangoutPort.postMessage = sinon.spy(hangoutPort, 'postMessage'); | 34 hangoutPort.postMessage = sinon.spy(hangoutPort, 'postMessage'); |
| 30 hangoutPort.disconnect = sinon.spy(hangoutPort, 'disconnect'); | 35 hangoutPort.disconnect = sinon.spy(hangoutPort, 'disconnect'); |
| 31 | 36 |
| 32 // WebappPort. | 37 // WebappPort. |
| 33 webappPort = new chromeMocks.runtime.Port(); | 38 webappPort = new chrome.runtime.Port(); |
| 34 webappPort.sender = { | 39 webappPort.sender = { |
| 35 tab : { | 40 tab : { |
| 36 id : 'tabId' | 41 id : 'tabId' |
| 37 } | 42 } |
| 38 }; | 43 }; |
| 39 webappPort.postMessage = sinon.spy(webappPort, 'postMessage'); | 44 webappPort.postMessage = sinon.spy(webappPort, 'postMessage'); |
| 40 webappPort.disconnect = sinon.spy(webappPort, 'disconnect'); | 45 webappPort.disconnect = sinon.spy(webappPort, 'disconnect'); |
| 41 | 46 |
| 42 // disconnect callback | 47 // disconnect callback |
| 43 disconnectCallback = sinon.spy(); | 48 disconnectCallback = sinon.spy(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 hangoutPort.onDisconnect.mock$fire(); | 185 hangoutPort.onDisconnect.mock$fire(); |
| 181 | 186 |
| 182 sinon.assert.calledOnce(appLauncher.close); | 187 sinon.assert.calledOnce(appLauncher.close); |
| 183 sinon.assert.calledOnce(disconnectCallback); | 188 sinon.assert.calledOnce(disconnectCallback); |
| 184 | 189 |
| 185 sinon.assert.called(hangoutPort.disconnect); | 190 sinon.assert.called(hangoutPort.disconnect); |
| 186 sinon.assert.called(webappPort.disconnect); | 191 sinon.assert.called(webappPort.disconnect); |
| 187 }); | 192 }); |
| 188 | 193 |
| 189 })(); | 194 })(); |
| OLD | NEW |