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

Unified Diff: tests/PathTest.cpp

Issue 16950021: add rect-output parameter to isRect, allowing us to return the correct bounds even if a rectagular … (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 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
« include/core/SkPath.h ('K') | « src/core/SkStroke.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PathTest.cpp
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 0f59aebe88a2bd4107d5bd3cb998cac682338cb2..5f7a00ce7672217b03d4b5a14a189cf7bdfe2cd6 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -1230,8 +1230,7 @@ static void test_isRect(skiatest::Reporter* reporter) {
if (close) {
path.close();
}
- REPORTER_ASSERT(reporter, fail ^ path.isRect(0));
- REPORTER_ASSERT(reporter, fail ^ path.isRect(NULL, NULL));
+ REPORTER_ASSERT(reporter, fail ^ path.isRect(NULL));
if (!fail) {
SkRect computed, expected;
@@ -1242,7 +1241,7 @@ static void test_isRect(skiatest::Reporter* reporter) {
bool isClosed;
SkPath::Direction direction, cheapDirection;
REPORTER_ASSERT(reporter, path.cheapComputeDirection(&cheapDirection));
- REPORTER_ASSERT(reporter, path.isRect(&isClosed, &direction));
+ REPORTER_ASSERT(reporter, path.isRect(NULL, &isClosed, &direction));
REPORTER_ASSERT(reporter, isClosed == close);
REPORTER_ASSERT(reporter, direction == cheapDirection);
} else {
@@ -1254,7 +1253,7 @@ static void test_isRect(skiatest::Reporter* reporter) {
bool isClosed = (bool) -1;
SkPath::Direction direction = (SkPath::Direction) -1;
- REPORTER_ASSERT(reporter, !path.isRect(&isClosed, &direction));
+ REPORTER_ASSERT(reporter, !path.isRect(NULL, &isClosed, &direction));
REPORTER_ASSERT(reporter, isClosed == (bool) -1);
REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1);
}
@@ -1275,7 +1274,7 @@ static void test_isRect(skiatest::Reporter* reporter) {
}
path1.close();
path1.lineTo(1, 0);
- REPORTER_ASSERT(reporter, fail ^ path1.isRect(0));
+ REPORTER_ASSERT(reporter, fail ^ path1.isRect(NULL));
// fail, move in the middle
path1.reset();
@@ -1287,7 +1286,7 @@ static void test_isRect(skiatest::Reporter* reporter) {
path1.lineTo(r1[index].fX, r1[index].fY);
}
path1.close();
- REPORTER_ASSERT(reporter, fail ^ path1.isRect(0));
+ REPORTER_ASSERT(reporter, fail ^ path1.isRect(NULL));
// fail, move on the edge
path1.reset();
@@ -1296,7 +1295,7 @@ static void test_isRect(skiatest::Reporter* reporter) {
path1.lineTo(r1[index].fX, r1[index].fY);
}
path1.close();
- REPORTER_ASSERT(reporter, fail ^ path1.isRect(0));
+ REPORTER_ASSERT(reporter, fail ^ path1.isRect(NULL));
// fail, quad
path1.reset();
@@ -1308,7 +1307,7 @@ static void test_isRect(skiatest::Reporter* reporter) {
path1.lineTo(r1[index].fX, r1[index].fY);
}
path1.close();
- REPORTER_ASSERT(reporter, fail ^ path1.isRect(0));
+ REPORTER_ASSERT(reporter, fail ^ path1.isRect(NULL));
// fail, cubic
path1.reset();
@@ -1320,7 +1319,7 @@ static void test_isRect(skiatest::Reporter* reporter) {
path1.lineTo(r1[index].fX, r1[index].fY);
}
path1.close();
- REPORTER_ASSERT(reporter, fail ^ path1.isRect(0));
+ REPORTER_ASSERT(reporter, fail ^ path1.isRect(NULL));
}
static void test_isNestedRects(skiatest::Reporter* reporter) {
@@ -2403,6 +2402,19 @@ static void TestPath(skiatest::Reporter* reporter) {
p.addRect(bounds);
REPORTER_ASSERT(reporter, !p.isRect(NULL));
+ // test isRect for a trailing moveTo
+ {
+ SkRect r;
+ p.reset();
+ p.addRect(bounds);
+ REPORTER_ASSERT(reporter, p.isRect(&r));
+ REPORTER_ASSERT(reporter, r == bounds);
+ // add a moveTo outside of our bounds
+ p.moveTo(bounds.fLeft + 10, bounds.fBottom + 10);
+ REPORTER_ASSERT(reporter, p.isRect(&r));
+ REPORTER_ASSERT(reporter, r == bounds);
+ }
+
test_isLine(reporter);
test_isRect(reporter);
test_isNestedRects(reporter);
« include/core/SkPath.h ('K') | « src/core/SkStroke.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698