| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** @type {remoting.TelemetryEventWriter.Service} */ | 9 /** @type {remoting.TelemetryEventWriter.Service} */ | 
| 10 var service; | 10 var service; | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 85   }); | 85   }); | 
| 86 }); | 86 }); | 
| 87 | 87 | 
| 88 QUnit.test('should send CANCELED event when window is closed while started.', | 88 QUnit.test('should send CANCELED event when window is closed while started.', | 
| 89   function(assert) { | 89   function(assert) { | 
| 90   var writeStub = sinon.stub(eventWriter, 'write'); | 90   var writeStub = sinon.stub(eventWriter, 'write'); | 
| 91   return service.init().then(function() { | 91   return service.init().then(function() { | 
| 92     chrome.app.window.current().id = 'fake-window-id'; | 92     chrome.app.window.current().id = 'fake-window-id'; | 
| 93   }).then(function() { | 93   }).then(function() { | 
| 94     logger.logSessionStateChange( | 94     logger.logSessionStateChange( | 
| 95         remoting.ChromotingEvent.SessionState.STARTED, | 95         remoting.ChromotingEvent.SessionState.STARTED); | 
| 96         remoting.ChromotingEvent.ConnectionError.NONE); |  | 
| 97   }).then(function() { | 96   }).then(function() { | 
| 98     return service.unbindSession('fake-window-id'); | 97     return service.unbindSession('fake-window-id'); | 
| 99   }).then(function() { | 98   }).then(function() { | 
| 100     var Event = remoting.ChromotingEvent; | 99     var Event = remoting.ChromotingEvent; | 
| 101     verifyEvent(writeStub, assert, 1, { | 100     verifyEvent(writeStub, assert, 1, { | 
| 102       type: Event.Type.SESSION_STATE, | 101       type: Event.Type.SESSION_STATE, | 
| 103       session_state: Event.SessionState.CONNECTION_CANCELED, | 102       session_state: Event.SessionState.CONNECTION_CANCELED, | 
| 104       connection_error: Event.ConnectionError.NONE, | 103       connection_error: Event.ConnectionError.NONE, | 
| 105       application_id: 'extensionId', | 104       application_id: 'extensionId', | 
| 106       role: Event.Role.CLIENT, | 105       role: Event.Role.CLIENT, | 
| 107       mode: Event.Mode.ME2ME, | 106       mode: Event.Mode.ME2ME, | 
| 108       connection_type: Event.ConnectionType.STUN, | 107       connection_type: Event.ConnectionType.STUN, | 
| 109       host_version: 'host_version', | 108       host_version: 'host_version', | 
| 110       host_os: remoting.ChromotingEvent.Os.OTHER, | 109       host_os: remoting.ChromotingEvent.Os.OTHER, | 
| 111       host_os_version: 'host_os_version' | 110       host_os_version: 'host_os_version' | 
| 112     }); | 111     }); | 
| 113   }); | 112   }); | 
| 114 }); | 113 }); | 
| 115 | 114 | 
| 116 QUnit.test('should send CANCELED event when window is closed while connecting.', | 115 QUnit.test('should send CANCELED event when window is closed while connecting.', | 
| 117   function(assert) { | 116   function(assert) { | 
| 118   var writeStub = sinon.stub(eventWriter, 'write'); | 117   var writeStub = sinon.stub(eventWriter, 'write'); | 
| 119   return service.init().then(function() { | 118   return service.init().then(function() { | 
| 120     chrome.app.window.current().id = 'fake-window-id'; | 119     chrome.app.window.current().id = 'fake-window-id'; | 
| 121   }).then(function() { | 120   }).then(function() { | 
| 122     logger.logClientSessionStateChange( | 121     logger.logSessionStateChange( | 
| 123         remoting.ClientSession.State.CONNECTING, remoting.Error.none(), null); | 122         remoting.ChromotingEvent.SessionState.CONNECTING); | 
| 124   }).then(function() { | 123   }).then(function() { | 
| 125     return service.unbindSession('fake-window-id'); | 124     return service.unbindSession('fake-window-id'); | 
| 126   }).then(function() { | 125   }).then(function() { | 
| 127     var Event = remoting.ChromotingEvent; | 126     var Event = remoting.ChromotingEvent; | 
| 128     verifyEvent(writeStub, assert, 1, { | 127     verifyEvent(writeStub, assert, 1, { | 
| 129       type: Event.Type.SESSION_STATE, | 128       type: Event.Type.SESSION_STATE, | 
| 130       session_state: Event.SessionState.CONNECTION_CANCELED, | 129       session_state: Event.SessionState.CONNECTION_CANCELED, | 
| 131       connection_error: Event.ConnectionError.NONE, | 130       connection_error: Event.ConnectionError.NONE, | 
| 132       application_id: 'extensionId', | 131       application_id: 'extensionId', | 
| 133       role: Event.Role.CLIENT, | 132       role: Event.Role.CLIENT, | 
| 134       mode: Event.Mode.ME2ME, | 133       mode: Event.Mode.ME2ME, | 
| 135       connection_type: Event.ConnectionType.STUN, | 134       connection_type: Event.ConnectionType.STUN, | 
| 136       host_version: 'host_version', | 135       host_version: 'host_version', | 
| 137       host_os: remoting.ChromotingEvent.Os.OTHER, | 136       host_os: remoting.ChromotingEvent.Os.OTHER, | 
| 138       host_os_version: 'host_os_version' | 137       host_os_version: 'host_os_version' | 
| 139     }); | 138     }); | 
| 140   }); | 139   }); | 
| 141 }); | 140 }); | 
| 142 | 141 | 
| 143 QUnit.test('should send CLOSED event when window is closed while connected.', | 142 QUnit.test('should send CLOSED event when window is closed while connected.', | 
| 144   function(assert) { | 143   function(assert) { | 
| 145   var writeStub = sinon.stub(eventWriter, 'write'); | 144   var writeStub = sinon.stub(eventWriter, 'write'); | 
| 146 | 145 | 
| 147   return service.init().then(function() { | 146   return service.init().then(function() { | 
| 148     chrome.app.window.current().id = 'fake-window-id'; | 147     chrome.app.window.current().id = 'fake-window-id'; | 
| 149   }).then(function() { | 148   }).then(function() { | 
| 150     logger.logClientSessionStateChange( | 149     logger.logSessionStateChange( | 
| 151         remoting.ClientSession.State.CONNECTING, remoting.Error.none(), null); | 150         remoting.ChromotingEvent.SessionState.CONNECTING); | 
| 152   }).then(function() { | 151   }).then(function() { | 
| 153     logger.logClientSessionStateChange( | 152     logger.logSessionStateChange( | 
| 154         remoting.ClientSession.State.CONNECTED, remoting.Error.none(), null); | 153         remoting.ChromotingEvent.SessionState.CONNECTED); | 
| 155   }).then(function() { | 154   }).then(function() { | 
| 156     return service.unbindSession('fake-window-id'); | 155     return service.unbindSession('fake-window-id'); | 
| 157   }).then(function() { | 156   }).then(function() { | 
| 158     var Event = remoting.ChromotingEvent; | 157     var Event = remoting.ChromotingEvent; | 
| 159     verifyEvent(writeStub, assert, 2, { | 158     verifyEvent(writeStub, assert, 2, { | 
| 160       type: Event.Type.SESSION_STATE, | 159       type: Event.Type.SESSION_STATE, | 
| 161       session_state: Event.SessionState.CLOSED, | 160       session_state: Event.SessionState.CLOSED, | 
| 162       connection_error: Event.ConnectionError.NONE, | 161       connection_error: Event.ConnectionError.NONE, | 
| 163       application_id: 'extensionId', | 162       application_id: 'extensionId', | 
| 164       role: Event.Role.CLIENT, | 163       role: Event.Role.CLIENT, | 
| 165       mode: Event.Mode.ME2ME, | 164       mode: Event.Mode.ME2ME, | 
| 166       connection_type: Event.ConnectionType.STUN, | 165       connection_type: Event.ConnectionType.STUN, | 
| 167       host_version: 'host_version', | 166       host_version: 'host_version', | 
| 168       host_os: remoting.ChromotingEvent.Os.OTHER, | 167       host_os: remoting.ChromotingEvent.Os.OTHER, | 
| 169       host_os_version: 'host_os_version' | 168       host_os_version: 'host_os_version' | 
| 170     }); | 169     }); | 
| 171   }); | 170   }); | 
| 172 }); | 171 }); | 
| 173 | 172 | 
| 174 QUnit.test('should not send CLOSED event when window is closed unconnected.', | 173 QUnit.test('should not send CLOSED event when window is closed unconnected.', | 
| 175   function(assert) { | 174   function(assert) { | 
| 176 | 175 | 
| 177   var mockEventWriter = sinon.mock(eventWriter); | 176   var mockEventWriter = sinon.mock(eventWriter); | 
| 178   mockEventWriter.expects('write').exactly(2); | 177   mockEventWriter.expects('write').exactly(2); | 
| 179 | 178 | 
| 180   return service.init().then(function() { | 179   return service.init().then(function() { | 
| 181     chrome.app.window.current().id = 'fake-window-id'; | 180     chrome.app.window.current().id = 'fake-window-id'; | 
| 182   }).then(function() { | 181   }).then(function() { | 
| 183     logger.logClientSessionStateChange( | 182     logger.logSessionStateChange( | 
| 184         remoting.ClientSession.State.CONNECTING, remoting.Error.none(), null); | 183         remoting.ChromotingEvent.SessionState.CONNECTING); | 
| 185   }).then(function() { | 184   }).then(function() { | 
| 186     logger.logClientSessionStateChange( | 185     logger.logSessionStateChange( | 
| 187         remoting.ClientSession.State.FAILED, remoting.Error.none(), null); | 186         remoting.ChromotingEvent.SessionState.CONNECTION_FAILED); | 
| 188   }).then(function() { | 187   }).then(function() { | 
| 189     return service.unbindSession('fake-window-id'); | 188     return service.unbindSession('fake-window-id'); | 
| 190   }).then(function() { | 189   }).then(function() { | 
| 191     mockEventWriter.verify(); | 190     mockEventWriter.verify(); | 
| 192   }); | 191   }); | 
| 193 }); | 192 }); | 
| 194 | 193 | 
| 195 })(); | 194 })(); | 
| OLD | NEW | 
|---|