| 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.SessionLogger} */ | 9 /** @type {remoting.SessionLogger} */ |
| 10 var logger = null; | 10 var logger = null; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 QUnit.test('logStatistics()', function(assert) { | 270 QUnit.test('logStatistics()', function(assert) { |
| 271 var clock = sinon.useFakeTimers(); | 271 var clock = sinon.useFakeTimers(); |
| 272 var Event = remoting.ChromotingEvent; | 272 var Event = remoting.ChromotingEvent; |
| 273 | 273 |
| 274 // Creates the logger. | 274 // Creates the logger. |
| 275 logger = new remoting.SessionLogger(Event.Role.CLIENT, logWriter); | 275 logger = new remoting.SessionLogger(Event.Role.CLIENT, logWriter); |
| 276 logger.setLogEntryMode(Event.Mode.LGAPP); | 276 logger.setLogEntryMode(Event.Mode.LGAPP); |
| 277 logger.setConnectionType('direct'); | 277 logger.setConnectionType('direct'); |
| 278 logger.setHost(fakeHost); | 278 logger.setHost(fakeHost); |
| 279 | 279 |
| 280 // Log the statistics. | 280 // Log the statistics |
| 281 logger.logStatistics({ | |
| 282 videoBandwidth: 1.0, | |
| 283 captureLatency: 1.0, | |
| 284 encodeLatency: 1.0, | |
| 285 decodeLatency: 0.0, | |
| 286 renderLatency: 1.0, | |
| 287 roundtripLatency: 1.0 | |
| 288 }); | |
| 289 | |
| 290 logger.logStatistics({ | |
| 291 videoBandwidth: 2.0, | |
| 292 captureLatency: 2.0, | |
| 293 encodeLatency: 1.0, | |
| 294 decodeLatency: 0.0, | |
| 295 renderLatency: 2.0, | |
| 296 roundtripLatency: 2.0 | |
| 297 }); | |
| 298 | |
| 299 sinon.assert.notCalled(logWriterSpy); | |
| 300 // Stats should only be accumulated at |CONNECTION_STATS_ACCUMULATE_TIME|. | |
| 301 clock.tick(remoting.SessionLogger.CONNECTION_STATS_ACCUMULATE_TIME + 10); | |
| 302 | |
| 303 logger.logStatistics({ | 281 logger.logStatistics({ |
| 304 videoBandwidth: 3.0, | 282 videoBandwidth: 3.0, |
| 305 captureLatency: 3.0, | 283 captureLatency: 1.0, |
| 306 encodeLatency: 1.0, | 284 maxCaptureLatency: 3.0, |
| 307 decodeLatency: 0.0, | 285 encodeLatency: 2.0, |
| 308 renderLatency: 0.0, | 286 maxEncodeLatency: 4.0, |
| 309 roundtripLatency: 0.0 | 287 decodeLatency: 3.0, |
| 288 maxDecodeLatency: 5.0, |
| 289 renderLatency: 4.0, |
| 290 maxRenderLatency: 6.0, |
| 291 roundtripLatency: 5.0, |
| 292 maxRoundtripLatency: 7.0 |
| 310 }); | 293 }); |
| 311 | 294 |
| 312 verifyEvent(assert, 0, { | 295 verifyEvent(assert, 0, { |
| 313 type: Event.Type.CONNECTION_STATISTICS, | 296 type: Event.Type.CONNECTION_STATISTICS, |
| 314 os: Event.Os.MAC, | 297 os: Event.Os.MAC, |
| 315 os_version: '10.9.5', | 298 os_version: '10.9.5', |
| 316 cpu: 'Intel', | 299 cpu: 'Intel', |
| 317 browser_version: '43.0.2357.81', | 300 browser_version: '43.0.2357.81', |
| 318 application_id: 'extensionId', | 301 application_id: 'extensionId', |
| 319 role: Event.Role.CLIENT, | 302 role: Event.Role.CLIENT, |
| 320 mode: Event.Mode.LGAPP, | 303 mode: Event.Mode.LGAPP, |
| 321 connection_type: Event.ConnectionType.DIRECT, | 304 connection_type: Event.ConnectionType.DIRECT, |
| 322 host_version: 'host_version', | 305 host_version: 'host_version', |
| 323 host_os: remoting.ChromotingEvent.Os.OTHER, | 306 host_os: remoting.ChromotingEvent.Os.OTHER, |
| 324 host_os_version: 'host_os_version', | 307 host_os_version: 'host_os_version', |
| 325 session_id: logger.getSessionId(), | 308 session_id: logger.getSessionId(), |
| 326 video_bandwidth: 2.0, | 309 video_bandwidth: 3.0, |
| 327 capture_latency: 2.0, | 310 capture_latency: 1.0, |
| 328 encode_latency: 1.0, | 311 encode_latency: 2.0, |
| 329 decode_latency: 0.0, | 312 decode_latency: 3.0, |
| 330 render_latency: 1.0, | 313 render_latency: 4.0, |
| 331 roundtrip_latency: 1.0 | 314 roundtrip_latency: 5.0, |
| 315 max_capture_latency: 3.0, |
| 316 max_encode_latency: 4.0, |
| 317 max_decode_latency: 5.0, |
| 318 max_render_latency: 6.0, |
| 319 max_roundtrip_latency: 7.0 |
| 332 }); | 320 }); |
| 333 }); | 321 }); |
| 334 | 322 |
| 335 QUnit.test('logStatistics() should not log if all stats are zeros ', | 323 QUnit.test('logStatistics() should not log if all stats are zeros ', |
| 336 function(assert) { | 324 function(assert) { |
| 337 var clock = sinon.useFakeTimers(); | 325 var clock = sinon.useFakeTimers(); |
| 338 var Event = remoting.ChromotingEvent; | 326 var Event = remoting.ChromotingEvent; |
| 339 | 327 |
| 340 // Creates the logger. | 328 // Creates the logger. |
| 341 logger = new remoting.SessionLogger(Event.Role.CLIENT, logWriter); | 329 logger = new remoting.SessionLogger(Event.Role.CLIENT, logWriter); |
| 342 | 330 |
| 343 logger.logStatistics({ | 331 logger.logStatistics({ |
| 344 videoBandwidth: 0.0, | 332 videoBandwidth: 0.0, |
| 345 captureLatency: 0.0, | 333 captureLatency: 0.0, |
| 346 encodeLatency: 0.0, | 334 encodeLatency: 0.0, |
| 347 decodeLatency: 0.0, | 335 decodeLatency: 0.0, |
| 348 renderLatency: 0.0, | 336 renderLatency: 0.0, |
| 349 roundtripLatency: 0.0 | 337 roundtripLatency: 0.0 |
| 350 }); | 338 }); |
| 351 | 339 |
| 352 clock.tick(remoting.SessionLogger.CONNECTION_STATS_ACCUMULATE_TIME + 10); | |
| 353 | |
| 354 logger.logStatistics({ | |
| 355 videoBandwidth: 0.0, | |
| 356 captureLatency: 0.0, | |
| 357 encodeLatency: 0.0, | |
| 358 decodeLatency: 0.0, | |
| 359 renderLatency: 0.0, | |
| 360 roundtripLatency: 0.0 | |
| 361 }); | |
| 362 | |
| 363 sinon.assert.notCalled(logWriterSpy); | 340 sinon.assert.notCalled(logWriterSpy); |
| 364 | 341 |
| 365 }); | 342 }); |
| 366 | 343 |
| 367 QUnit.test('incrementFeatureUsage() and flushFeatureTracker()', | 344 QUnit.test('incrementFeatureUsage() and flushFeatureTracker()', |
| 368 function(assert) { | 345 function(assert) { |
| 369 var Event = remoting.ChromotingEvent; | 346 var Event = remoting.ChromotingEvent; |
| 370 | 347 |
| 371 logger = new remoting.SessionLogger(Event.Role.CLIENT, logWriter); | 348 logger = new remoting.SessionLogger(Event.Role.CLIENT, logWriter); |
| 372 | 349 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 390 sinon.assert.notCalled(logWriterSpy); | 367 sinon.assert.notCalled(logWriterSpy); |
| 391 | 368 |
| 392 logger.flushFeatureTracker(); | 369 logger.flushFeatureTracker(); |
| 393 verifyEvent(assert, 0, { | 370 verifyEvent(assert, 0, { |
| 394 type: Event.Type.FEATURE_TRACKING, | 371 type: Event.Type.FEATURE_TRACKING, |
| 395 feature_tracker: {fullscreen_esc_count: 0} | 372 feature_tracker: {fullscreen_esc_count: 0} |
| 396 }); | 373 }); |
| 397 }); | 374 }); |
| 398 | 375 |
| 399 })(); | 376 })(); |
| OLD | NEW |