Give PictureTest more verbose error messages.

Motivation: On an odd build system I'm testing, we're triggering these
errors.  More verbose test output will help me diagnose the errors.

R=robertphillips@google.com

Author: halcanary@google.com

Review URL: https://codereview.chromium.org/183023014

git-svn-id: http://skia.googlecode.com/svn/trunk@13678 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index c54a9d5..47804c7 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -416,25 +416,29 @@
     }
 }
 
-static const DrawBitmapProc gProcs[] = {
-        drawpaint_proc,
-        drawpoints_proc,
-        drawrect_proc,
-        drawoval_proc,
-        drawrrect_proc,
-        drawpath_proc,
-        drawbitmap_proc,
-        drawbitmap_withshader_proc,
-        drawsprite_proc,
+
+static const struct {
+    const DrawBitmapProc proc;
+    const char* const desc;
+} gProcs[] = {
+    {drawpaint_proc, "drawpaint"},
+    {drawpoints_proc, "drawpoints"},
+    {drawrect_proc, "drawrect"},
+    {drawoval_proc, "drawoval"},
+    {drawrrect_proc, "drawrrect"},
+    {drawpath_proc, "drawpath"},
+    {drawbitmap_proc, "drawbitmap"},
+    {drawbitmap_withshader_proc, "drawbitmap_withshader"},
+    {drawsprite_proc, "drawsprite"},
 #if 0
-        drawsprite_withshader_proc,
+    {drawsprite_withshader_proc, "drawsprite_withshader"},
 #endif
-        drawbitmaprect_proc,
-        drawbitmaprect_withshader_proc,
-        drawtext_proc,
-        drawpostext_proc,
-        drawtextonpath_proc,
-        drawverts_proc,
+    {drawbitmaprect_proc, "drawbitmaprect"},
+    {drawbitmaprect_withshader_proc, "drawbitmaprect_withshader"},
+    {drawtext_proc, "drawtext"},
+    {drawpostext_proc, "drawpostext"},
+    {drawtextonpath_proc, "drawtextonpath"},
+    {drawverts_proc, "drawverts"},
 };
 
 static void create_textures(SkBitmap* bm, SkPixelRef** refs, int num, int w, int h) {
@@ -477,7 +481,8 @@
 
     SkRandom rand;
     for (size_t k = 0; k < SK_ARRAY_COUNT(gProcs); ++k) {
-        SkAutoTUnref<SkPicture> pic(record_bitmaps(bm, pos, analytic, N, gProcs[k]));
+        SkAutoTUnref<SkPicture> pic(
+            record_bitmaps(bm, pos, analytic, N, gProcs[k].proc));
 
         REPORTER_ASSERT(reporter, pic->willPlayBackBitmaps() || N == 0);
         // quick check for a small piece of each quadrant, which should just
@@ -487,18 +492,20 @@
             r.set(2, 2, W - 2, H - 2);
             r.offset(pos[i].fX, pos[i].fY);
             SkAutoDataUnref data(SkPictureUtils::GatherPixelRefs(pic, r));
-            REPORTER_ASSERT(reporter, data);
-            if (data) {
-                SkPixelRef** gatheredRefs = (SkPixelRef**)data->data();
-                int count = static_cast<int>(data->size() / sizeof(SkPixelRef*));
-                REPORTER_ASSERT(reporter, 1 == count || 2 == count);
-                if (1 == count) {
-                    REPORTER_ASSERT(reporter, gatheredRefs[0] == refs[i]);
-                } else if (2 == count) {
-                    REPORTER_ASSERT(reporter,
-                        (gatheredRefs[0] == refs[i] && gatheredRefs[1] == refs[i+N]) ||
-                        (gatheredRefs[1] == refs[i] && gatheredRefs[0] == refs[i+N]));
-                }
+            if (!data) {
+                ERRORF(reporter, "SkPictureUtils::GatherPixelRefs returned "
+                       "NULL for %s.", gProcs[k].desc);
+                continue;
+            }
+            SkPixelRef** gatheredRefs = (SkPixelRef**)data->data();
+            int count = static_cast<int>(data->size() / sizeof(SkPixelRef*));
+            REPORTER_ASSERT(reporter, 1 == count || 2 == count);
+            if (1 == count) {
+                REPORTER_ASSERT(reporter, gatheredRefs[0] == refs[i]);
+            } else if (2 == count) {
+                REPORTER_ASSERT(reporter,
+                    (gatheredRefs[0] == refs[i] && gatheredRefs[1] == refs[i+N]) ||
+                    (gatheredRefs[1] == refs[i] && gatheredRefs[0] == refs[i+N]));
             }
         }
 
@@ -528,7 +535,10 @@
             // but the analytic list may contain some pixelRefs that were not
             // seen in the image (e.g., A8 textures used as masks)
             for (int i = 0; i < fromImage.count(); ++i) {
-                REPORTER_ASSERT(reporter, -1 != fromAnalytic.find(fromImage[i]));
+                if (-1 == fromAnalytic.find(fromImage[i])) {
+                    ERRORF(reporter, "PixelRef missing %d %s",
+                           i, gProcs[k].desc);
+                }
             }
 
             /*
@@ -540,7 +550,10 @@
              */
             for (int i = 0; i < fromAnalytic.count(); ++i) {
                 bool found = find(gatherRefs, fromAnalytic[i], gatherCount);
-                REPORTER_ASSERT(reporter, found);
+                if (!found) {
+                    ERRORF(reporter, "PixelRef missing %d %s",
+                           i, gProcs[k].desc);
+                }
 #if 0
                 // enable this block of code to debug failures, as it will rerun
                 // the case that failed.
@@ -573,7 +586,8 @@
 
     SkRandom rand;
     for (size_t k = 0; k < SK_ARRAY_COUNT(gProcs); ++k) {
-        SkAutoTUnref<SkPicture> pic(record_bitmaps(bm, pos, analytic, N, gProcs[k]));
+        SkAutoTUnref<SkPicture> pic(
+            record_bitmaps(bm, pos, analytic, N, gProcs[k].proc));
 
         REPORTER_ASSERT(reporter, pic->willPlayBackBitmaps() || N == 0);