diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-03-07 03:39:23 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-03-07 03:39:23 +0000 |
commit | 5e5adfd12cc2cb194db971708cd7f34ff47e10b4 (patch) | |
tree | 4a516106bdc5844e275d6d2bcd03dfea80936828 /tests/PathMeasureTest.cpp | |
parent | 62533ed6bb490e9abf5d02686d897a93c5e85d51 (diff) |
migrate more legacy unittests into tests/
SkParse yet to be cleaned up
git-svn-id: http://skia.googlecode.com/svn/trunk@113 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/PathMeasureTest.cpp')
-rw-r--r-- | tests/PathMeasureTest.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/PathMeasureTest.cpp b/tests/PathMeasureTest.cpp new file mode 100644 index 0000000000..de18764481 --- /dev/null +++ b/tests/PathMeasureTest.cpp @@ -0,0 +1,42 @@ +#include "Test.h" +#include "SkPathMeasure.h" + +static void TestPathMeasure(skiatest::Reporter* reporter) { + SkPath path; + + path.moveTo(0, 0); + path.lineTo(SK_Scalar1, 0); + path.lineTo(SK_Scalar1, SK_Scalar1); + path.lineTo(0, SK_Scalar1); + + SkPathMeasure meas(path, true); + SkScalar length = meas.getLength(); + SkASSERT(length == SK_Scalar1*4); + + path.reset(); + path.moveTo(0, 0); + path.lineTo(SK_Scalar1*3, SK_Scalar1*4); + meas.setPath(&path, false); + length = meas.getLength(); + REPORTER_ASSERT(reporter, length == SK_Scalar1*5); + + path.reset(); + path.addCircle(0, 0, SK_Scalar1); + meas.setPath(&path, true); + length = meas.getLength(); +// SkDebugf("circle arc-length = %g\n", length); + + for (int i = 0; i < 8; i++) { + SkScalar d = length * i / 8; + SkPoint p; + SkVector v; + meas.getPosTan(d, &p, &v); +#if 0 + SkDebugf("circle arc-length=%g, pos[%g %g] tan[%g %g]\n", + d, p.fX, p.fY, v.fX, v.fY); +#endif + } +} + +#include "TestClassDef.h" +DEFINE_TESTCLASS("PathMeasure", PathMeasureTestClass, TestPathMeasure) |