| Index: third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-getStats-promise.html
|
| diff --git a/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-getStats-promise.html b/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-getStats-promise.html
|
| index 731a63a7c80fb003a87c798aa577a51284cc22d3..661c72a06a33d425cf4fb502d442992657efe94c 100644
|
| --- a/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-getStats-promise.html
|
| +++ b/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-getStats-promise.html
|
| @@ -9,6 +9,40 @@
|
| <script>
|
| var pc = new webkitRTCPeerConnection(null);
|
|
|
| +function stringify_equals(d1, d2) {
|
| + return JSON.stringify(d1) == JSON.stringify(d2);
|
| +}
|
| +
|
| +function assert_expected_report(report) {
|
| + assert_true(report != null);
|
| + var statsCount = 0;
|
| + report.forEach(function(s) {
|
| + assert_true(s != null);
|
| + statsCount++;
|
| + assert_true(stringify_equals(s, report.get(s.id)));
|
| + });
|
| +
|
| + // Verify that the report contains the same stats that
|
| + // |MockWebRTCPeerConnectionHandler::getStats| should produce.
|
| + assert_equals(statsCount, 1);
|
| + var stats = report.get('mock-stats-01');
|
| + assert_true(stats != null);
|
| + assert_equals(stats.type, 'mock-stats');
|
| + assert_equals(stats.timestamp, 1234.0);
|
| + assert_equals(stats.int32, 42);
|
| + assert_equals(stats.uint32, 42);
|
| + assert_equals(stats.int64, 42);
|
| + assert_equals(stats.uint64, 42);
|
| + assert_equals(stats.double, 42);
|
| + assert_equals(stats.string, '42');
|
| + assert_true(stringify_equals(stats.sequenceInt32, [42]));
|
| + assert_true(stringify_equals(stats.sequenceUint32, [42]));
|
| + assert_true(stringify_equals(stats.sequenceInt64, [42]));
|
| + assert_true(stringify_equals(stats.sequenceUint64, [42]));
|
| + assert_true(stringify_equals(stats.sequenceDouble, [42]));
|
| + assert_true(stringify_equals(stats.sequenceString, ['42']));
|
| +}
|
| +
|
| promise_test(function() {
|
| return navigator.mediaDevices.getUserMedia({audio:true, video:true})
|
| .then(function(mediaStream) {
|
| @@ -16,11 +50,8 @@ promise_test(function() {
|
| var selector = pc.getLocalStreams()[0].getVideoTracks()[0];
|
| assert_not_equals(selector, null);
|
| return pc.getStats(selector)
|
| - .then(function(statsReport) {
|
| - assert_unreached('The promise should be rejected.');
|
| - }, function(reason) {
|
| - // Expecting promise to be rejected until getStats is implemented.
|
| - // crbug.com/627816
|
| + .then(function(report) {
|
| + assert_expected_report(report);
|
| });
|
| });
|
| }, 'getStats(MediaStreamTrack selector)');
|
| @@ -30,11 +61,8 @@ promise_test(function() {
|
| .then(function(mediaStream) {
|
| pc.addStream(mediaStream);
|
| return pc.getStats(null)
|
| - .then(function(statsReport) {
|
| - assert_unreached('The promise should be rejected.');
|
| - }, function(reason) {
|
| - // Expecting promise to be rejected until getStats is implemented.
|
| - // crbug.com/627816
|
| + .then(function(report) {
|
| + assert_expected_report(report);
|
| });
|
| });
|
| }, 'getStats(null)');
|
| @@ -44,11 +72,8 @@ promise_test(function() {
|
| .then(function(mediaStream) {
|
| pc.addStream(mediaStream);
|
| return pc.getStats()
|
| - .then(function(statsReport) {
|
| - assert_unreached('The promise should be rejected.');
|
| - }, function(reason) {
|
| - // Expecting promise to be rejected until getStats is implemented.
|
| - // crbug.com/627816
|
| + .then(function(report) {
|
| + assert_expected_report(report);
|
| });
|
| });
|
| }, 'getStats()');
|
|
|