Add isRect variant that returns path closure and direction.
Add path test to verify that when isRect() returns false,
output parameters are unchanged.
Review URL: https://codereview.appspot.com/6855074
git-svn-id: http://skia.googlecode.com/svn/trunk@6524 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index bd41e19..58f864d 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -1052,12 +1052,34 @@
path.close();
}
REPORTER_ASSERT(reporter, fail ^ path.isRect(0));
+ REPORTER_ASSERT(reporter, fail ^ path.isRect(NULL, NULL));
+
if (!fail) {
SkRect computed, expected;
expected.set(tests[testIndex], testLen[testIndex] / sizeof(SkPoint));
REPORTER_ASSERT(reporter, path.isRect(&computed));
REPORTER_ASSERT(reporter, expected == computed);
+
+ bool isClosed;
+ SkPath::Direction direction, cheapDirection;
+ REPORTER_ASSERT(reporter, path.cheapComputeDirection(&cheapDirection));
+ REPORTER_ASSERT(reporter, path.isRect(&isClosed, &direction));
+ REPORTER_ASSERT(reporter, isClosed == close);
+ REPORTER_ASSERT(reporter, direction == cheapDirection);
+ } else {
+ SkRect computed;
+ computed.set(123, 456, 789, 1011);
+ REPORTER_ASSERT(reporter, !path.isRect(&computed));
+ REPORTER_ASSERT(reporter, computed.fLeft == 123 && computed.fTop == 456);
+ REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom == 1011);
+
+ bool isClosed = (bool) -1;
+ SkPath::Direction direction = (SkPath::Direction) -1;
+ REPORTER_ASSERT(reporter, !path.isRect(&isClosed, &direction));
+ REPORTER_ASSERT(reporter, isClosed == (bool) -1);
+ REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1);
}
+
if (tests[testIndex] == lastPass) {
fail = true;
}