skia2/tests/PathMeasureTest.cpp
reed@android.com 5e5adfd12c 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
2009-03-07 03:39:23 +00:00

43 lines
1.1 KiB
C++

#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)