LayoutTest webrtc/video-mute.html is very often failing
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2017 15:59:58 +0000 (15:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2017 15:59:58 +0000 (15:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177331

Patch by Youenn Fablet <youenn@apple.com> on 2017-09-25
Reviewed by Darin Adler.

* webrtc/video-mute.html: using getStats instead of internals to check whether black frames are received.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222445 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webrtc/video-mute.html

index b549d88..3e3e166 100644 (file)
@@ -1,3 +1,12 @@
+2017-09-25  Youenn Fablet  <youenn@apple.com>
+
+        LayoutTest webrtc/video-mute.html is very often failing
+        https://bugs.webkit.org/show_bug.cgi?id=177331
+
+        Reviewed by Darin Adler.
+
+        * webrtc/video-mute.html: using getStats instead of internals to check whether black frames are received.
+
 2017-09-25  Ms2ger  <Ms2ger@igalia.com>
 
         Update waitSync and the TIMEOUT_IGNORED constant to use signed integers.
index 53cdeb4..f279c13 100644 (file)
@@ -64,19 +64,38 @@ promise_test((test) => {
     return checkVideoBlack(true, canvas2, video);
 }, "Track is disabled, video should be black");
 
-promise_test((test) => {
-    if (!window.internals)
-        return Promise.reject("This test requires internals API");
-    internals.observeMediaStreamTrack(remoteTrack);
-    let counter = internals.trackVideoSampleCount;
-    return new Promise((resolve, reject) => {
-        setInterval(() => {
-            // Should get 1 frame per second.
-            if (internals.trackVideoSampleCount - counter >= 2)
-                resolve();
-        }, 300);
-        setTimeout(() => reject("did not get frames"), 5000);
+async function getInboundRTPStatsNumberOfDecodedFrames(connection)
+{
+    var report = await connection.getStats();
+    var framesDecoded;
+    report.forEach((statItem) => {
+        if (statItem.type === "inbound-rtp")
+            framesDecoded = statItem.framesDecoded;
     });
+    return framesDecoded;
+}
+
+async function testFrameDecodedIncreased(connection, count, previousFramesNumber)
+{
+    if (previousFramesNumber === undefined) {
+        let number = await getInboundRTPStatsNumberOfDecodedFrames(connection);
+        await waitFor(1000);
+        return testFrameDecodedIncreased(connection, 0, number);
+    }
+
+    var number = await getInboundRTPStatsNumberOfDecodedFrames(connection);
+    if (previousFramesNumber && number > previousFramesNumber)
+        return;
+
+    if (count >= 20)
+        return Promise.reject("test increasing frame encoded timed out");
+
+    await waitFor(1000);
+    return testFrameDecodedIncreased(connection, ++count, previousFramesNumber);
+}
+
+promise_test((test) => {
+    return testFrameDecodedIncreased(receivingConnection);
 }, "If disabled, black frames should still be coming");
 
 promise_test((test) => {