Index: tests/PathOpsExtendedTest.cpp |
diff --git a/tests/PathOpsExtendedTest.cpp b/tests/PathOpsExtendedTest.cpp |
index b71b11543919d94a8b11e8add2d29bc732b3e359..2f6d99d6529d329d5f08446905ffbd36a921c2ad 100644 |
--- a/tests/PathOpsExtendedTest.cpp |
+++ b/tests/PathOpsExtendedTest.cpp |
@@ -22,6 +22,15 @@ |
#include <sys/sysctl.h> |
#endif |
+bool OpDebug(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result |
+ SkDEBUGPARAMS(bool skipAssert) |
+ SkDEBUGPARAMS(const char* testName)); |
+ |
+bool SimplifyDebug(const SkPath& one, SkPath* result |
+ SkDEBUGPARAMS(bool skipAssert) |
+ SkDEBUGPARAMS(const char* testName)); |
+ |
+ |
__SK_FORCE_IMAGE_DECODER_LINKING; |
DEFINE_bool2(runFail, f, false, "run tests known to fail."); |
@@ -38,7 +47,7 @@ static const char* opStrs[] = { |
"kDifference_SkPathOp", |
"kIntersect_SkPathOp", |
"kUnion_SkPathOp", |
- "kXor_PathOp", |
+ "kXOR_PathOp", |
"kReverseDifference_SkPathOp", |
}; |
@@ -47,6 +56,7 @@ static const char* opSuffixes[] = { |
"i", |
"u", |
"o", |
+ "r", |
}; |
#if DEBUG_SHOW_TEST_NAME |
@@ -443,20 +453,43 @@ bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& st |
return result == 0; |
} |
+enum class ExpectSuccess { |
+ kNo, |
+ kYes |
+}; |
+ |
+enum class SkipAssert { |
+ kNo, |
+ kYes |
+}; |
+ |
+enum class ExpectMatch { |
+ kNo, |
+ kYes |
+}; |
+ |
static bool inner_simplify(skiatest::Reporter* reporter, const SkPath& path, const char* filename, |
- bool checkFail) { |
+ ExpectSuccess expectSuccess, SkipAssert skipAssert, ExpectMatch expectMatch) { |
#if 0 && DEBUG_SHOW_TEST_NAME |
showPathData(path); |
#endif |
SkPath out; |
- if (!Simplify(path, &out)) { |
- SkDebugf("%s did not expect %s failure\n", __FUNCTION__, filename); |
- REPORTER_ASSERT(reporter, 0); |
+ if (!SimplifyDebug(path, &out SkDEBUGPARAMS(SkipAssert::kYes == skipAssert) |
+ SkDEBUGPARAMS(testName))) { |
+ if (ExpectSuccess::kYes == expectSuccess) { |
+ SkDebugf("%s did not expect %s failure\n", __FUNCTION__, filename); |
+ REPORTER_ASSERT(reporter, 0); |
+ } |
return false; |
+ } else { |
+ if (ExpectSuccess::kNo == expectSuccess) { |
+ SkDebugf("%s %s unexpected success\n", __FUNCTION__, filename); |
+ REPORTER_ASSERT(reporter, 0); |
+ } |
} |
SkBitmap bitmap; |
int errors = comparePaths(reporter, filename, path, out, bitmap); |
- if (!checkFail) { |
+ if (ExpectMatch::kNo == expectMatch) { |
if (!errors) { |
SkDebugf("%s failing test %s now succeeds\n", __FUNCTION__, filename); |
REPORTER_ASSERT(reporter, 0); |
@@ -470,12 +503,19 @@ static bool inner_simplify(skiatest::Reporter* reporter, const SkPath& path, con |
} |
bool testSimplify(skiatest::Reporter* reporter, const SkPath& path, const char* filename) { |
- return inner_simplify(reporter, path, filename, true); |
+ return inner_simplify(reporter, path, filename, ExpectSuccess::kYes, SkipAssert::kNo, |
+ ExpectMatch::kYes); |
+} |
+ |
+bool testSimplifyFailSkipAssert(skiatest::Reporter* reporter, const SkPath& path, const char* filename) { |
+ return inner_simplify(reporter, path, filename, ExpectSuccess::kNo, SkipAssert::kYes, |
+ ExpectMatch::kNo); |
} |
bool testSimplifyCheck(skiatest::Reporter* reporter, const SkPath& path, const char* filename, |
bool checkFail) { |
- return inner_simplify(reporter, path, filename, checkFail); |
+ return inner_simplify(reporter, path, filename, checkFail ? |
+ ExpectSuccess::kYes : ExpectSuccess::kNo, SkipAssert::kNo, ExpectMatch::kNo); |
} |
#if DEBUG_SHOW_TEST_NAME |
@@ -487,23 +527,25 @@ static void showName(const SkPath& a, const SkPath& b, const SkPathOp shapeOp) { |
} |
#endif |
-bool OpDebug(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result |
- SkDEBUGPARAMS(bool skipAssert) |
- SkDEBUGPARAMS(const char* testName)); |
- |
static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
- const SkPathOp shapeOp, const char* testName, bool expectSuccess, bool skipAssert) { |
+ const SkPathOp shapeOp, const char* testName, ExpectSuccess expectSuccess, |
+ SkipAssert skipAssert, ExpectMatch expectMatch) { |
#if 0 && DEBUG_SHOW_TEST_NAME |
showName(a, b, shapeOp); |
#endif |
SkPath out; |
- if (!OpDebug(a, b, shapeOp, &out SkDEBUGPARAMS(skipAssert) |
+ if (!OpDebug(a, b, shapeOp, &out SkDEBUGPARAMS(SkipAssert::kYes == skipAssert) |
SkDEBUGPARAMS(testName))) { |
- if (expectSuccess) { |
- SkDebugf("%s did not expect failure\n", __FUNCTION__); |
+ if (ExpectSuccess::kYes == expectSuccess) { |
+ SkDebugf("%s %s did not expect failure\n", __FUNCTION__, testName); |
REPORTER_ASSERT(reporter, 0); |
} |
return false; |
+ } else { |
+ if (ExpectSuccess::kNo == expectSuccess) { |
+ SkDebugf("%s %s unexpected success\n", __FUNCTION__, testName); |
+ REPORTER_ASSERT(reporter, 0); |
+ } |
} |
if (!reporter->verbose()) { |
return true; |
@@ -533,37 +575,42 @@ static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP |
scaledOut.addPath(out, scale); |
scaledOut.setFillType(out.getFillType()); |
int result = comparePaths(reporter, testName, pathOut, scaledPathOut, out, scaledOut, bitmap, |
- a, b, shapeOp, scale, expectSuccess); |
+ a, b, shapeOp, scale, ExpectMatch::kYes == expectMatch); |
reporter->bumpTestCount(); |
return result == 0; |
} |
bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
const SkPathOp shapeOp, const char* testName) { |
- return innerPathOp(reporter, a, b, shapeOp, testName, true, false); |
+ return innerPathOp(reporter, a, b, shapeOp, testName, ExpectSuccess::kYes, SkipAssert::kNo, |
+ ExpectMatch::kYes); |
} |
bool testPathOpCheck(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
const SkPathOp shapeOp, const char* testName, bool checkFail) { |
- return innerPathOp(reporter, a, b, shapeOp, testName, checkFail, false); |
+ return innerPathOp(reporter, a, b, shapeOp, testName, checkFail ? |
+ ExpectSuccess::kYes : ExpectSuccess::kNo, SkipAssert::kNo, ExpectMatch::kNo); |
} |
bool testPathOpFailCheck(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
const SkPathOp shapeOp, const char* testName) { |
- return innerPathOp(reporter, a, b, shapeOp, testName, false, false); |
+ return innerPathOp(reporter, a, b, shapeOp, testName, ExpectSuccess::kNo, SkipAssert::kNo, |
+ ExpectMatch::kNo); |
} |
-bool testPathSkipAssertOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
+bool testPathOpSkipAssert(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
const SkPathOp shapeOp, const char* testName) { |
- return innerPathOp(reporter, a, b, shapeOp, testName, true, true); |
+ return innerPathOp(reporter, a, b, shapeOp, testName, ExpectSuccess::kYes, SkipAssert::kYes, |
+ ExpectMatch::kYes); |
} |
-bool testPathFailSkipAssertOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
+bool testPathOpFailSkipAssert(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
const SkPathOp shapeOp, const char* testName) { |
- return innerPathOp(reporter, a, b, shapeOp, testName, false, true); |
+ return innerPathOp(reporter, a, b, shapeOp, testName, ExpectSuccess::kNo, SkipAssert::kYes, |
+ ExpectMatch::kNo); |
} |
-bool testPathFailOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
+bool testPathOpFail(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
const SkPathOp shapeOp, const char* testName) { |
#if DEBUG_SHOW_TEST_NAME |
showName(a, b, shapeOp); |