Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: tests/PictureTest.cpp

Issue 183023014: Give PictureTest more verbose error messages. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: x Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PictureTest.cpp
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index c54a9d56d665fdb7223ff84dc9b18dc675d155a5..47804c7850ec758b83ca871771abc7d5f5c02bf3 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -416,25 +416,29 @@ static void gather_from_analytic(const SkPoint pos[], SkScalar w, SkScalar h,
}
}
-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 @@ static void test_gatherpixelrefs(skiatest::Reporter* reporter) {
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 @@ static void test_gatherpixelrefs(skiatest::Reporter* reporter) {
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 @@ static void test_gatherpixelrefs(skiatest::Reporter* reporter) {
// 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 @@ static void test_gatherpixelrefs(skiatest::Reporter* reporter) {
*/
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 @@ static void test_gatherpixelrefsandrects(skiatest::Reporter* reporter) {
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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698