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

Unified Diff: tests/PathOpsSimplifyFailTest.cpp

Issue 21359002: path ops work in progress (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove space Created 7 years, 3 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 | « tests/PathOpsQuadLineIntersectionTest.cpp ('k') | tests/PathOpsSimplifyTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PathOpsSimplifyFailTest.cpp
diff --git a/tests/PathOpsSimplifyFailTest.cpp b/tests/PathOpsSimplifyFailTest.cpp
index 0245f878c1c5cd8384bae9872e973e4e0b6cf19a..8c0f9ba852078115802091d303a479cab7e0c882 100644
--- a/tests/PathOpsSimplifyFailTest.cpp
+++ b/tests/PathOpsSimplifyFailTest.cpp
@@ -37,63 +37,82 @@ static const SkPoint finitePts[] = {
const size_t finitePtsCount = sizeof(finitePts) / sizeof(finitePts[0]);
+static void failOne(skiatest::Reporter* reporter, int index) {
+ SkPath path;
+ int i = (int) (index % nonFinitePtsCount);
+ int f = (int) (index % finitePtsCount);
+ int g = (int) ((f + 1) % finitePtsCount);
+ switch (index % 13) {
+ case 0: path.lineTo(nonFinitePts[i]); break;
+ case 1: path.quadTo(nonFinitePts[i], nonFinitePts[i]); break;
+ case 2: path.quadTo(nonFinitePts[i], finitePts[f]); break;
+ case 3: path.quadTo(finitePts[f], nonFinitePts[i]); break;
+ case 4: path.cubicTo(nonFinitePts[i], finitePts[f], finitePts[f]); break;
+ case 5: path.cubicTo(finitePts[f], nonFinitePts[i], finitePts[f]); break;
+ case 6: path.cubicTo(finitePts[f], finitePts[f], nonFinitePts[i]); break;
+ case 7: path.cubicTo(nonFinitePts[i], nonFinitePts[i], finitePts[f]); break;
+ case 8: path.cubicTo(nonFinitePts[i], finitePts[f], nonFinitePts[i]); break;
+ case 9: path.cubicTo(finitePts[f], nonFinitePts[i], nonFinitePts[i]); break;
+ case 10: path.cubicTo(nonFinitePts[i], nonFinitePts[i], nonFinitePts[i]); break;
+ case 11: path.cubicTo(nonFinitePts[i], finitePts[f], finitePts[g]); break;
+ case 12: path.moveTo(nonFinitePts[i]); break;
+ }
+ SkPath result;
+ result.setFillType(SkPath::kWinding_FillType);
+ bool success = Simplify(path, &result);
+ REPORTER_ASSERT(reporter, !success);
+ REPORTER_ASSERT(reporter, result.isEmpty());
+ REPORTER_ASSERT(reporter, result.getFillType() == SkPath::kWinding_FillType);
+ reporter->bumpTestCount();
+}
+
+static void dontFailOne(skiatest::Reporter* reporter, int index) {
+ SkPath path;
+ int f = (int) (index % finitePtsCount);
+ int g = (int) ((f + 1) % finitePtsCount);
+ switch (index % 11) {
+ case 0: path.lineTo(finitePts[f]); break;
+ case 1: path.quadTo(finitePts[f], finitePts[f]); break;
+ case 2: path.quadTo(finitePts[f], finitePts[g]); break;
+ case 3: path.quadTo(finitePts[g], finitePts[f]); break;
+ case 4: path.cubicTo(finitePts[f], finitePts[f], finitePts[f]); break;
+ case 5: path.cubicTo(finitePts[f], finitePts[f], finitePts[g]); break;
+ case 6: path.cubicTo(finitePts[f], finitePts[g], finitePts[f]); break;
+ case 7: path.cubicTo(finitePts[f], finitePts[g], finitePts[g]); break;
+ case 8: path.cubicTo(finitePts[g], finitePts[f], finitePts[f]); break;
+ case 9: path.cubicTo(finitePts[g], finitePts[f], finitePts[g]); break;
+ case 10: path.moveTo(finitePts[f]); break;
+ }
+ SkPath result;
+ result.setFillType(SkPath::kWinding_FillType);
+ bool success = Simplify(path, &result);
+ REPORTER_ASSERT(reporter, success);
+ REPORTER_ASSERT(reporter, result.getFillType() != SkPath::kWinding_FillType);
+ reporter->bumpTestCount();
+}
+
static void PathOpsSimplifyFailTest(skiatest::Reporter* reporter) {
for (int index = 0; index < (int) (13 * nonFinitePtsCount * finitePtsCount); ++index) {
- SkPath path;
- int i = (int) (index % nonFinitePtsCount);
- int f = (int) (index % finitePtsCount);
- int g = (int) ((f + 1) % finitePtsCount);
- switch (index % 13) {
- case 0: path.lineTo(nonFinitePts[i]); break;
- case 1: path.quadTo(nonFinitePts[i], nonFinitePts[i]); break;
- case 2: path.quadTo(nonFinitePts[i], finitePts[f]); break;
- case 3: path.quadTo(finitePts[f], nonFinitePts[i]); break;
- case 4: path.cubicTo(nonFinitePts[i], finitePts[f], finitePts[f]); break;
- case 5: path.cubicTo(finitePts[f], nonFinitePts[i], finitePts[f]); break;
- case 6: path.cubicTo(finitePts[f], finitePts[f], nonFinitePts[i]); break;
- case 7: path.cubicTo(nonFinitePts[i], nonFinitePts[i], finitePts[f]); break;
- case 8: path.cubicTo(nonFinitePts[i], finitePts[f], nonFinitePts[i]); break;
- case 9: path.cubicTo(finitePts[f], nonFinitePts[i], nonFinitePts[i]); break;
- case 10: path.cubicTo(nonFinitePts[i], nonFinitePts[i], nonFinitePts[i]); break;
- case 11: path.cubicTo(nonFinitePts[i], finitePts[f], finitePts[g]); break;
- case 12: path.moveTo(nonFinitePts[i]); break;
- }
- SkPath result;
- result.setFillType(SkPath::kWinding_FillType);
- bool success = Simplify(path, &result);
- REPORTER_ASSERT(reporter, !success);
- REPORTER_ASSERT(reporter, result.isEmpty());
- REPORTER_ASSERT(reporter, result.getFillType() == SkPath::kWinding_FillType);
- reporter->bumpTestCount();
- }
- if (sizeof(reporter) == 4) {
- return;
+ failOne(reporter, index);
}
for (int index = 0; index < (int) (11 * finitePtsCount); ++index) {
- SkPath path;
- int f = (int) (index % finitePtsCount);
- int g = (int) ((f + 1) % finitePtsCount);
- switch (index % 11) {
- case 0: path.lineTo(finitePts[f]); break;
- case 1: path.quadTo(finitePts[f], finitePts[f]); break;
- case 2: path.quadTo(finitePts[f], finitePts[g]); break;
- case 3: path.quadTo(finitePts[g], finitePts[f]); break;
- case 4: path.cubicTo(finitePts[f], finitePts[f], finitePts[f]); break;
- case 5: path.cubicTo(finitePts[f], finitePts[f], finitePts[g]); break;
- case 6: path.cubicTo(finitePts[f], finitePts[g], finitePts[f]); break;
- case 7: path.cubicTo(finitePts[f], finitePts[g], finitePts[g]); break;
- case 8: path.cubicTo(finitePts[g], finitePts[f], finitePts[f]); break;
- case 9: path.cubicTo(finitePts[g], finitePts[f], finitePts[g]); break;
- case 10: path.moveTo(finitePts[f]); break;
- }
- SkPath result;
- result.setFillType(SkPath::kWinding_FillType);
- bool success = Simplify(path, &result);
- REPORTER_ASSERT(reporter, success);
- REPORTER_ASSERT(reporter, result.getFillType() != SkPath::kWinding_FillType);
- reporter->bumpTestCount();
+ dontFailOne(reporter, index);
}
}
+static void PathOpsSimplifyFailOneTest(skiatest::Reporter* reporter) {
+ int index = 0;
+ failOne(reporter, index);
+}
+
+static void PathOpsSimplifyDontFailOneTest(skiatest::Reporter* reporter) {
+ int index = 6;
+ dontFailOne(reporter, index);
+}
+
#include "TestClassDef.h"
DEFINE_TESTCLASS_SHORT(PathOpsSimplifyFailTest)
+
+DEFINE_TESTCLASS_SHORT(PathOpsSimplifyFailOneTest)
+
+DEFINE_TESTCLASS_SHORT(PathOpsSimplifyDontFailOneTest)
« no previous file with comments | « tests/PathOpsQuadLineIntersectionTest.cpp ('k') | tests/PathOpsSimplifyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698