Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: tests/ParsePathTest.cpp

Issue 885103002: fix parsing SVG strings to paths with comma delimiters (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/utils/SkParsePath.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * 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
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkParsePath.h" 8 #include "SkParsePath.h"
9 #include "Test.h" 9 #include "Test.h"
10 10
(...skipping 13 matching lines...) Expand all
24 if (path != path2) { 24 if (path != path2) {
25 SkDebugf("str1=%s\nstr2=%s\n", str.c_str(), str2.c_str()); 25 SkDebugf("str1=%s\nstr2=%s\n", str.c_str(), str2.c_str());
26 } 26 }
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 { "M1,1 l-2.58-2.828-3.82-0.113, 1.9-3.3223-1.08-3.6702, 3.75,0.7744,3.16-2. 1551,"
35 "0.42,3.8008,3.02,2.3384-3.48,1.574-1.29,3.601z",
36 { -5.39999962f, -10.3142f, 5.77000046f, 1.f } },
34 { "", { 0, 0, 0, 0 } }, 37 { "", { 0, 0, 0, 0 } },
35 { "M0,0L10,10", { 0, 0, SkIntToScalar(10), SkIntToScalar(10) } }, 38 { "M0,0L10,10", { 0, 0, SkIntToScalar(10), SkIntToScalar(10) } },
36 { "M-5.5,-0.5 Q 0 0 6,6.50", 39 { "M-5.5,-0.5 Q 0 0 6,6.50",
37 { -5.5f, -0.5f, 40 { -5.5f, -0.5f,
38 6, 6.5f } } 41 6, 6.5f } }
39 }; 42 };
40 43
41 DEF_TEST(ParsePath, reporter) { 44 DEF_TEST(ParsePath, reporter) {
42 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { 45 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
43 SkPath path; 46 SkPath path;
44 bool success = SkParsePath::FromSVGString(gRec[i].fStr, &path); 47 bool success = SkParsePath::FromSVGString(gRec[i].fStr, &path);
45 REPORTER_ASSERT(reporter, success); 48 REPORTER_ASSERT(reporter, success);
46 const SkRect& expectedBounds = gRec[i].fBounds; 49 const SkRect& expectedBounds = gRec[i].fBounds;
47 const SkRect& pathBounds = path.getBounds(); 50 const SkRect& pathBounds = path.getBounds();
48 REPORTER_ASSERT(reporter, expectedBounds == pathBounds); 51 REPORTER_ASSERT(reporter, expectedBounds == pathBounds);
49 52
50 test_to_from(reporter, path); 53 test_to_from(reporter, path);
51 } 54 }
52 55
53 SkRect r; 56 SkRect r;
54 r.set(0, 0, 10, 10.5f); 57 r.set(0, 0, 10, 10.5f);
55 SkPath p; 58 SkPath p;
56 p.addRect(r); 59 p.addRect(r);
57 test_to_from(reporter, p); 60 test_to_from(reporter, p);
58 p.addOval(r); 61 p.addOval(r);
59 test_to_from(reporter, p); 62 test_to_from(reporter, p);
60 p.addRoundRect(r, 4, 4.5f); 63 p.addRoundRect(r, 4, 4.5f);
61 test_to_from(reporter, p); 64 test_to_from(reporter, p);
62 } 65 }
OLDNEW
« no previous file with comments | « src/utils/SkParsePath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698