OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "gpu/config/gpu_test_expectations_parser.h" | 5 #include "gpu/config/gpu_test_expectations_parser.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 sizeof(kErrorMessage) / sizeof(kErrorMessage[0])); | 180 sizeof(kErrorMessage) / sizeof(kErrorMessage[0])); |
181 } | 181 } |
182 | 182 |
183 GPUTestExpectationsParser::~GPUTestExpectationsParser() { | 183 GPUTestExpectationsParser::~GPUTestExpectationsParser() { |
184 } | 184 } |
185 | 185 |
186 bool GPUTestExpectationsParser::LoadTestExpectations(const std::string& data) { | 186 bool GPUTestExpectationsParser::LoadTestExpectations(const std::string& data) { |
187 entries_.clear(); | 187 entries_.clear(); |
188 error_messages_.clear(); | 188 error_messages_.clear(); |
189 | 189 |
190 std::vector<std::string> lines = base::SplitString( | 190 std::vector<std::string> lines; |
191 data, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 191 base::SplitString(data, '\n', &lines); |
192 bool rt = true; | 192 bool rt = true; |
193 for (size_t i = 0; i < lines.size(); ++i) { | 193 for (size_t i = 0; i < lines.size(); ++i) { |
194 if (!ParseLine(lines[i], i + 1)) | 194 if (!ParseLine(lines[i], i + 1)) |
195 rt = false; | 195 rt = false; |
196 } | 196 } |
197 if (DetectConflictsBetweenEntries()) { | 197 if (DetectConflictsBetweenEntries()) { |
198 entries_.clear(); | 198 entries_.clear(); |
199 rt = false; | 199 rt = false; |
200 } | 200 } |
201 | 201 |
(...skipping 25 matching lines...) Expand all Loading... |
227 } | 227 } |
228 | 228 |
229 const std::vector<std::string>& | 229 const std::vector<std::string>& |
230 GPUTestExpectationsParser::GetErrorMessages() const { | 230 GPUTestExpectationsParser::GetErrorMessages() const { |
231 return error_messages_; | 231 return error_messages_; |
232 } | 232 } |
233 | 233 |
234 bool GPUTestExpectationsParser::ParseConfig( | 234 bool GPUTestExpectationsParser::ParseConfig( |
235 const std::string& config_data, GPUTestConfig* config) { | 235 const std::string& config_data, GPUTestConfig* config) { |
236 DCHECK(config); | 236 DCHECK(config); |
237 std::vector<std::string> tokens = base::SplitString( | 237 std::vector<std::string> tokens; |
238 config_data, base::kWhitespaceASCII, base::KEEP_WHITESPACE, | 238 base::SplitStringAlongWhitespace(config_data, &tokens); |
239 base::SPLIT_WANT_NONEMPTY); | |
240 | 239 |
241 for (size_t i = 0; i < tokens.size(); ++i) { | 240 for (size_t i = 0; i < tokens.size(); ++i) { |
242 Token token = ParseToken(tokens[i]); | 241 Token token = ParseToken(tokens[i]); |
243 switch (token) { | 242 switch (token) { |
244 case kConfigWinXP: | 243 case kConfigWinXP: |
245 case kConfigWinVista: | 244 case kConfigWinVista: |
246 case kConfigWin7: | 245 case kConfigWin7: |
247 case kConfigWin8: | 246 case kConfigWin8: |
248 case kConfigWin10: | 247 case kConfigWin10: |
249 case kConfigWin: | 248 case kConfigWin: |
(...skipping 28 matching lines...) Expand all Loading... |
278 break; | 277 break; |
279 default: | 278 default: |
280 return false; | 279 return false; |
281 } | 280 } |
282 } | 281 } |
283 return true; | 282 return true; |
284 } | 283 } |
285 | 284 |
286 bool GPUTestExpectationsParser::ParseLine( | 285 bool GPUTestExpectationsParser::ParseLine( |
287 const std::string& line_data, size_t line_number) { | 286 const std::string& line_data, size_t line_number) { |
288 std::vector<std::string> tokens = base::SplitString( | 287 std::vector<std::string> tokens; |
289 line_data, base::kWhitespaceASCII, base::KEEP_WHITESPACE, | 288 base::SplitStringAlongWhitespace(line_data, &tokens); |
290 base::SPLIT_WANT_NONEMPTY); | |
291 int32 stage = kLineParserBegin; | 289 int32 stage = kLineParserBegin; |
292 GPUTestExpectationEntry entry; | 290 GPUTestExpectationEntry entry; |
293 entry.line_number = line_number; | 291 entry.line_number = line_number; |
294 GPUTestConfig& config = entry.test_config; | 292 GPUTestConfig& config = entry.test_config; |
295 bool comments_encountered = false; | 293 bool comments_encountered = false; |
296 for (size_t i = 0; i < tokens.size() && !comments_encountered; ++i) { | 294 for (size_t i = 0; i < tokens.size() && !comments_encountered; ++i) { |
297 Token token = ParseToken(tokens[i]); | 295 Token token = ParseToken(tokens[i]); |
298 switch (token) { | 296 switch (token) { |
299 case kTokenComment: | 297 case kTokenComment: |
300 comments_encountered = true; | 298 comments_encountered = true; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 message.c_str())); | 538 message.c_str())); |
541 } | 539 } |
542 | 540 |
543 GPUTestExpectationsParser:: GPUTestExpectationEntry::GPUTestExpectationEntry() | 541 GPUTestExpectationsParser:: GPUTestExpectationEntry::GPUTestExpectationEntry() |
544 : test_expectation(0), | 542 : test_expectation(0), |
545 line_number(0) { | 543 line_number(0) { |
546 } | 544 } |
547 | 545 |
548 } // namespace gpu | 546 } // namespace gpu |
549 | 547 |
OLD | NEW |