Bug 1392143 - P5. Improve rendering test. r=mattwoodrow
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 07 Sep 2017 19:19:35 +0200
changeset 379703 0e76e3df87497dd708ea3affc7e7dafb532d71c0
parent 379702 6714fb98a7f25b857dab3f276e5b85871e5792a0
child 379704 9b99855c32cac452f6e6ded85e6b96769f9d6318
push id32461
push userkwierso@gmail.com
push dateFri, 08 Sep 2017 20:15:32 +0000
treeherdermozilla-central@dd3736e98e4e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1392143
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1392143 - P5. Improve rendering test. r=mattwoodrow We now check that the canvas is properly scaled by checking if the color immediately on the right of the canvas is correct. If the rendering failed, we do not bother testing the H264 video decoder. MozReview-Commit-ID: IwBwKnceLBg
toolkit/components/gfx/SanityTest.js
toolkit/components/gfx/content/sanitytest.html
--- a/toolkit/components/gfx/SanityTest.js
+++ b/toolkit/components/gfx/SanityTest.js
@@ -9,16 +9,20 @@ const { utils: Cu, interfaces: Ci, class
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 const FRAME_SCRIPT_URL = "chrome://gfxsanity/content/gfxFrameScript.js";
 
 const PAGE_WIDTH = 160;
 const PAGE_HEIGHT = 234;
+const LEFT_EDGE = 8;
+const TOP_EDGE = 8;
+const CANVAS_WIDTH = 32;
+const CANVAS_HEIGHT = 64;
 const DRIVER_PREF = "sanity-test.driver-version";
 const DEVICE_PREF = "sanity-test.device-id";
 const VERSION_PREF = "sanity-test.version";
 const ADVANCED_LAYERS_PREF = "sanity-test.advanced-layers";
 const DISABLE_VIDEO_PREF = "media.hardware-video-decoding.failed";
 const RUNNING_PREF = "sanity-test.running";
 const TIMEOUT_SEC = 20;
 
@@ -115,43 +119,45 @@ function takeWindowSnapshot(win, ctx) {
 function verifyVideoRendering(ctx) {
   return testPixel(ctx, 41, 105, 255, 255, 255, 255, 64) &&
     testPixel(ctx, 107, 105, 0, 255, 0, 255, 64) &&
     testPixel(ctx, 41, 171, 0, 0, 255, 255, 64) &&
     testPixel(ctx, 107, 171, 255, 0, 0, 255, 64);
 }
 
 // Verify that the middle of the layers test is the color we expect.
-// It's a red 64x64 square, test a pixel deep into the 64x64 square
-// to prevent fuzzing.
+// It's a red CANVAS_WIDTHxCANVAS_HEIGHT square, test a pixel deep into the
+// square to prevent fuzzing, and another outside the expected limit of the
+// square to check that scaling occurred properly. The square is drawn LEFT_EDGE
+// pixels from the window's left edge and TOP_EDGE from the window's top edge.
 function verifyLayersRendering(ctx) {
-  return testPixel(ctx, 18, 18, 255, 0, 0, 255, 64);
+  return testPixel(ctx, LEFT_EDGE + CANVAS_WIDTH / 2, TOP_EDGE + CANVAS_HEIGHT / 2, 255, 0, 0, 255, 64) &&
+         testPixel(ctx, LEFT_EDGE + CANVAS_WIDTH, TOP_EDGE + CANVAS_HEIGHT / 2, 255, 255, 255, 255, 64);
 }
 
 function testCompositor(test, win, ctx) {
   takeWindowSnapshot(win, ctx);
   var testPassed = true;
 
-  if (!verifyVideoRendering(ctx)) {
-    reportResult(TEST_FAILED_VIDEO);
-    Services.prefs.setBoolPref(DISABLE_VIDEO_PREF, true);
-    testPassed = false;
-  }
-
   if (!verifyLayersRendering(ctx)) {
-    // Try disabling advanced layers if it was enabled. Also trgiger
+    // Try disabling advanced layers if it was enabled. Also trigger
     // a device reset so the screen redraws.
     if (Services.prefs.getBoolPref(AL_ENABLED_PREF, false)) {
       Services.prefs.setBoolPref(AL_TEST_FAILED_PREF, true);
       test.utils.triggerDeviceReset();
     }
     reportResult(TEST_FAILED_RENDER);
     testPassed = false;
   } else {
     Services.prefs.setBoolPref(AL_TEST_FAILED_PREF, false);
+    if (!verifyVideoRendering(ctx)) {
+      reportResult(TEST_FAILED_VIDEO);
+      Services.prefs.setBoolPref(DISABLE_VIDEO_PREF, true);
+      testPassed = false;
+    }
   }
 
   if (testPassed) {
     reportResult(TEST_PASSED);
   }
 
   return testPassed;
 }
--- a/toolkit/components/gfx/content/sanitytest.html
+++ b/toolkit/components/gfx/content/sanitytest.html
@@ -1,6 +1,6 @@
 <html>
     <body>
-        <div style="width:64px; height:64px; background-color:red;"></div>
+        <div style="width:32px; height:64px; background-color:red;"></div>
         <video src="videotest.mp4"></video>
     </body>
 </html>