Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 /* | 8 /* |
| 9 * Code for the "gm" (Golden Master) rendering comparison tool. | 9 * Code for the "gm" (Golden Master) rendering comparison tool. |
| 10 * | 10 * |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 291 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
| 292 ErrorType type = static_cast<ErrorType>(typeInt); | 292 ErrorType type = static_cast<ErrorType>(typeInt); |
| 293 if (!fIgnorableErrorCombination.includes(type)) { | 293 if (!fIgnorableErrorCombination.includes(type)) { |
| 294 significantErrors += fFailedTests[type].count(); | 294 significantErrors += fFailedTests[type].count(); |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 return significantErrors; | 297 return significantErrors; |
| 298 } | 298 } |
| 299 | 299 |
| 300 /** | 300 /** |
| 301 * Display the summary of results with this ErrorType. | |
| 302 */ | |
| 303 void DisplayResultTypeSummary(ErrorType type) { | |
| 304 SkString line; | |
| 305 if (fIgnorableErrorCombination.includes(type)) { | |
| 306 line.append("[ ] "); | |
| 307 } else { | |
| 308 line.append("[*] "); | |
| 309 } | |
| 310 | |
| 311 SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type]; | |
| 312 int count = failedTestsOfThisType->count(); | |
| 313 line.appendf("%d %s:", count, getErrorTypeName(type)); | |
| 314 for (int i = 0; i < count; ++i) { | |
| 315 line.append(" "); | |
| 316 line.append((*failedTestsOfThisType)[i]); | |
| 317 } | |
| 318 gm_fprintf(stdout, "%s\n", line.c_str()); | |
| 319 } | |
| 320 | |
| 321 /** | |
| 301 * List contents of fFailedTests to stdout. | 322 * List contents of fFailedTests to stdout. |
| 302 */ | 323 */ |
| 303 void ListErrors() { | 324 void ListErrors() { |
| 304 // First, print a single summary line. | 325 // First, print a single summary line. |
| 305 SkString summary; | 326 SkString summary; |
| 306 summary.appendf("Ran %d tests:", fTestsRun); | 327 summary.appendf("Ran %d tests:", fTestsRun); |
| 307 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 328 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
| 308 ErrorType type = static_cast<ErrorType>(typeInt); | 329 ErrorType type = static_cast<ErrorType>(typeInt); |
| 309 summary.appendf(" %s=%d", getErrorTypeName(type), fFailedTests[type] .count()); | 330 summary.appendf(" %s=%d", getErrorTypeName(type), fFailedTests[type] .count()); |
| 310 } | 331 } |
| 311 gm_fprintf(stdout, "%s\n", summary.c_str()); | 332 gm_fprintf(stdout, "%s\n", summary.c_str()); |
| 312 | 333 |
| 313 // Now, for each failure type, list the tests that failed that way. | 334 // Now, for each failure type, list the tests that failed that way. |
| 314 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 335 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
| 315 SkString line; | 336 this->DisplayResultTypeSummary(static_cast<ErrorType>(typeInt)); |
|
epoger
2013/04/09 20:08:26
patchset 1 extracts some logic into its own method
| |
| 316 ErrorType type = static_cast<ErrorType>(typeInt); | |
| 317 if (fIgnorableErrorCombination.includes(type)) { | |
| 318 line.append("[ ] "); | |
| 319 } else { | |
| 320 line.append("[*] "); | |
| 321 } | |
| 322 | |
| 323 SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type]; | |
| 324 int count = failedTestsOfThisType->count(); | |
| 325 line.appendf("%d %s:", count, getErrorTypeName(type)); | |
| 326 for (int i = 0; i < count; ++i) { | |
| 327 line.append(" "); | |
| 328 line.append((*failedTestsOfThisType)[i]); | |
| 329 } | |
| 330 gm_fprintf(stdout, "%s\n", line.c_str()); | |
| 331 } | 337 } |
| 332 gm_fprintf(stdout, "(results marked with [*] will cause nonzero return v alue)\n"); | 338 gm_fprintf(stdout, "(results marked with [*] will cause nonzero return v alue)\n"); |
| 333 } | 339 } |
| 334 | 340 |
| 335 static bool write_document(const SkString& path, | 341 static bool write_document(const SkString& path, |
| 336 const SkDynamicMemoryWStream& document) { | 342 const SkDynamicMemoryWStream& document) { |
| 337 SkFILEWStream stream(path.c_str()); | 343 SkFILEWStream stream(path.c_str()); |
| 338 SkAutoDataUnref data(document.copyToData()); | 344 SkAutoDataUnref data(document.copyToData()); |
| 339 return stream.writeData(data.get()); | 345 return stream.writeData(data.get()); |
| 340 } | 346 } |
| (...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1816 if (FLAGS_forceBWtext) { | 1822 if (FLAGS_forceBWtext) { |
| 1817 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 1823 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 1818 } | 1824 } |
| 1819 } | 1825 } |
| 1820 | 1826 |
| 1821 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1827 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 1822 int main(int argc, char * const argv[]) { | 1828 int main(int argc, char * const argv[]) { |
| 1823 return tool_main(argc, (char**) argv); | 1829 return tool_main(argc, (char**) argv); |
| 1824 } | 1830 } |
| 1825 #endif | 1831 #endif |
| OLD | NEW |