| <!doctype html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>Testing basic video exchange from offerer to receiver</title> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| <script src ="routines.js"></script> |
| <script> |
| function getTrackStats(connection) |
| { |
| return connection.getStats().then((report) => { |
| var stats; |
| report.forEach((statItem) => { |
| if (statItem.type === "track") { |
| stats = statItem; |
| } |
| }); |
| return stats; |
| }); |
| } |
| |
| var firstConnection, secondConnection; |
| promise_test((test) => { |
| if (window.testRunner) |
| testRunner.setUserMediaPermission(true); |
| |
| var localStream, remoteStream; |
| return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => { |
| localStream = stream; |
| return new Promise((resolve, reject) => { |
| createConnections((connection) => { |
| firstConnection = connection; |
| firstConnection.addTrack(stream.getVideoTracks()[0], stream); |
| }, (connection) => { |
| secondConnection = connection; |
| secondConnection.ontrack = (trackEvent) => { |
| remoteStream = trackEvent.streams[0]; |
| resolve(); |
| }; |
| }); |
| setTimeout(() => reject("Test timed out"), 5000); |
| }); |
| }).then(() => { |
| return getTrackStats(secondConnection); |
| }).then((stats) => { |
| assert_true(!!stats, "tracks stats should not be null or undefined"); |
| stats.id = "id"; |
| stats.timestamp = 1; |
| stats.trackIdentifier = "trackid"; |
| assert_equals(stats.type, "track"); |
| assert_false(stats.detached); |
| assert_false(stats.ended); |
| assert_equals(stats.framesDecoded, 0); |
| assert_equals(stats.framesDropped, 0); |
| assert_equals(stats.framesReceived, 0); |
| assert_true(stats.remoteSource); |
| assert_equals(stats.trackIdentifier, "trackid"); |
| // non standard stats. |
| assert_equals(stats.freezeCount, 0); |
| assert_equals(stats.pauseCount, 0); |
| assert_equals(stats.totalFreezesDuration, 0); |
| assert_equals(stats.totalPausesDuration, 0); |
| return waitFor(1000); |
| }).then(() => { |
| return getTrackStats(secondConnection); |
| }).then((stats) => { |
| assert_equals(stats.frameHeight, 480); |
| assert_equals(stats.frameWidth, 640); |
| assert_true(stats.framesDecoded > 0); |
| assert_true(stats.framesReceived > 0); |
| }); |
| }, "Basic video media stream track stats"); |
| </script> |
| </body> |
| </html> |