Added better logging for CanvasClients, and test cases in general.
Added test name to the tear down loggin.
Change-Id: Iea341c586a9b3d37fe852e498f1dbc79284b6d2e
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ExactCanvasTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ExactCanvasTests.java
index 678ae81..5f86f90 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ExactCanvasTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ExactCanvasTests.java
@@ -39,6 +39,7 @@
@SmallTest
public void testBlueRect() {
+ final Rect rect = new Rect(10, 10, 100, 100);
createTest()
.addCanvasClient(new CanvasClient() {
@Override
@@ -46,10 +47,10 @@
Paint p = new Paint();
p.setAntiAlias(false);
p.setColor(Color.BLUE);
- canvas.drawRect(0, 0, 100, 100, p);
+ canvas.drawRect(rect, p);
}
})
- .runWithComparer(mExactComparer);
+ .runWithVerifier(new RectVerifier(Color.WHITE, Color.BLUE, rect));
}
@SmallTest
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SweepTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SweepTests.java
index 0ac0bc4..8b7618e 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SweepTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SweepTests.java
@@ -376,6 +376,7 @@
int index = 0;
// Create the test cases with each combination
do {
+ canvasClient.setDebugString(modifierAccessor.getDebugString());
if (bitmapComparers != null) {
int arrIndex = Math.min(index, bitmapComparers.length - 1);
createTest().addCanvasClient(canvasClient).runWithComparer(bitmapComparers[arrIndex]);
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/ActivityTestBase.java b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/ActivityTestBase.java
index bddedcc..f1b6ab7 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/ActivityTestBase.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/ActivityTestBase.java
@@ -85,7 +85,7 @@
for (TestCase testCase : testCases) {
if (!testCase.wasTestRan) {
- Log.w(TAG_NAME, "Not all of the tests were ran");
+ Log.w(TAG_NAME, getName() + " not all of the tests were ran");
break;
}
}
@@ -129,43 +129,44 @@
* the test name.
*/
protected void assertBitmapsAreSimilar(Bitmap bitmap1, Bitmap bitmap2,
- BitmapComparer comparer) {
- boolean res;
+ BitmapComparer comparer, String debugMessage) {
+ boolean success;
if (USE_RS && comparer.supportsRenderScript()) {
mIdealAllocation = Allocation.createFromBitmap(mRenderScript, bitmap1,
Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
mGivenAllocation = Allocation.createFromBitmap(mRenderScript, bitmap2,
Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
- res = comparer.verifySameRS(getActivity().getResources(), mIdealAllocation,
+ success = comparer.verifySameRS(getActivity().getResources(), mIdealAllocation,
mGivenAllocation, 0, TEST_WIDTH, TEST_WIDTH, TEST_HEIGHT, mRenderScript);
} else {
bitmap1.getPixels(mSoftwareArray, 0, TEST_WIDTH, 0, 0, TEST_WIDTH, TEST_HEIGHT);
bitmap2.getPixels(mHardwareArray, 0, TEST_WIDTH, 0, 0, TEST_WIDTH, TEST_HEIGHT);
- res = comparer.verifySame(mSoftwareArray, mHardwareArray, 0, TEST_WIDTH, TEST_WIDTH,
+ success = comparer.verifySame(mSoftwareArray, mHardwareArray, 0, TEST_WIDTH, TEST_WIDTH,
TEST_HEIGHT);
}
- if (!res) {
+ if (!success) {
BitmapDumper.dumpBitmaps(bitmap1, bitmap2, getName(), mDifferenceVisualizer);
}
- assertTrue(res);
+ assertTrue(debugMessage, success);
}
/**
* Tests to see if a bitmap passes a verifier's test. If it doesn't the bitmap is saved to the
* sdcard.
*/
- protected void assertBitmapIsVerified(Bitmap bitmap, BitmapVerifier bitmapVerifier) {
+ protected void assertBitmapIsVerified(Bitmap bitmap, BitmapVerifier bitmapVerifier,
+ String debugMessage) {
bitmap.getPixels(mSoftwareArray, 0, TEST_WIDTH, 0, 0,
TEST_WIDTH, TEST_HEIGHT);
- boolean res = bitmapVerifier.verify(mSoftwareArray, 0, TEST_WIDTH, TEST_WIDTH, TEST_HEIGHT);
- if (!res) {
+ boolean success = bitmapVerifier.verify(mSoftwareArray, 0, TEST_WIDTH, TEST_WIDTH, TEST_HEIGHT);
+ if (!success) {
BitmapDumper.dumpBitmap(bitmap, getName());
BitmapDumper.dumpBitmap(bitmapVerifier.getDifferenceBitmap(), getName() + "_verifier");
}
- assertTrue(res);
+ assertTrue(debugMessage, success);
}
protected TestCaseBuilder createTest() {
@@ -196,7 +197,8 @@
for (TestCase testCase : mTestCases) {
Bitmap testCaseBitmap = captureRenderSpec(testCase);
- assertBitmapsAreSimilar(idealBitmap, testCaseBitmap, bitmapComparer);
+ assertBitmapsAreSimilar(idealBitmap, testCaseBitmap, bitmapComparer,
+ testCase.getDebugString());
}
}
@@ -211,7 +213,7 @@
for (TestCase testCase : mTestCases) {
Bitmap testCaseBitmap = captureRenderSpec(testCase);
- assertBitmapIsVerified(testCaseBitmap, bitmapVerifier);
+ assertBitmapIsVerified(testCaseBitmap, bitmapVerifier, testCase.getDebugString());
}
}
@@ -276,5 +278,24 @@
this.useHardware = useHardware;
this.wasTestRan = false;
}
+
+ public String getDebugString() {
+ String debug = "";
+ if (canvasClient != null) {
+ debug += "CanvasClient : ";
+ if (canvasClient.getDebugString() != null) {
+ debug += canvasClient.getDebugString();
+ } else {
+ debug += "no debug string given";
+ }
+ } else if (webViewUrl != null) {
+ debug += "WebView URL : " + webViewUrl;
+ } else {
+ debug += "Layout resource : " +
+ getActivity().getResources().getResourceName(layoutID);
+ }
+ debug += "\nTest ran in " + (useHardware ? "hardware" : "software") + "\n";
+ return debug;
+ }
}
}
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/CanvasClient.java b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/CanvasClient.java
index 9bef089..a99c576 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/CanvasClient.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/CanvasClient.java
@@ -20,6 +20,16 @@
/**
* A class that the tester will implement and create a set of drawing calls the tests would use
*/
-public interface CanvasClient {
+public abstract class CanvasClient {
+ private String mDebugString;
+
public abstract void draw(Canvas canvas, int width, int height);
+
+ public String getDebugString() {
+ return mDebugString;
+ }
+
+ public void setDebugString(String debugString) {
+ mDebugString = debugString;
+ }
}
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DisplayModifier.java b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DisplayModifier.java
index fdaecf1..50880e9 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DisplayModifier.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DisplayModifier.java
@@ -437,6 +437,7 @@
public final static int XFERMODE_INDEX = 7;
private final int mMask;
+ private String mDebugString;
private int[] mIndices;
private LinkedHashMap<String, LinkedHashMap<String, DisplayModifier>> mDisplayMap;
@@ -453,6 +454,7 @@
}
index++;
}
+ mDebugString = "";
}
private LinkedHashMap<String, DisplayModifier> getMapAtIndex(int index) {
@@ -512,15 +514,20 @@
private ArrayList<DisplayModifier> getModifierList() {
ArrayList<DisplayModifier> modifierArrayList = new ArrayList<DisplayModifier>();
int mapIndex = 0;
+ mDebugString = "";
// Through each possible category of modification
- for (LinkedHashMap<String, DisplayModifier> map : mDisplayMap.values()) {
+ for (Map.Entry<String, LinkedHashMap<String, DisplayModifier>> entry :
+ mDisplayMap.entrySet()) {
int displayModifierIndex = mIndices[mapIndex];
+ mDebugString += "Modification : " + entry.getKey();
// Loop until we find the modification we are going to use
- for (Map.Entry<String, DisplayModifier> modifierEntry : map.entrySet()) {
+ for (Map.Entry<String, DisplayModifier> modifierEntry :
+ entry.getValue().entrySet()) {
// Once we find the modification we want, then we will add it to the list,
// and the last applied modifications
if (displayModifierIndex == 0) {
+ mDebugString += " value : " + modifierEntry.getKey() + " ";
modifierArrayList.add(modifierEntry.getValue());
break;
}
@@ -531,6 +538,10 @@
return modifierArrayList;
}
+ public String getDebugString() {
+ return mDebugString;
+ }
+
/**
* Using the given masks, it tells if the map at the given index should be used, or not.
*/