Title: [222446] trunk/LayoutTests
Revision
222446
Author
[email protected]
Date
2017-09-25 09:00:42 -0700 (Mon, 25 Sep 2017)

Log Message

Make captureCanvas-webrtc.html more robust
https://bugs.webkit.org/show_bug.cgi?id=177334

Patch by Youenn Fablet <[email protected]> on 2017-09-25
Reviewed by Darin Adler.

Making test more robust by printing synchronously the canvas and increasing.
the threshold for pixel comparison.
Minor refactoring for improving the readability.

* webrtc/captureCanvas-webrtc.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222445 => 222446)


--- trunk/LayoutTests/ChangeLog	2017-09-25 15:59:58 UTC (rev 222445)
+++ trunk/LayoutTests/ChangeLog	2017-09-25 16:00:42 UTC (rev 222446)
@@ -1,5 +1,18 @@
 2017-09-25  Youenn Fablet  <[email protected]>
 
+        Make captureCanvas-webrtc.html more robust
+        https://bugs.webkit.org/show_bug.cgi?id=177334
+
+        Reviewed by Darin Adler.
+
+        Making test more robust by printing synchronously the canvas and increasing.
+        the threshold for pixel comparison.
+        Minor refactoring for improving the readability.
+
+        * webrtc/captureCanvas-webrtc.html:
+
+2017-09-25  Youenn Fablet  <[email protected]>
+
         LayoutTest webrtc/video-mute.html is very often failing
         https://bugs.webkit.org/show_bug.cgi?id=177331
 

Modified: trunk/LayoutTests/webrtc/captureCanvas-webrtc.html (222445 => 222446)


--- trunk/LayoutTests/webrtc/captureCanvas-webrtc.html	2017-09-25 15:59:58 UTC (rev 222445)
+++ trunk/LayoutTests/webrtc/captureCanvas-webrtc.html	2017-09-25 16:00:42 UTC (rev 222446)
@@ -10,16 +10,23 @@
         <script>
 
 var color = "green";
-function printRectangle()
+
+function printCanvas()
 {
     var context = canvas1.getContext("2d");
     context.fillStyle = color;
-    context.fillRect(0, 0, 320, 240);
-    setTimeout(printRectangle, 50);
+    context.fillRect(0, 0, canvas1.width, canvas1.height);
 }
 
-function testCanvas(testName, array1, isSame, count)
+function printRectangleEvery50ms()
 {
+    printCanvas();
+    setTimeout(printRectangleEvery50ms, 50);
+}
+
+function testCanvas(testName, canvas, isSame, count)
+{
+    var array1 = canvas.getContext("2d").getImageData(20, 20, 60, 60).data;
     if (count === undefined)
         count = 0;
     canvas2.getContext("2d").drawImage(video, 0 ,0);
@@ -29,24 +36,24 @@
     for (index = 0; index < array1.length; ++index) {
         // Rough comparison since we are compressing data.
         // This test still catches errors since we are going from green to blue to red.
-        if (Math.abs(array1[index] - array2[index]) > 40) {
+        if (Math.abs(array1[index] - array2[index]) > 100) {
             isEqual = false;
             continue;
         }
     }
     if (isEqual === isSame)
-        return;
+        return Promise.resolve();
 
     if (count === 20)
         return Promise.reject(testName + " failed, expected " + JSON.stringify(array1) + " but got " + JSON.stringify(array2));
 
     return waitFor(100).then(() => {
-        return testCanvas(testName, array1, isSame, ++count);
+        return testCanvas(testName, canvas, isSame, ++count);
     });
 }
 
 promise_test((test) => {
-    printRectangle();
+    printRectangleEvery50ms();
     return new Promise((resolve, reject) => {
         createConnections((firstConnection) => {
             var stream = canvas1.captureStream();
@@ -68,29 +75,26 @@
 }, "Setting up the connection");
 
 promise_test((test) => {
-    return waitFor(100).then(() => {
-        return testCanvas("test 1", canvas1.getContext("2d").getImageData(20, 20, 60, 60).data, true);
-    });
+    return testCanvas("test 1", canvas1, true);
 }, "Checking canvas is green");
 
 promise_test((test) => {
     color = "red";
-    return waitFor(300).then(() => {
-        return testCanvas("test 2", canvas1.getContext("2d").getImageData(20, 20, 60, 60).data, true);
-    });
+    printCanvas()
+    return testCanvas("test 2", canvas1, true);
 }, "Checking canvas is red");
 
 
 promise_test((test) => {
     color = "green";
-    return waitFor(300).then(() => {
-        return testCanvas("test 3", canvas1.getContext("2d").getImageData(20, 20, 60, 60).data, true);
-    });
+    printCanvas();
+    return testCanvas("test 3", canvas1, true);
 }, "Checking canvas is green again");
 
 promise_test((test) => {
     canvas1.width = 640;
     canvas1.height = 480;
+    printCanvas();
     return waitForVideoSize(video, 640, 480);
 }, "Checking canvas size change");
         </script>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to