aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathOpsExtendedTest.cpp
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@google.com>2017-01-18 11:00:57 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-20 17:35:30 +0000
commitd2eb581ebc8f8009e80cccccd74d5b341ef5bd5b (patch)
treeb7e839cf44743ce6d8119ad527ebaae5e2c1ea6d /tests/PathOpsExtendedTest.cpp
parentf833215420847565b4c9945aebdc2e7ae182937f (diff)
offset angle check edge in common
When curves cross, their intersection points may be nearby, but not exactly the same. Sort the angles formed by the crossing curves when all angles don't have the same origin. This sets up the framework to solve test case that currently fail (e.g., joel6) but does not fix all related test cases (e.g., joel9). All older existing test cases, including extended tests, pass. Rework the test framework to better report when tests expected to produce failing results now pass. Add new point and vector operations to support offset angles. TBR=reed@google.com BUG=skia:6041 Change-Id: I67c651ded0a25e99ad93d55d6a35109b3ee3698e Reviewed-on: https://skia-review.googlesource.com/6624 Commit-Queue: Cary Clark <caryclark@google.com> Reviewed-by: Cary Clark <caryclark@google.com>
Diffstat (limited to 'tests/PathOpsExtendedTest.cpp')
-rw-r--r--tests/PathOpsExtendedTest.cpp52
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) {