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

Side by Side Diff: tests/EmptyPathTest.cpp

Issue 132843002: Add REPORTF test macro. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: final rebase Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/DataRefTest.cpp ('k') | tests/GpuBitmapCopyTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Test.h" 8 #include "Test.h"
9 #include "TestClassDef.h" 9 #include "TestClassDef.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 12
13 static void appendStr(SkString* str, const SkPaint& paint) {
14 str->appendf(" style[%d] cap[%d] join[%d] antialias[%d]",
15 paint.getStyle(), paint.getStrokeCap(),
16 paint.getStrokeJoin(), paint.isAntiAlias());
17 }
18
19 static void appendStr(SkString* str, const SkPath& path) {
20 str->appendf(" filltype[%d] ptcount[%d]",
21 path.getFillType(), path.countPoints());
22 }
23
24 #define DIMENSION 32 13 #define DIMENSION 32
25 14
26 static void drawAndTest(skiatest::Reporter* reporter, const SkPath& path, 15 static void drawAndTest(skiatest::Reporter* reporter, const SkPath& path,
27 const SkPaint& paint, bool shouldDraw) { 16 const SkPaint& paint, bool shouldDraw) {
28 SkBitmap bm; 17 SkBitmap bm;
29 // explicitly specify a trim rowbytes, so we have no padding on each row 18 // explicitly specify a trim rowbytes, so we have no padding on each row
30 bm.setConfig(SkBitmap::kARGB_8888_Config, DIMENSION, DIMENSION, DIMENSION*4) ; 19 bm.setConfig(SkBitmap::kARGB_8888_Config, DIMENSION, DIMENSION, DIMENSION*4) ;
31 bm.allocPixels(); 20 bm.allocPixels();
32 bm.eraseColor(SK_ColorTRANSPARENT); 21 bm.eraseColor(SK_ColorTRANSPARENT);
33 22
(...skipping 11 matching lines...) Expand all
45 for (size_t i = 0; i < count; ++i) { 34 for (size_t i = 0; i < count; ++i) {
46 SkPMColor c = ptr[i]; 35 SkPMColor c = ptr[i];
47 andValue &= c; 36 andValue &= c;
48 orValue |= c; 37 orValue |= c;
49 } 38 }
50 39
51 // success means we drew everywhere or nowhere (depending on shouldDraw) 40 // success means we drew everywhere or nowhere (depending on shouldDraw)
52 bool success = shouldDraw ? (~0U == andValue) : (0 == orValue); 41 bool success = shouldDraw ? (~0U == andValue) : (0 == orValue);
53 42
54 if (!success) { 43 if (!success) {
55 SkString str; 44 const char* str;
56 if (shouldDraw) { 45 if (shouldDraw) {
57 str.set("Path expected to draw everywhere, but didn't. "); 46 str = "Path expected to draw everywhere, but didn't. ";
58 } else { 47 } else {
59 str.set("Path expected to draw nowhere, but did. "); 48 str = "Path expected to draw nowhere, but did. ";
60 } 49 }
61 appendStr(&str, paint); 50 ERRORF(reporter, "%s style[%d] cap[%d] join[%d] antialias[%d]"
62 appendStr(&str, path); 51 " filltype[%d] ptcount[%d]", str, paint.getStyle(),
63 reporter->reportFailed(str); 52 paint.getStrokeCap(), paint.getStrokeJoin(),
64 53 paint.isAntiAlias(), path.getFillType(), path.countPoints());
65 // uncomment this if you want to step in to see the failure 54 // uncomment this if you want to step in to see the failure
66 // canvas.drawPath(path, p); 55 // canvas.drawPath(path, p);
67 } 56 }
68 } 57 }
69 58
70 static void iter_paint(skiatest::Reporter* reporter, const SkPath& path, bool sh ouldDraw) { 59 static void iter_paint(skiatest::Reporter* reporter, const SkPath& path, bool sh ouldDraw) {
71 static const SkPaint::Cap gCaps[] = { 60 static const SkPaint::Cap gCaps[] = {
72 SkPaint::kButt_Cap, 61 SkPaint::kButt_Cap,
73 SkPaint::kRound_Cap, 62 SkPaint::kRound_Cap,
74 SkPaint::kSquare_Cap 63 SkPaint::kSquare_Cap
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 bool shouldDraw = path.isInverseFillType(); 134 bool shouldDraw = path.isInverseFillType();
146 iter_paint(reporter, path, shouldDraw); 135 iter_paint(reporter, path, shouldDraw);
147 } 136 }
148 } 137 }
149 } 138 }
150 } 139 }
151 140
152 DEF_TEST(EmptyPath, reporter) { 141 DEF_TEST(EmptyPath, reporter) {
153 test_emptydrawing(reporter); 142 test_emptydrawing(reporter);
154 } 143 }
OLDNEW
« no previous file with comments | « tests/DataRefTest.cpp ('k') | tests/GpuBitmapCopyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698