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