2
#include "SkParsePath.h"
4
static void test_to_from(skiatest::Reporter* reporter, const SkPath& path) {
6
SkParsePath::ToSVGString(path, &str);
9
bool success = SkParsePath::FromSVGString(str.c_str(), &path2);
10
REPORTER_ASSERT(reporter, success);
12
SkParsePath::ToSVGString(path2, &str2);
13
REPORTER_ASSERT(reporter, str == str2);
14
#if 0 // closed paths are not equal, the iter explicitly gives the closing
15
// edge, even if it is not in the path.
16
REPORTER_ASSERT(reporter, path == path2);
18
SkDebugf("str1=%s\nstr2=%s\n", str.c_str(), str2.c_str());
23
static void TestParsePath(skiatest::Reporter* reporter) {
28
{ "", { 0, 0, 0, 0 } },
29
{ "M0,0L10,10", { 0, 0, SkIntToScalar(10), SkIntToScalar(10) } },
30
{ "M-5.5,-0.5 Q 0 0 6,6.50",
31
{ SkFloatToScalar(-5.5f), SkFloatToScalar(-0.5f),
32
SkFloatToScalar(6), SkFloatToScalar(6.5f) } }
35
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
37
bool success = SkParsePath::FromSVGString(gRec[i].fStr, &path);
38
REPORTER_ASSERT(reporter, success);
39
const SkRect& expectedBounds = gRec[i].fBounds;
40
const SkRect& pathBounds = path.getBounds();
41
REPORTER_ASSERT(reporter, expectedBounds == pathBounds);
43
test_to_from(reporter, path);
47
r.set(0, 0, SkFloatToScalar(10), SkFloatToScalar(10.5));
50
test_to_from(reporter, p);
52
test_to_from(reporter, p);
53
p.addRoundRect(r, SkFloatToScalar(4), SkFloatToScalar(4.5));
54
test_to_from(reporter, p);
57
#include "TestClassDef.h"
58
DEFINE_TESTCLASS("ParsePath", ParsePathClass, TestParsePath)