Commit c3d474be authored by Brian Sheedy's avatar Brian Sheedy Committed by Commit Bot

Prepare RenderTests for name changes

Prepares RenderTestRule for the upcoming test name change to not include
OS or device model in the test name reported to Skia Gold. This is done
by creating a copy of the compareForResult method that does not add the
extra information and calling it at the end of compareForResult.

These extra comparisons have the ignore=1 field in their JSON, which
means that they won't cause Gold to comment on CLs if they fail. This is
so that any existing flakiness in the tests can work through the system
with the new names without affecting anyone.

Once everything is ready, this new implementation can just replace the
existing compareForResult (with the ignore field removed and some
renaming performed).

Bug: 1077274
Change-Id: I714999a382b2f2f9a7e4e5abe34d46a817c8882a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2337101Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarBrian Sheedy <bsheedy@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796052}
parent c1e388c5
......@@ -206,6 +206,42 @@ public class RenderTestRule extends TestWatcher {
Assert.fail("Failed to create Skia Gold JSON keys: " + e.toString());
}
saveString(goldKeys.toString(), createOutputPath(SKIA_GOLD_FOLDER_RELATIVE, jsonName));
// TODO(crbug.com/1077274): Make this the default behavior instead of calling in addition to
// the above once we're ready to switch.
compareForResultNoDeviceInfo(testBitmap, id);
}
/**
* A temporary version of compareForResult that does not include OS/device model information in
* the test name. This is in preparation for the switch to doing this be default. In the
* interim period, results both with and without the extra information will be uploaded, but the
* latter will be ignored on Gold's end for a period of time.
*/
private void compareForResultNoDeviceInfo(Bitmap testBitmap, String id) throws IOException {
Assert.assertTrue("Render Tests must have the RenderTest feature.", mHasRenderTestFeature);
// Save the image and its metadata to a location where it can be pulled by the test runner
// for comparison after the test finishes.
String imageName = getImageNameNoDeviceInfo(mTestClassName, mVariantPrefix, id);
String jsonName = getJsonNameNoDeviceInfo(mTestClassName, mVariantPrefix, id);
saveBitmap(testBitmap, createOutputPath(SKIA_GOLD_FOLDER_RELATIVE, imageName));
JSONObject goldKeys = new JSONObject();
try {
goldKeys.put("source_type", mSkiaGoldCorpus);
goldKeys.put("model", Build.MODEL);
goldKeys.put("sdk_version", String.valueOf(Build.VERSION.SDK_INT));
if (!TextUtils.isEmpty(mSkiaGoldRevisionDescription)) {
goldKeys.put("revision_description", mSkiaGoldRevisionDescription);
}
goldKeys.put("fail_on_unsupported_configs", String.valueOf(mFailOnUnsupportedConfigs));
// TODO(crbug.com/1077274): Remove this ignore key once this is the default behavior.
goldKeys.put("ignore", "1");
} catch (JSONException e) {
Assert.fail("Failed to create Skia Gold JSON keys: " + e.toString());
}
saveString(goldKeys.toString(), createOutputPath(SKIA_GOLD_FOLDER_RELATIVE, jsonName));
}
/**
......@@ -253,6 +289,13 @@ public class RenderTestRule extends TestWatcher {
return String.format("%s.png", getFileName(testClass, variantPrefix, desc));
}
/**
* Version of getImageName that does not include OS/device model in the name.
*/
private String getImageNameNoDeviceInfo(String testClass, String variantPrefix, String desc) {
return String.format("%s.png", getFileNameNoDeviceInfo(testClass, variantPrefix, desc));
}
/**
* Creates a JSON name combining the description with details about the device (e.g. model,
* current orientation).
......@@ -261,6 +304,13 @@ public class RenderTestRule extends TestWatcher {
return String.format("%s.json", getFileName(testClass, variantPrefix, desc));
}
/**
* Version of getJsonName that does not include OS/device model in the name.
*/
private String getJsonNameNoDeviceInfo(String testClass, String variantPrefix, String desc) {
return String.format("%s.json", getFileNameNoDeviceInfo(testClass, variantPrefix, desc));
}
/**
* Creates a generic filename (without a file extension) combining the description with details
* about the device (e.g. model, current orientation).
......@@ -281,6 +331,21 @@ public class RenderTestRule extends TestWatcher {
"%s.%s.%s.rev_%s", testClass, desc, modelSdkIdentifier(), mSkiaGoldRevision);
}
/**
* Version of getFileName that does not include OS/device model in the name.
*/
private String getFileNameNoDeviceInfo(String testClass, String variantPrefix, String desc) {
if (!TextUtils.isEmpty(mNightModePrefix)) {
desc = mNightModePrefix + "-" + desc;
}
if (!TextUtils.isEmpty(variantPrefix)) {
desc = variantPrefix + "-" + desc;
}
return String.format("%s.%s.rev_%s", testClass, desc, mSkiaGoldRevision);
}
/**
* Returns a string encoding the device model and sdk. It is used to identify device goldens.
*/
......
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