Chromium Code Reviews

Side by Side Diff: chrome/test/data/webrtc/peerconnection.js

Issue 2641263003: Performance measures of old and new RTCPeerConnection.getStats added. (Closed)
Patch Set: Fix windows compile error (change name of enum keys) Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 /** 1 /**
2 * Copyright 2014 The Chromium Authors. All rights reserved. 2 * Copyright 2014 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /** 7 /**
8 * The one and only peer connection in this page. 8 * The one and only peer connection in this page.
9 * @private 9 * @private
10 */ 10 */
(...skipping 358 matching lines...)
369 } 369 }
370 370
371 /** 371 /**
372 * Returns 372 * Returns
373 */ 373 */
374 function hasSeenCryptoInSdp() { 374 function hasSeenCryptoInSdp() {
375 returnToTest(gHasSeenCryptoInSdp); 375 returnToTest(gHasSeenCryptoInSdp);
376 } 376 }
377 377
378 /** 378 /**
379 * Verifies that |RTCPeerConnection.getStats| returns stats. 379 * Verifies that the legacy |RTCPeerConnection.getStats| returns stats and
380 * verifies that each stats member is a string.
380 * 381 *
381 * Returns ok-got-stats on success. 382 * Returns ok-got-stats on success.
382 */ 383 */
383 function verifyStatsGenerated() { 384 function verifyStatsGenerated() {
384 peerConnection_().getStats( 385 peerConnection_().getStats(
385 function(response) { 386 function(response) {
386 var reports = response.result(); 387 var reports = response.result();
387 var numStats = 0; 388 var numStats = 0;
388 for (var i = 0; i < reports.length; i++) { 389 for (var i = 0; i < reports.length; i++) {
389 var statNames = reports[i].names(); 390 var statNames = reports[i].names();
390 numStats += statNames.length; 391 numStats += statNames.length;
391 for (var j = 0; j < statNames.length; j++) { 392 for (var j = 0; j < statNames.length; j++) {
392 var statValue = reports[i].stat(statNames[j]); 393 var statValue = reports[i].stat(statNames[j]);
393 if (typeof statValue != 'string') 394 if (typeof statValue != 'string')
394 throw failTest('A stat was returned that is not a string.'); 395 throw failTest('A stat was returned that is not a string.');
395 } 396 }
396 } 397 }
397 if (numStats === 0) 398 if (numStats === 0)
398 throw failTest('No stats was returned by getStats.'); 399 throw failTest('No stats was returned by getStats.');
399 returnToTest('ok-got-stats'); 400 returnToTest('ok-got-stats');
400 }); 401 });
401 } 402 }
402 403
404 /**
405 * Invokes the legacy (callback-based) |RTCPeerConnection.getStats| and returns
406 * to test when done, not doing anything with the results. For testing
407 * performance.
408 *
409 * Returns done on success.
410 */
411 function getStatsCallbackAndReturn() {
412 peerConnection_().getStats(
413 function(response) {
414 returnToTest('done');
415 });
416 }
417
403 // Internals. 418 // Internals.
404 419
405 /** @private */ 420 /** @private */
406 function createPeerConnection_(rtcConfig) { 421 function createPeerConnection_(rtcConfig) {
407 try { 422 try {
408 peerConnection = new RTCPeerConnection(rtcConfig, {}); 423 peerConnection = new RTCPeerConnection(rtcConfig, {});
409 } catch (exception) { 424 } catch (exception) {
410 throw failTest('Failed to create peer connection: ' + exception); 425 throw failTest('Failed to create peer connection: ' + exception);
411 } 426 }
412 peerConnection.onaddstream = addStreamCallback_; 427 peerConnection.onaddstream = addStreamCallback_;
(...skipping 47 matching lines...)
460 function parseJson_(json) { 475 function parseJson_(json) {
461 // Escape since the \r\n in the SDP tend to get unescaped. 476 // Escape since the \r\n in the SDP tend to get unescaped.
462 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); 477 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n');
463 try { 478 try {
464 return JSON.parse(jsonWithEscapedLineBreaks); 479 return JSON.parse(jsonWithEscapedLineBreaks);
465 } catch (exception) { 480 } catch (exception) {
466 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + 481 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' +
467 exception); 482 exception);
468 } 483 }
469 } 484 }
OLDNEW

Powered by Google App Engine