OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "CrashHandler.h" | 8 #include "CrashHandler.h" |
9 // #include "OverwriteLine.h" | 9 // #include "OverwriteLine.h" |
10 #include "Resources.h" | 10 #include "Resources.h" |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 static void writePict(const SkBitmap& bitmap, const char* outDir, const char* pn
gName) { | 436 static void writePict(const SkBitmap& bitmap, const char* outDir, const char* pn
gName) { |
437 SkString outFile = get_sum_path(outDir); | 437 SkString outFile = get_sum_path(outDir); |
438 outFile.appendf("%s%s", PATH_SLASH, pngName); | 438 outFile.appendf("%s%s", PATH_SLASH, pngName); |
439 if (!SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder::kPN
G_Type, 100)) { | 439 if (!SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder::kPN
G_Type, 100)) { |
440 SkDebugf("unable to encode gr %s (width=%d height=%d)\n", pngName, | 440 SkDebugf("unable to encode gr %s (width=%d height=%d)\n", pngName, |
441 bitmap.width(), bitmap.height()); | 441 bitmap.width(), bitmap.height()); |
442 } | 442 } |
443 } | 443 } |
444 | 444 |
445 void TestResult::testOne() { | 445 void TestResult::testOne() { |
446 SkPicture* pic = NULL; | 446 SkPicture* pic = nullptr; |
447 { | 447 { |
448 #if DEBUG_SHOW_TEST_NAME | 448 #if DEBUG_SHOW_TEST_NAME |
449 if (fTestStep == kCompareBits) { | 449 if (fTestStep == kCompareBits) { |
450 SkString testName(fFilename); | 450 SkString testName(fFilename); |
451 const char http[] = "http"; | 451 const char http[] = "http"; |
452 if (testName.startsWith(http)) { | 452 if (testName.startsWith(http)) { |
453 testName.remove(0, sizeof(http) - 1); | 453 testName.remove(0, sizeof(http) - 1); |
454 } | 454 } |
455 while (testName.startsWith("_")) { | 455 while (testName.startsWith("_")) { |
456 testName.remove(0, 1); | 456 testName.remove(0, 1); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 526 |
527 DEFINE_string2(match, m, "PathOpsSkpClipThreaded", | 527 DEFINE_string2(match, m, "PathOpsSkpClipThreaded", |
528 "[~][^]substring[$] [...] of test name to run.\n" | 528 "[~][^]substring[$] [...] of test name to run.\n" |
529 "Multiple matches may be separated by spaces.\n" | 529 "Multiple matches may be separated by spaces.\n" |
530 "~ causes a matching test to always be skipped\n" | 530 "~ causes a matching test to always be skipped\n" |
531 "^ requires the start of the test to match\n" | 531 "^ requires the start of the test to match\n" |
532 "$ requires the end of the test to match\n" | 532 "$ requires the end of the test to match\n" |
533 "^ and $ requires an exact match\n" | 533 "^ and $ requires an exact match\n" |
534 "If a test does not match any list entry,\n" | 534 "If a test does not match any list entry,\n" |
535 "it is skipped unless some list entry starts with ~"); | 535 "it is skipped unless some list entry starts with ~"); |
536 DEFINE_string2(dir, d, NULL, "range of directories (e.g., 1-100)"); | 536 DEFINE_string2(dir, d, nullptr, "range of directories (e.g., 1-100)"); |
537 DEFINE_string2(skp, s, NULL, "skp to test"); | 537 DEFINE_string2(skp, s, nullptr, "skp to test"); |
538 DEFINE_bool2(single, z, false, "run tests on a single thread internally."); | 538 DEFINE_bool2(single, z, false, "run tests on a single thread internally."); |
539 DEFINE_int32(testIndex, 0, "override local test index (PathOpsSkpClipOneOff only
)."); | 539 DEFINE_int32(testIndex, 0, "override local test index (PathOpsSkpClipOneOff only
)."); |
540 DEFINE_bool2(verbose, v, false, "enable verbose output."); | 540 DEFINE_bool2(verbose, v, false, "enable verbose output."); |
541 | 541 |
542 static bool verbose() { | 542 static bool verbose() { |
543 return FLAGS_verbose; | 543 return FLAGS_verbose; |
544 } | 544 } |
545 | 545 |
546 class Dirs { | 546 class Dirs { |
547 public: | 547 public: |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 class Filenames { | 607 class Filenames { |
608 public: | 608 public: |
609 Filenames() | 609 Filenames() |
610 : fIndex(-1) { | 610 : fIndex(-1) { |
611 } | 611 } |
612 | 612 |
613 const char* next() { | 613 const char* next() { |
614 while (fNames && ++fIndex < fNames->count()) { | 614 while (fNames && ++fIndex < fNames->count()) { |
615 return (*fNames)[fIndex]; | 615 return (*fNames)[fIndex]; |
616 } | 616 } |
617 return NULL; | 617 return nullptr; |
618 } | 618 } |
619 | 619 |
620 void set(const SkCommandLineFlags::StringArray& names) { | 620 void set(const SkCommandLineFlags::StringArray& names) { |
621 fNames = &names; | 621 fNames = &names; |
622 } | 622 } |
623 | 623 |
624 private: | 624 private: |
625 int fIndex; | 625 int fIndex; |
626 const SkCommandLineFlags::StringArray* fNames; | 626 const SkCommandLineFlags::StringArray* fNames; |
627 } gNames; | 627 } gNames; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 } | 698 } |
699 } | 699 } |
700 | 700 |
701 bool Less(const SortByName& a, const SortByName& b); | 701 bool Less(const SortByName& a, const SortByName& b); |
702 bool Less(const SortByName& a, const SortByName& b) { | 702 bool Less(const SortByName& a, const SortByName& b) { |
703 return a < b; | 703 return a < b; |
704 } | 704 } |
705 | 705 |
706 static bool doOneDir(TestState* state, bool threaded) { | 706 static bool doOneDir(TestState* state, bool threaded) { |
707 int dirNo = state->fResult.fDirNo; | 707 int dirNo = state->fResult.fDirNo; |
708 SkString dirName = get_in_path(dirNo, NULL); | 708 SkString dirName = get_in_path(dirNo, nullptr); |
709 if (!dirName.size()) { | 709 if (!dirName.size()) { |
710 return false; | 710 return false; |
711 } | 711 } |
712 SkTDArray<TestResult> tests[1]; | 712 SkTDArray<TestResult> tests[1]; |
713 SkTDArray<SortByName*> sorted[1]; | 713 SkTDArray<SortByName*> sorted[1]; |
714 if (!buildTestDir(dirNo, dirNo, tests, sorted)) { | 714 if (!buildTestDir(dirNo, dirNo, tests, sorted)) { |
715 return false; | 715 return false; |
716 } | 716 } |
717 SkOSFile::Iter iter(dirName.c_str(), "skp"); | 717 SkOSFile::Iter iter(dirName.c_str(), "skp"); |
718 SkString filename; | 718 SkString filename; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 int dirCount = lastDirNo - firstDirNo + 1; | 905 int dirCount = lastDirNo - firstDirNo + 1; |
906 SkAutoTDeleteArray<SkTDArray<TestResult> > tests(new SkTDArray<TestResult>[d
irCount]); | 906 SkAutoTDeleteArray<SkTDArray<TestResult> > tests(new SkTDArray<TestResult>[d
irCount]); |
907 SkAutoTDeleteArray<SkTDArray<SortByName*> > sorted(new SkTDArray<SortByName*
>[dirCount]); | 907 SkAutoTDeleteArray<SkTDArray<SortByName*> > sorted(new SkTDArray<SortByName*
>[dirCount]); |
908 if (!buildTests(tests.get(), sorted.get())) { | 908 if (!buildTests(tests.get(), sorted.get())) { |
909 return; | 909 return; |
910 } | 910 } |
911 TestRunner testRunner; | 911 TestRunner testRunner; |
912 int dirNo; | 912 int dirNo; |
913 gDirs.reset(); | 913 gDirs.reset(); |
914 while ((dirNo = gDirs.next()) > 0) { | 914 while ((dirNo = gDirs.next()) > 0) { |
915 SkString dirName = get_in_path(dirNo, NULL); | 915 SkString dirName = get_in_path(dirNo, nullptr); |
916 if (!dirName.size()) { | 916 if (!dirName.size()) { |
917 continue; | 917 continue; |
918 } | 918 } |
919 SkOSFile::Iter iter(dirName.c_str(), "skp"); | 919 SkOSFile::Iter iter(dirName.c_str(), "skp"); |
920 SkString filename; | 920 SkString filename; |
921 while (iter.next(&filename)) { | 921 while (iter.next(&filename)) { |
922 for (size_t index = 0; index < skipOverCount; ++index) { | 922 for (size_t index = 0; index < skipOverCount; ++index) { |
923 if (skipOver[index].directory == dirNo | 923 if (skipOver[index].directory == dirNo |
924 && strcmp(filename.c_str(), skipOver[index].filename) ==
0) { | 924 && strcmp(filename.c_str(), skipOver[index].filename) ==
0) { |
925 goto checkEarlyExit; | 925 goto checkEarlyExit; |
(...skipping 10 matching lines...) Expand all Loading... |
936 &testSkpClip, dirNo, filename.c_str(), &testRunner); | 936 &testSkpClip, dirNo, filename.c_str(), &testRunner); |
937 } | 937 } |
938 } | 938 } |
939 checkEarlyExit: | 939 checkEarlyExit: |
940 ; | 940 ; |
941 } | 941 } |
942 | 942 |
943 } | 943 } |
944 testRunner.render(); | 944 testRunner.render(); |
945 SkAutoTDeleteArray<SkTDArray<TestResult> > results(new SkTDArray<TestResult>
[dirCount]); | 945 SkAutoTDeleteArray<SkTDArray<TestResult> > results(new SkTDArray<TestResult>
[dirCount]); |
946 if (!buildTests(results.get(), NULL)) { | 946 if (!buildTests(results.get(), nullptr)) { |
947 return; | 947 return; |
948 } | 948 } |
949 SkTDArray<TestResult> allResults; | 949 SkTDArray<TestResult> allResults; |
950 for (int dirNo = firstDirNo; dirNo <= lastDirNo; ++dirNo) { | 950 for (int dirNo = firstDirNo; dirNo <= lastDirNo; ++dirNo) { |
951 SkTDArray<TestResult>& array = results.get()[dirNo - firstDirNo]; | 951 SkTDArray<TestResult>& array = results.get()[dirNo - firstDirNo]; |
952 allResults.append(array.count(), array.begin()); | 952 allResults.append(array.count(), array.begin()); |
953 } | 953 } |
954 int allCount = allResults.count(); | 954 int allCount = allResults.count(); |
955 SkTDArray<SortByPixel*> pixels; | 955 SkTDArray<SortByPixel*> pixels; |
956 SkTDArray<SortByTime*> times; | 956 SkTDArray<SortByTime*> times; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 | 1035 |
1036 class Iter { | 1036 class Iter { |
1037 public: | 1037 public: |
1038 Iter() { this->reset(); } | 1038 Iter() { this->reset(); } |
1039 void reset() { fReg = TestRegistry::Head(); } | 1039 void reset() { fReg = TestRegistry::Head(); } |
1040 | 1040 |
1041 Test* next() { | 1041 Test* next() { |
1042 if (fReg) { | 1042 if (fReg) { |
1043 TestRegistry::Factory fact = fReg->factory(); | 1043 TestRegistry::Factory fact = fReg->factory(); |
1044 fReg = fReg->next(); | 1044 fReg = fReg->next(); |
1045 Test* test = fact(NULL); | 1045 Test* test = fact(nullptr); |
1046 return test; | 1046 return test; |
1047 } | 1047 } |
1048 return NULL; | 1048 return nullptr; |
1049 } | 1049 } |
1050 | 1050 |
1051 private: | 1051 private: |
1052 const TestRegistry* fReg; | 1052 const TestRegistry* fReg; |
1053 }; | 1053 }; |
1054 | 1054 |
1055 int tool_main(int argc, char** argv); | 1055 int tool_main(int argc, char** argv); |
1056 int tool_main(int argc, char** argv) { | 1056 int tool_main(int argc, char** argv) { |
1057 SetupCrashHandler(); | 1057 SetupCrashHandler(); |
1058 SkCommandLineFlags::SetUsage(""); | 1058 SkCommandLineFlags::SetUsage(""); |
(...skipping 30 matching lines...) Expand all Loading... |
1089 header.append(" SK_DEBUG"); | 1089 header.append(" SK_DEBUG"); |
1090 #else | 1090 #else |
1091 header.append(" SK_RELEASE"); | 1091 header.append(" SK_RELEASE"); |
1092 #endif | 1092 #endif |
1093 if (FLAGS_verbose) { | 1093 if (FLAGS_verbose) { |
1094 header.appendf("\n"); | 1094 header.appendf("\n"); |
1095 } | 1095 } |
1096 SkDebugf("%s", header.c_str()); | 1096 SkDebugf("%s", header.c_str()); |
1097 Iter iter; | 1097 Iter iter; |
1098 Test* test; | 1098 Test* test; |
1099 while ((test = iter.next()) != NULL) { | 1099 while ((test = iter.next()) != nullptr) { |
1100 SkAutoTDelete<Test> owned(test); | 1100 SkAutoTDelete<Test> owned(test); |
1101 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) { | 1101 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) { |
1102 test->run(); | 1102 test->run(); |
1103 } | 1103 } |
1104 } | 1104 } |
1105 SkGraphics::Term(); | 1105 SkGraphics::Term(); |
1106 return 0; | 1106 return 0; |
1107 } | 1107 } |
1108 | 1108 |
1109 #if !defined(SK_BUILD_FOR_IOS) | 1109 #if !defined(SK_BUILD_FOR_IOS) |
1110 int main(int argc, char * const argv[]) { | 1110 int main(int argc, char * const argv[]) { |
1111 return tool_main(argc, (char**) argv); | 1111 return tool_main(argc, (char**) argv); |
1112 } | 1112 } |
1113 #endif | 1113 #endif |
OLD | NEW |