aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-09-21 12:29:05 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-09-21 12:29:05 +0000
commit10296ccb6a63c65b2e60733a929bf15d8bf94309 (patch)
tree74ffe5dad3e9a659488aa4ce58c248693190aa37 /tests
parent4fa6694c587b3830932429766c99d08c8dd9b723 (diff)
add segment types query to SkPath (i.e. does it have any quads)
git-svn-id: http://skia.googlecode.com/svn/trunk@2292 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/PathTest.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 4c0113e978..45e7d15457 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -438,6 +438,8 @@ static void test_isRect(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, fail ^ path1.isRect(0));
}
+#define kCurveSegmentMask (SkPath::kQuad_SegmentMask | SkPath::kCubic_SegmentMask)
+
void TestPath(skiatest::Reporter* reporter);
void TestPath(skiatest::Reporter* reporter) {
{
@@ -454,6 +456,7 @@ void TestPath(skiatest::Reporter* reporter) {
SkRect bounds, bounds2;
REPORTER_ASSERT(reporter, p.isEmpty());
+ REPORTER_ASSERT(reporter, 0 == p.getSegmentMasks());
REPORTER_ASSERT(reporter, p.isConvex());
REPORTER_ASSERT(reporter, p.getFillType() == SkPath::kWinding_FillType);
REPORTER_ASSERT(reporter, !p.isInverseFillType());
@@ -466,14 +469,20 @@ void TestPath(skiatest::Reporter* reporter) {
p.addRoundRect(bounds, SK_Scalar1, SK_Scalar1);
check_convex_bounds(reporter, p, bounds);
+ // we have quads or cubics
+ REPORTER_ASSERT(reporter, p.getSegmentMasks() & kCurveSegmentMask);
p.reset();
+ REPORTER_ASSERT(reporter, 0 == p.getSegmentMasks());
+
p.addOval(bounds);
check_convex_bounds(reporter, p, bounds);
p.reset();
p.addRect(bounds);
check_convex_bounds(reporter, p, bounds);
+ // we have only lines
+ REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == p.getSegmentMasks());
REPORTER_ASSERT(reporter, p != p2);
REPORTER_ASSERT(reporter, !(p == p2));
@@ -510,6 +519,17 @@ void TestPath(skiatest::Reporter* reporter) {
test_convexity(reporter);
test_convexity2(reporter);
test_close(reporter);
+
+ p.reset();
+ p.moveTo(0, 0);
+ p.quadTo(100, 100, 200, 200);
+ REPORTER_ASSERT(reporter, SkPath::kQuad_SegmentMask == p.getSegmentMasks());
+ p.cubicTo(100, 100, 200, 200, 300, 300);
+ REPORTER_ASSERT(reporter, kCurveSegmentMask == p.getSegmentMasks());
+ p.reset();
+ p.moveTo(0, 0);
+ p.cubicTo(100, 100, 200, 200, 300, 300);
+ REPORTER_ASSERT(reporter, SkPath::kCubic_SegmentMask == p.getSegmentMasks());
}
#include "TestClassDef.h"