Index: chrome/test/data/webrtc/peerconnection.js |
diff --git a/chrome/test/data/webrtc/peerconnection.js b/chrome/test/data/webrtc/peerconnection.js |
index 639e0f41a8ff34624bc5be8ea6fed1aeb640b757..2f4f1c6d8235c1c983e73b7f8c99398439fd6709 100644 |
--- a/chrome/test/data/webrtc/peerconnection.js |
+++ b/chrome/test/data/webrtc/peerconnection.js |
@@ -289,6 +289,36 @@ function hasSeenCryptoInSdp() { |
returnToTest(gHasSeenCryptoInSdp); |
} |
+/** |
+ * Gets and iterates stats. Makes sure at least one report stat is returned. |
+ * |
+ * Returns ok on success. |
+ */ |
+function getStats() { |
+ peerConnection_().getStats( |
+ function(response) { |
+ var statsStr = ''; |
+ var reports = response.result(); |
+ var numStats = 0; |
+ for (var i = 0; i < reports.length; i++) { |
+ var report = reports[i]; |
+ statsStr += '\nReport #' + i + ': ' + report.id + ' (type: ' + |
phoglund_chromium
2016/07/27 12:52:10
Maybe call it statsText or result? It appears this
hbos_chromium
2016/07/27 13:50:31
Done.
|
+ report.type + ', timestamp: ' + report.timestamp + ')'; |
+ var statNames = report.names(); |
+ numStats += statNames.length; |
+ for (var j = 0; j < statNames.length; j++) { |
+ var statName = statNames[j]; |
+ var statValue = report.stat(statName); |
+ statsStr += '\n- ' + statName + ': ' + statValue; |
+ } |
+ } |
+ console.log('getStats:' + statsStr); |
+ if (numStats === 0) |
+ throw failTest('No stats was returned by getStats.'); |
+ returnToTest('ok'); |
phoglund_chromium
2016/07/27 12:52:10
ok-got-stats perhaps?
hbos_chromium
2016/07/27 13:50:31
Done.
|
+ }); |
+} |
+ |
// Internals. |
/** @private */ |