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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGPathParserTest.cpp

Issue 1646543004: Refactor away SVGPathSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use namespace Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/svg/SVGPathParser.h" 5 #include "core/svg/SVGPathParser.h"
6 6
7 #include "core/svg/SVGPathStringBuilder.h" 7 #include "core/svg/SVGPathStringBuilder.h"
8 #include "core/svg/SVGPathStringSource.h" 8 #include "core/svg/SVGPathStringSource.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 namespace { 13 namespace {
14 14
15 bool parsePath(const char* input, String& output) 15 bool parsePath(const char* input, String& output)
16 { 16 {
17 String inputString(input); 17 String inputString(input);
18 SVGPathStringSource source(inputString); 18 SVGPathStringSource source(inputString);
19 SVGPathStringBuilder builder; 19 SVGPathStringBuilder builder;
20 SVGPathParser parser(&source, &builder); 20 bool hadError = SVGPathParser::parsePath(source, builder);
21 bool hadError = parser.parsePathDataFromSource();
22 output = builder.result(); 21 output = builder.result();
23 // Coerce a null result to empty. 22 // Coerce a null result to empty.
24 if (output.isNull()) 23 if (output.isNull())
25 output = emptyString(); 24 output = emptyString();
26 return hadError; 25 return hadError;
27 } 26 }
28 27
29 #define VALID(input, expected) \ 28 #define VALID(input, expected) \
30 { \ 29 { \
31 String output; \ 30 String output; \
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 138 }
140 139
141 #undef MALFORMED 140 #undef MALFORMED
142 #undef VALID 141 #undef VALID
143 142
144 SVGParsingError parsePathWithError(const char* input) 143 SVGParsingError parsePathWithError(const char* input)
145 { 144 {
146 String inputString(input); 145 String inputString(input);
147 SVGPathStringSource source(inputString); 146 SVGPathStringSource source(inputString);
148 SVGPathStringBuilder builder; 147 SVGPathStringBuilder builder;
149 SVGPathParser parser(&source, &builder); 148 SVGPathParser::parsePath(source, builder);
150 parser.parsePathDataFromSource();
151 return source.parseError(); 149 return source.parseError();
152 } 150 }
153 151
154 #define EXPECT_ERROR(input, expectedLocus, expectedError) \ 152 #define EXPECT_ERROR(input, expectedLocus, expectedError) \
155 { \ 153 { \
156 SVGParsingError error = parsePathWithError(input); \ 154 SVGParsingError error = parsePathWithError(input); \
157 EXPECT_EQ(expectedError, error.status()); \ 155 EXPECT_EQ(expectedError, error.status()); \
158 EXPECT_TRUE(error.hasLocus()); \ 156 EXPECT_TRUE(error.hasLocus()); \
159 EXPECT_EQ(expectedLocus, error.locus()); \ 157 EXPECT_EQ(expectedLocus, error.locus()); \
160 } 158 }
(...skipping 19 matching lines...) Expand all
180 EXPECT_ERROR("M0,0 A10,10 0 #,0 20,20", 14u, SVGParseStatus::ExpectedArcFlag ); 178 EXPECT_ERROR("M0,0 A10,10 0 #,0 20,20", 14u, SVGParseStatus::ExpectedArcFlag );
181 EXPECT_ERROR("M0,0 A10,10 0 0,# 20,20", 16u, SVGParseStatus::ExpectedArcFlag ); 179 EXPECT_ERROR("M0,0 A10,10 0 0,# 20,20", 16u, SVGParseStatus::ExpectedArcFlag );
182 EXPECT_ERROR("M0,0 A10,10 0 0,2 20,20", 16u, SVGParseStatus::ExpectedArcFlag ); 180 EXPECT_ERROR("M0,0 A10,10 0 0,2 20,20", 16u, SVGParseStatus::ExpectedArcFlag );
183 } 181 }
184 182
185 #undef EXPECT_ERROR 183 #undef EXPECT_ERROR
186 184
187 } // namespace 185 } // namespace
188 186
189 } // namespace blink 187 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGPathParser.cpp ('k') | third_party/WebKit/Source/core/svg/SVGPathSource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698