Improve debugging ability of some webrtc tests
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Jun 2017 23:53:00 +0000 (23:53 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Jun 2017 23:53:00 +0000 (23:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173549

Patch by Youenn Fablet <youenn@apple.com> on 2017-06-19
Reviewed by Eric Carlson.

Improve debugging ability for first two tests.
Improve reliability for the next three tests.

* webrtc/audio-replace-track-expected.txt:
* webrtc/audio-replace-track.html: Checking connected state.
* webrtc/video-mute-expected.txt:
* webrtc/video-mute.html: Ditto.
* webrtc/video-replace-track-to-null.html: Improving reliability of test.
* webrtc/video-rotation.html: Adding some delay before testing black frames and increasing delay between the tests..
* webrtc/video-unmute.html: Using counter based testing of black frames.

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

LayoutTests/ChangeLog
LayoutTests/webrtc/audio-replace-track-expected.txt
LayoutTests/webrtc/audio-replace-track.html
LayoutTests/webrtc/video-mute-expected.txt
LayoutTests/webrtc/video-mute.html
LayoutTests/webrtc/video-replace-track-to-null.html
LayoutTests/webrtc/video-rotation.html
LayoutTests/webrtc/video-unmute.html

index 0073611..ec8508c 100644 (file)
@@ -1,3 +1,21 @@
+2017-06-19  Youenn Fablet  <youenn@apple.com>
+
+        Improve debugging ability of some webrtc tests
+        https://bugs.webkit.org/show_bug.cgi?id=173549
+
+        Reviewed by Eric Carlson.
+
+        Improve debugging ability for first two tests.
+        Improve reliability for the next three tests.
+
+        * webrtc/audio-replace-track-expected.txt:
+        * webrtc/audio-replace-track.html: Checking connected state.
+        * webrtc/video-mute-expected.txt:
+        * webrtc/video-mute.html: Ditto.
+        * webrtc/video-replace-track-to-null.html: Improving reliability of test.
+        * webrtc/video-rotation.html: Adding some delay before testing black frames and increasing delay between the tests..
+        * webrtc/video-unmute.html: Using counter based testing of black frames.
+
 2017-06-19  Alex Christensen  <achristensen@webkit.org>
 
         [Cocoa] implement URLSession:task:needNewBodyStream: delegate method
index ee27233..fd39e33 100644 (file)
@@ -1,5 +1,6 @@
 
 PASS Starting an audio connection 
+PASS Ensuring connection state is connected 
 PASS Ensuring mock audio source is received on the remote side 
 PASS Using replaceTrack for audio 
 PASS Ensuring remote audio gets the replacing track data 
index 0156dde..952bc8b 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <head>
     <meta charset="utf-8">
-    <title>Testing local audio capture playback causes "playing" event to fire</title>
+    <title>Testing replacing an audio track during a WebRTC call</title>
     <script src="../resources/testharness.js"></script>
     <script src="../resources/testharnessreport.js"></script>
     <script src ="routines.js"></script>
@@ -12,6 +12,7 @@
     var sender;
     var remoteStream;
     var secondStream;
+    var receivingConnection;
     promise_test((test) => {
         if (window.testRunner)
             testRunner.setUserMediaPermission(true);
@@ -21,6 +22,7 @@
                 createConnections((firstConnection) => {
                     sender = firstConnection.addTrack(firstStream.getAudioTracks()[0], firstStream);
                 }, (secondConnection) => {
+                    receivingConnection = secondConnection;
                     secondConnection.ontrack = (trackEvent) => { resolve(trackEvent.streams[0]); };
                 });
                 setTimeout(() => reject("Test timed out"), 5000);
     }, "Starting an audio connection");
 
     promise_test(() => {
+        if (receivingConnection.connectionState === "connected")
+            return Promise.resolve();
+        return new Promise((resolve, reject) => {
+            receivingConnection.onconnectionstatechange = () => {
+                if (receivingConnection.connectionState === "connected")
+                    resolve();
+            };
+            setTimeout(() => reject("Test timed out"), 5000);
+        });
+    }, "Ensuring connection state is connected");
+
+    promise_test(() => {
         return doHumAnalysis(remoteStream, true).then((result) => {
             assert_true(result, "heard hum 1");
         });
index 4e343a9..0a25875 100644 (file)
@@ -3,6 +3,7 @@ Following, should be a snapshot of the video, a black frame and a snapshot of th
   
 
 PASS Setting video exchange 
+PASS Ensuring connection state is connected 
 PASS Track is enabled, video should not be black 
 PASS Track is disabled, video should be black 
 PASS If disabled, black frames should still be coming 
index 92a2998..a03b219 100644 (file)
@@ -2,7 +2,7 @@
 <html>
     <head>
         <meta charset="utf-8">
-        <title>Testing basic video exchange from offerer to receiver</title>
+        <title>Testing muting video</title>
         <script src="../resources/testharness.js"></script>
         <script src="../resources/testharnessreport.js"></script>
     </head>
@@ -52,6 +52,7 @@ function checkVideoBlack(expected, id)
 
 var track;
 var remoteTrack;
+var receivingConnection;
 promise_test((test) => {
     if (window.testRunner)
         testRunner.setUserMediaPermission(true);
@@ -63,9 +64,10 @@ promise_test((test) => {
             createConnections((firstConnection) => {
                 firstConnection.addTrack(track, localStream);
             }, (secondConnection) => {
+                receivingConnection = secondConnection;
                 secondConnection.ontrack = (trackEvent) => {
                     remoteTrack = trackEvent.track;
-                    resolve(trackEvent.streams[0]); 
+                    resolve(trackEvent.streams[0]);
                 };
             });
             setTimeout(() => reject("Test timed out"), 5000);
@@ -76,6 +78,18 @@ promise_test((test) => {
     });
 }, "Setting video exchange");
 
+promise_test(() => {
+    if (receivingConnection.connectionState === "connected")
+        return Promise.resolve();
+    return new Promise((resolve, reject) => {
+        receivingConnection.onconnectionstatechange = () => {
+            if (receivingConnection.connectionState === "connected")
+                resolve();
+        };
+        setTimeout(() => reject("Test timed out"), 5000);
+    });
+}, "Ensuring connection state is connected");
+
 promise_test((test) => {
     return checkVideoBlack(false, "canvas1");
 }, "Track is enabled, video should not be black");
index 6c978b0..78652b5 100644 (file)
@@ -32,7 +32,7 @@ function storeFrame()
     firstFrameData = grabImagePixels();
 }
 
-function testCameraImage()
+function checkCameraImageIsDifferent()
 {
     data = grabImagePixels();
 
@@ -47,7 +47,23 @@ function testCameraImage()
             break;
         }
     }
-    assert_false(same);
+    return !same;
+}
+
+function testCameraImage(resolve, reject, counter)
+{
+    if (!counter)
+        counter = 0;
+
+    if (checkCameraImageIsDifferent()) {
+        resolve();
+        return;
+    }
+    if (++counter === 20) {
+        reject("testCameraImage timed out");
+        return;
+    }
+    setTimeout(() => testCameraImage(resolve, reject, counter));
 }
 
 function testStoppedImage()
@@ -83,7 +99,9 @@ promise_test((test) => {
         storeFrame();
         return waitFor(100);
     }).then(() => {
-        testCameraImage();
+        return new Promise((resolve, reject) => {
+            testCameraImage(resolve, reject);
+        });
     }).then(() => {
         promise = sender.replaceTrack(null);
         assert_true(!!sender.track);
index b8d18d9..3e7da58 100644 (file)
@@ -2,7 +2,7 @@
 <html>
     <head>
         <meta charset="utf-8">
-        <title>Testing basic video exchange from offerer to receiver</title>
+        <title>Testing video rotation in basic video exchange </title>
         <script src="../resources/testharness.js"></script>
         <script src="../resources/testharnessreport.js"></script>
     </head>
@@ -37,7 +37,7 @@ function pollVideoBlackCheck(expected, id, resolve)
         return;
     }
 
-    setTimeout(() => pollVideoBlackCheck(expected, id, resolve), 50);
+    setTimeout(() => pollVideoBlackCheck(expected, id, resolve), 100);
 }
 
 function checkVideoBlack(expected, id)
@@ -49,7 +49,6 @@ function checkVideoBlack(expected, id)
 }
 
 var track;
-var remoteTrack;
 promise_test((test) => {
     if (window.testRunner)
         testRunner.setUserMediaPermission(true);
@@ -64,8 +63,7 @@ promise_test((test) => {
                     internals.applyRotationForOutgoingVideoSources(firstConnection);
             }, (secondConnection) => {
                 secondConnection.ontrack = (trackEvent) => {
-                    remoteTrack = trackEvent.track;
-                    resolve(trackEvent.streams[0]); 
+                    resolve(trackEvent.streams[0]);
                 };
             });
             setTimeout(() => reject("Test timed out"), 5000);
@@ -91,7 +89,9 @@ promise_test((test) => {
 
 promise_test((test) => {
     track.enabled = false;
-    return checkVideoBlack(true, "canvas2");
+    return waitFor(500).then(() => {
+        return checkVideoBlack(true, "canvas2");
+    })
 }, "Track is disabled, video should be black");
 
         </script>
index 8006536..bc69531 100644 (file)
@@ -31,21 +31,26 @@ function isVideoBlack(id)
     return true;
 }
 
-function pollVideoBlackCheck(expected, id, resolve)
+function pollVideoBlackCheck(expected, id, resolve, reject, counter)
 {
     if (isVideoBlack(id) === expected) {
         resolve();
         return;
     }
 
-    setTimeout(() => pollVideoBlackCheck(expected, id, resolve), 50);
+    if (!counter)
+        counter = 0;
+    else if (++counter > 20) {
+        reject("test for " + id + " timed out");
+        return;
+    }
+    setTimeout(() => pollVideoBlackCheck(expected, id, resolve, reject, counter), 100);
 }
 
 function checkVideoBlack(expected, id)
 {
     return new Promise((resolve, reject) => {
         pollVideoBlackCheck(expected, id, resolve);
-        setTimeout(() => reject("checkVideoBlack timed out for " + id + " expected " + expected), 5000);
     });
 }