Commit 9608749b authored by Peter E Conn's avatar Peter E Conn Committed by Commit Bot

📷 Enable Render Tests.

Make the render tests fail if the rendered bitmap does not match the
golden.

Bug: 641973
Change-Id: I432111296893bafab18dc65bfb62b12a8212d68e
Reviewed-on: https://chromium-review.googlesource.com/565399
Commit-Queue: Peter Conn <peconn@chromium.org>
Reviewed-by: default avatarJohn Budorick <jbudorick@chromium.org>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488631}
parent 5ccd006d
...@@ -74,11 +74,11 @@ public class RenderTestRule extends TestWatcher { ...@@ -74,11 +74,11 @@ public class RenderTestRule extends TestWatcher {
private static final String[] RENDER_TEST_DEVICES = {"Nexus 5X", "Nexus 5"}; private static final String[] RENDER_TEST_DEVICES = {"Nexus 5X", "Nexus 5"};
/** /**
* Before we know how flaky screenshot tests are going to be we don't want them to cause a * We only want to cause the tests to fail when renders mismatch for devices that we test on
* full test failure every time they fail. If the tests prove their worth, this will be set to * both the CI and the CQ. This is temporary and will be removed once all the
* false/removed. * {@link RENDER_TEST_DEVICES} are run on the CI and CQ. https://crbug.com/731759.
*/ */
private static final boolean REPORT_ONLY_DO_NOT_FAIL = true; private static final String[] FAIL_ON_MISMATCH_DEVICES = {"Nexus 5"};
/** How many pixels can be different in an image before counting the images as different. */ /** How many pixels can be different in an image before counting the images as different. */
private static final int PIXEL_DIFF_THRESHOLD = 0; private static final int PIXEL_DIFF_THRESHOLD = 0;
...@@ -198,10 +198,10 @@ public class RenderTestRule extends TestWatcher { ...@@ -198,10 +198,10 @@ public class RenderTestRule extends TestWatcher {
sb.append(TextUtils.join(", ", mMismatchIds)); sb.append(TextUtils.join(", ", mMismatchIds));
} }
if (REPORT_ONLY_DO_NOT_FAIL) { if (shouldFailOnMismatch()) {
Log.w(TAG, sb.toString());
} else {
throw new RenderTestException(sb.toString()); throw new RenderTestException(sb.toString());
} else {
Log.w(TAG, sb.toString());
} }
} }
...@@ -215,6 +215,16 @@ public class RenderTestRule extends TestWatcher { ...@@ -215,6 +215,16 @@ public class RenderTestRule extends TestWatcher {
return false; return false;
} }
/**
* Returns whether a mismatch should cause a test failure.
*/
private static boolean shouldFailOnMismatch() {
for (String model : FAIL_ON_MISMATCH_DEVICES) {
if (model.equals(Build.MODEL)) return true;
}
return false;
}
/** /**
* Creates an image name combining the image description with details about the device * Creates an image name combining the image description with details about the device
* (eg model, current orientation). * (eg model, current orientation).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment