OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
| 7 |
8 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
9 #include "SkParsePath.h" | 10 #include "SkParsePath.h" |
10 | 11 |
11 static void test_to_from(skiatest::Reporter* reporter, const SkPath& path) { | 12 static void test_to_from(skiatest::Reporter* reporter, const SkPath& path) { |
12 SkString str, str2; | 13 SkString str, str2; |
13 SkParsePath::ToSVGString(path, &str); | 14 SkParsePath::ToSVGString(path, &str); |
14 | 15 |
15 SkPath path2; | 16 SkPath path2; |
16 bool success = SkParsePath::FromSVGString(str.c_str(), &path2); | 17 bool success = SkParsePath::FromSVGString(str.c_str(), &path2); |
17 REPORTER_ASSERT(reporter, success); | 18 REPORTER_ASSERT(reporter, success); |
18 | 19 |
(...skipping 12 matching lines...) Expand all Loading... |
31 const char* fStr; | 32 const char* fStr; |
32 const SkRect fBounds; | 33 const SkRect fBounds; |
33 } gRec[] = { | 34 } gRec[] = { |
34 { "", { 0, 0, 0, 0 } }, | 35 { "", { 0, 0, 0, 0 } }, |
35 { "M0,0L10,10", { 0, 0, SkIntToScalar(10), SkIntToScalar(10) } }, | 36 { "M0,0L10,10", { 0, 0, SkIntToScalar(10), SkIntToScalar(10) } }, |
36 { "M-5.5,-0.5 Q 0 0 6,6.50", | 37 { "M-5.5,-0.5 Q 0 0 6,6.50", |
37 { -5.5f, -0.5f, | 38 { -5.5f, -0.5f, |
38 6, 6.5f } } | 39 6, 6.5f } } |
39 }; | 40 }; |
40 | 41 |
41 static void TestParsePath(skiatest::Reporter* reporter) { | 42 DEF_TEST(ParsePath, reporter) { |
42 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { | 43 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { |
43 SkPath path; | 44 SkPath path; |
44 bool success = SkParsePath::FromSVGString(gRec[i].fStr, &path); | 45 bool success = SkParsePath::FromSVGString(gRec[i].fStr, &path); |
45 REPORTER_ASSERT(reporter, success); | 46 REPORTER_ASSERT(reporter, success); |
46 const SkRect& expectedBounds = gRec[i].fBounds; | 47 const SkRect& expectedBounds = gRec[i].fBounds; |
47 const SkRect& pathBounds = path.getBounds(); | 48 const SkRect& pathBounds = path.getBounds(); |
48 REPORTER_ASSERT(reporter, expectedBounds == pathBounds); | 49 REPORTER_ASSERT(reporter, expectedBounds == pathBounds); |
49 | 50 |
50 test_to_from(reporter, path); | 51 test_to_from(reporter, path); |
51 } | 52 } |
52 | 53 |
53 SkRect r; | 54 SkRect r; |
54 r.set(0, 0, 10, 10.5f); | 55 r.set(0, 0, 10, 10.5f); |
55 SkPath p; | 56 SkPath p; |
56 p.addRect(r); | 57 p.addRect(r); |
57 test_to_from(reporter, p); | 58 test_to_from(reporter, p); |
58 p.addOval(r); | 59 p.addOval(r); |
59 test_to_from(reporter, p); | 60 test_to_from(reporter, p); |
60 p.addRoundRect(r, 4, 4.5f); | 61 p.addRoundRect(r, 4, 4.5f); |
61 test_to_from(reporter, p); | 62 test_to_from(reporter, p); |
62 } | 63 } |
63 | |
64 #include "TestClassDef.h" | |
65 DEFINE_TESTCLASS("ParsePath", ParsePathClass, TestParsePath) | |
OLD | NEW |