diff options
| author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-03-02 05:36:20 +0000 |
|---|---|---|
| committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-03-02 05:36:20 +0000 |
| commit | 3abec1d7c38e9bd786fc6057f9608f3eeec98c86 (patch) | |
| tree | cd78249fa6641d26203307aae74ef532907950cd /tests/PathTest.cpp | |
| parent | a396a16d53c1355c59f9f1f739618b47dc346ee4 (diff) | |
add initial unittests for Path
add operator== for paths
still need to implement isRect!
git-svn-id: http://skia.googlecode.com/svn/trunk@99 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/PathTest.cpp')
| -rw-r--r-- | tests/PathTest.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp new file mode 100644 index 0000000000..383ad030c5 --- /dev/null +++ b/tests/PathTest.cpp @@ -0,0 +1,61 @@ +#include "Test.h" +#include "SkPath.h" + +static void TestPath(skiatest::Reporter* reporter) { + SkPath p, p2; + SkRect bounds, bounds2; + + REPORTER_ASSERT(reporter, p.isEmpty()); + REPORTER_ASSERT(reporter, p.getFillType() == SkPath::kWinding_FillType); + REPORTER_ASSERT(reporter, !p.isInverseFillType()); + REPORTER_ASSERT(reporter, p == p2); + REPORTER_ASSERT(reporter, !(p != p2)); + + // initialize bounds to not-empty + bounds.set(0, 0, SK_Scalar1, SK_Scalar1); + p.computeBounds(&bounds, SkPath::kFast_BoundsType); + REPORTER_ASSERT(reporter, bounds.isEmpty()); + + bounds.set(0, 0, SK_Scalar1, SK_Scalar1); + p.addRect(bounds); + bounds2.setEmpty(); + p.computeBounds(&bounds2, SkPath::kFast_BoundsType); + REPORTER_ASSERT(reporter, bounds == bounds2); + + REPORTER_ASSERT(reporter, p != p2); + REPORTER_ASSERT(reporter, !(p == p2)); + + // does getPoints return the right result + REPORTER_ASSERT(reporter, p.getPoints(NULL, 5) == 4); + SkPoint pts[4]; + int count = p.getPoints(pts, 4); + REPORTER_ASSERT(reporter, count == 4); + bounds2.set(pts, 4); + REPORTER_ASSERT(reporter, bounds == bounds2); + + bounds.offset(SK_Scalar1*3, SK_Scalar1*4); + p.offset(SK_Scalar1*3, SK_Scalar1*4); + p.computeBounds(&bounds2, SkPath::kFast_BoundsType); + REPORTER_ASSERT(reporter, bounds == bounds2); + +#if 0 // isRect needs to be implemented + REPORTER_ASSERT(reporter, p.isRect(NULL)); + bounds.setEmpty(); + REPORTER_ASSERT(reporter, p.isRect(&bounds2)); + REPORTER_ASSERT(reporter, bounds == bounds2); + + // now force p to not be a rect + bounds.set(0, 0, SK_Scalar1/2, SK_Scalar1/2); + p.addRect(bounds); + REPORTER_ASSERT(reporter, !p.isRect(NULL)); +#endif + + SkPoint pt; + + p.moveTo(SK_Scalar1, 0); + p.getLastPt(&pt); + REPORTER_ASSERT(reporter, pt.fX == SK_Scalar1); +} + +#include "TestClassDef.h" +DEFINE_TESTCLASS("Path", PathTestClass, TestPath) |
