diff options
Diffstat (limited to 'tests/PathOpsExtendedTest.cpp')
-rw-r--r-- | tests/PathOpsExtendedTest.cpp | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/tests/PathOpsExtendedTest.cpp b/tests/PathOpsExtendedTest.cpp index d70deb30fc..06fee80f5d 100644 --- a/tests/PathOpsExtendedTest.cpp +++ b/tests/PathOpsExtendedTest.cpp @@ -320,21 +320,26 @@ int comparePaths(skiatest::Reporter* reporter, const char* filename, const SkPat static SkTDArray<SkPathOp> gTestOp; -static void showPathOpPath(const char* testName, const SkPath& one, const SkPath& two, - const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath& scaledTwo, - const SkPathOp shapeOp, const SkMatrix& scale) { - SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); +static void dumpPathOpFunction(const char* testName, const SkPath& a, const SkPath& b, + const SkPathOp shapeOp) { if (!testName) { testName = "xOp"; } SkDebugf("static void %s_%s(skiatest::Reporter* reporter, const char* filename) {\n", testName, opSuffixes[shapeOp]); - *gTestOp.append() = shapeOp; SkDebugf(" SkPath path, pathB;\n"); SkPathOpsDebug::ShowOnePath(a, "path", false); SkPathOpsDebug::ShowOnePath(b, "pathB", false); SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[shapeOp]); SkDebugf("}\n"); +} + +static void showPathOpPath(const char* testName, const SkPath& one, const SkPath& two, + const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath& scaledTwo, + const SkPathOp shapeOp, const SkMatrix& scale) { + SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); + *gTestOp.append() = shapeOp; + dumpPathOpFunction(testName, a, b, shapeOp); drawAsciiPaths(scaledOne, scaledTwo, true); } @@ -344,11 +349,15 @@ static int comparePaths(skiatest::Reporter* reporter, const char* testName, cons const SkPath& scaledOne, const SkPath& two, const SkPath& scaledTwo, SkBitmap& bitmap, const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const SkMatrix& scale, ExpectMatch expectMatch) { + if (ExpectMatch::kFlaky == expectMatch) { + return 0; // fuzz data may cause asserts in region generating code, so don't try + } int errors2x2; const int MAX_ERRORS = 8; (void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2); if (ExpectMatch::kNo == expectMatch) { if (errors2x2 < MAX_ERRORS) { + SkDebugf("%s failing test %s now succeeds\n", __FUNCTION__, testName); REPORTER_ASSERT(reporter, 0); } return 0; @@ -505,6 +514,11 @@ bool testSimplifyCheck(skiatest::Reporter* reporter, const SkPath& path, const c ExpectSuccess::kYes : ExpectSuccess::kNo, SkipAssert::kNo, ExpectMatch::kNo); } +bool testSimplifyTry(skiatest::Reporter* reporter, const SkPath& path, const char* filename) { + return inner_simplify(reporter, path, filename, ExpectSuccess::kYes, SkipAssert::kNo, + ExpectMatch::kNo); +} + #if DEBUG_SHOW_TEST_NAME static void showName(const SkPath& a, const SkPath& b, const SkPathOp shapeOp) { SkDebugf("\n"); @@ -525,18 +539,23 @@ static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP SkDEBUGPARAMS(testName))) { if (ExpectSuccess::kYes == expectSuccess) { SkDebugf("%s %s did not expect failure\n", __FUNCTION__, testName); + dumpPathOpFunction(testName, a, b, shapeOp); REPORTER_ASSERT(reporter, 0); } return false; } else { if (ExpectSuccess::kNo == expectSuccess) { SkDebugf("%s %s unexpected success\n", __FUNCTION__, testName); + dumpPathOpFunction(testName, a, b, shapeOp); REPORTER_ASSERT(reporter, 0); } } if (!reporter->verbose()) { return true; } + if (ExpectMatch::kFlaky == expectMatch) { + return true; // fuzzy data may assert in region construction: see bug.skia.org/6129 + } SkPath pathOut, scaledPathOut; SkRegion rgnA, rgnB, openClip, rgnOut; openClip.setRect(-16000, -16000, 16000, 16000); @@ -579,29 +598,18 @@ bool testPathOpCheck(skiatest::Reporter* reporter, const SkPath& a, const SkPath ExpectSuccess::kYes : ExpectSuccess::kNo, SkipAssert::kNo, ExpectMatch::kNo); } +bool testPathOpTry(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, + const SkPathOp shapeOp, const char* testName) { + return innerPathOp(reporter, a, b, shapeOp, testName, + ExpectSuccess::kYes, SkipAssert::kNo, ExpectMatch::kNo); +} + bool testPathOpFuzz(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const char* testName) { return innerPathOp(reporter, a, b, shapeOp, testName, ExpectSuccess::kFlaky, SkipAssert::kYes, ExpectMatch::kFlaky); } -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); -#endif - SkPath orig; - orig.lineTo(54, 43); - SkPath out = orig; - if (Op(a, b, shapeOp, &out) ) { - SkDebugf("%s test is expected to fail\n", __FUNCTION__); - REPORTER_ASSERT(reporter, 0); - return false; - } - SkASSERT(out == orig); - return true; -} - SK_DECLARE_STATIC_MUTEX(gMutex); void initializeTests(skiatest::Reporter* reporter, const char* test) { |