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" |
11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
13 #include "SkColor.h" | 13 #include "SkColor.h" |
14 #include "SkColorPriv.h" | 14 #include "SkColorPriv.h" |
15 #include "SkCommandLineFlags.h" | 15 #include "SkCommandLineFlags.h" |
16 #include "SkForceLinking.h" | 16 #include "SkForceLinking.h" |
17 #include "SkGraphics.h" | 17 #include "SkGraphics.h" |
18 #include "SkImageEncoder.h" | 18 #include "SkImageEncoder.h" |
19 #include "SkOSFile.h" | 19 #include "SkOSFile.h" |
20 #include "SkPathOpsDebug.h" | 20 #include "SkPathOpsDebug.h" |
21 #include "SkPicture.h" | 21 #include "SkPicture.h" |
| 22 #include "SkRTConf.h" |
22 #include "SkTSort.h" | 23 #include "SkTSort.h" |
23 #include "SkStream.h" | 24 #include "SkStream.h" |
24 #include "SkString.h" | 25 #include "SkString.h" |
25 #include "SkTArray.h" | 26 #include "SkTArray.h" |
26 #include "SkTDArray.h" | 27 #include "SkTDArray.h" |
27 #include "SkTaskGroup.h" | 28 #include "SkTaskGroup.h" |
28 #include "SkTemplates.h" | 29 #include "SkTemplates.h" |
29 #include "SkTSearch.h" | |
30 #include "SkTime.h" | 30 #include "SkTime.h" |
31 | 31 |
32 #include <stdlib.h> | 32 #include <stdlib.h> |
33 | 33 |
34 /* add local exceptions here */ | 34 /* add local exceptions here */ |
35 /* TODO : add command flag interface */ | 35 /* TODO : add command flag interface */ |
36 const struct SkipOverTest { | 36 const struct SkipOverTest { |
37 int directory; | 37 int directory; |
38 const char* filename; | 38 const char* filename; |
39 bool blamePathOps; | 39 bool blamePathOps; |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 return true; | 733 return true; |
734 } | 734 } |
735 #endif | 735 #endif |
736 } | 736 } |
737 checkEarlyExit: | 737 checkEarlyExit: |
738 ; | 738 ; |
739 } | 739 } |
740 return true; | 740 return true; |
741 } | 741 } |
742 | 742 |
| 743 static void initTest() { |
| 744 #if !defined SK_BUILD_FOR_WIN && !defined SK_BUILD_FOR_MAC |
| 745 SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); |
| 746 SK_CONF_SET("images.png.suppressDecoderWarnings", true); |
| 747 #endif |
| 748 } |
| 749 |
743 static void testSkpClipEncode(TestState* data) { | 750 static void testSkpClipEncode(TestState* data) { |
744 data->fResult.testOne(); | 751 data->fResult.testOne(); |
745 if (verbose()) { | 752 if (verbose()) { |
746 SkDebugf("+"); | 753 SkDebugf("+"); |
747 } | 754 } |
748 } | 755 } |
749 | 756 |
750 static void encodeFound(TestState& state) { | 757 static void encodeFound(TestState& state) { |
751 if (verbose()) { | 758 if (verbose()) { |
752 if (state.fPixelWorst.count()) { | 759 if (state.fPixelWorst.count()) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 \ | 820 \ |
814 protected: \ | 821 protected: \ |
815 void onGetName(SkString* name) override { name->set(#name); } \ | 822 void onGetName(SkString* name) override { name->set(#name); } \ |
816 void onRun() override { test_##name(); } \ | 823 void onRun() override { test_##name(); } \ |
817 }; \ | 824 }; \ |
818 static TestRegistry gReg_##name##Class(name##Class::Factory); \ | 825 static TestRegistry gReg_##name##Class(name##Class::Factory); \ |
819 static void test_##name() | 826 static void test_##name() |
820 | 827 |
821 DEF_TEST(PathOpsSkpClip) { | 828 DEF_TEST(PathOpsSkpClip) { |
822 gDirs.setDefault(); | 829 gDirs.setDefault(); |
| 830 initTest(); |
823 SkTArray<TestResult, true> errors; | 831 SkTArray<TestResult, true> errors; |
824 TestState state; | 832 TestState state; |
825 state.init(0); | 833 state.init(0); |
826 int dirNo; | 834 int dirNo; |
827 gDirs.reset(); | 835 gDirs.reset(); |
828 while ((dirNo = gDirs.next()) > 0) { | 836 while ((dirNo = gDirs.next()) > 0) { |
829 if (verbose()) { | 837 if (verbose()) { |
830 SkDebugf("dirNo=%d\n", dirNo); | 838 SkDebugf("dirNo=%d\n", dirNo); |
831 } | 839 } |
832 state.fResult.fDirNo = dirNo; | 840 state.fResult.fDirNo = dirNo; |
833 if (!doOneDir(&state, false)) { | 841 if (!doOneDir(&state, false)) { |
834 break; | 842 break; |
835 } | 843 } |
836 } | 844 } |
837 encodeFound(state); | 845 encodeFound(state); |
838 } | 846 } |
839 | 847 |
840 static void testSkpClipMain(TestState* data) { | 848 static void testSkpClipMain(TestState* data) { |
841 (void) doOneDir(data, true); | 849 (void) doOneDir(data, true); |
842 } | 850 } |
843 | 851 |
844 DEF_TEST(PathOpsSkpClipThreaded) { | 852 DEF_TEST(PathOpsSkpClipThreaded) { |
845 gDirs.setDefault(); | 853 gDirs.setDefault(); |
| 854 initTest(); |
846 TestRunner testRunner; | 855 TestRunner testRunner; |
847 int dirNo; | 856 int dirNo; |
848 gDirs.reset(); | 857 gDirs.reset(); |
849 while ((dirNo = gDirs.next()) > 0) { | 858 while ((dirNo = gDirs.next()) > 0) { |
850 *testRunner.fRunnables.append() = new TestRunnableDir(&testSkpClipMain,
dirNo, &testRunner); | 859 *testRunner.fRunnables.append() = new TestRunnableDir(&testSkpClipMain,
dirNo, &testRunner); |
851 } | 860 } |
852 testRunner.render(); | 861 testRunner.render(); |
853 TestState state; | 862 TestState state; |
854 state.init(0); | 863 state.init(0); |
855 gDirs.reset(); | 864 gDirs.reset(); |
(...skipping 18 matching lines...) Expand all Loading... |
874 return false; | 883 return false; |
875 } | 884 } |
876 } | 885 } |
877 return true; | 886 return true; |
878 } | 887 } |
879 | 888 |
880 DEF_TEST(PathOpsSkpClipUberThreaded) { | 889 DEF_TEST(PathOpsSkpClipUberThreaded) { |
881 gDirs.setDefault(); | 890 gDirs.setDefault(); |
882 const int firstDirNo = gDirs.next(); | 891 const int firstDirNo = gDirs.next(); |
883 const int lastDirNo = gDirs.last(); | 892 const int lastDirNo = gDirs.last(); |
| 893 initTest(); |
884 int dirCount = lastDirNo - firstDirNo + 1; | 894 int dirCount = lastDirNo - firstDirNo + 1; |
885 SkAutoTDeleteArray<SkTDArray<TestResult> > tests(new SkTDArray<TestResult>[d
irCount]); | 895 SkAutoTDeleteArray<SkTDArray<TestResult> > tests(new SkTDArray<TestResult>[d
irCount]); |
886 SkAutoTDeleteArray<SkTDArray<SortByName*> > sorted(new SkTDArray<SortByName*
>[dirCount]); | 896 SkAutoTDeleteArray<SkTDArray<SortByName*> > sorted(new SkTDArray<SortByName*
>[dirCount]); |
887 if (!buildTests(tests.get(), sorted.get())) { | 897 if (!buildTests(tests.get(), sorted.get())) { |
888 return; | 898 return; |
889 } | 899 } |
890 TestRunner testRunner; | 900 TestRunner testRunner; |
891 int dirNo; | 901 int dirNo; |
892 gDirs.reset(); | 902 gDirs.reset(); |
893 while ((dirNo = gDirs.next()) > 0) { | 903 while ((dirNo = gDirs.next()) > 0) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 DEF_TEST(PathOpsSkpClipOneOff) { | 966 DEF_TEST(PathOpsSkpClipOneOff) { |
957 const int testIndex = FLAGS_testIndex; | 967 const int testIndex = FLAGS_testIndex; |
958 int dirNo = gDirs.next(); | 968 int dirNo = gDirs.next(); |
959 if (dirNo < 0) { | 969 if (dirNo < 0) { |
960 dirNo = skipOver[testIndex].directory; | 970 dirNo = skipOver[testIndex].directory; |
961 } | 971 } |
962 const char* skp = gNames.next(); | 972 const char* skp = gNames.next(); |
963 if (!skp) { | 973 if (!skp) { |
964 skp = skipOver[testIndex].filename; | 974 skp = skipOver[testIndex].filename; |
965 } | 975 } |
| 976 initTest(); |
966 SkAssertResult(get_in_path(dirNo, skp).size()); | 977 SkAssertResult(get_in_path(dirNo, skp).size()); |
967 SkString filename(skp); | 978 SkString filename(skp); |
968 TestResult state; | 979 TestResult state; |
969 state.test(dirNo, filename); | 980 state.test(dirNo, filename); |
970 if (verbose()) { | 981 if (verbose()) { |
971 SkDebugf("%s", state.status().c_str()); | 982 SkDebugf("%s", state.status().c_str()); |
972 } | 983 } |
973 state.fTestStep = kEncodeFiles; | 984 state.fTestStep = kEncodeFiles; |
974 state.testOne(); | 985 state.testOne(); |
975 } | 986 } |
976 | 987 |
977 DEF_TEST(PathOpsTestSkipped) { | 988 DEF_TEST(PathOpsTestSkipped) { |
978 for (size_t index = 0; index < skipOverCount; ++index) { | 989 for (size_t index = 0; index < skipOverCount; ++index) { |
979 const SkipOverTest& skip = skipOver[index]; | 990 const SkipOverTest& skip = skipOver[index]; |
980 if (!skip.blamePathOps) { | 991 if (!skip.blamePathOps) { |
981 continue; | 992 continue; |
982 } | 993 } |
983 int dirNo = skip.directory; | 994 int dirNo = skip.directory; |
984 const char* skp = skip.filename; | 995 const char* skp = skip.filename; |
| 996 initTest(); |
985 SkAssertResult(get_in_path(dirNo, skp).size()); | 997 SkAssertResult(get_in_path(dirNo, skp).size()); |
986 SkString filename(skp); | 998 SkString filename(skp); |
987 TestResult state; | 999 TestResult state; |
988 state.test(dirNo, filename); | 1000 state.test(dirNo, filename); |
989 if (verbose()) { | 1001 if (verbose()) { |
990 SkDebugf("%s", state.status().c_str()); | 1002 SkDebugf("%s", state.status().c_str()); |
991 } | 1003 } |
992 state.fTestStep = kEncodeFiles; | 1004 state.fTestStep = kEncodeFiles; |
993 state.testOne(); | 1005 state.testOne(); |
994 } | 1006 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 } | 1092 } |
1081 } | 1093 } |
1082 return 0; | 1094 return 0; |
1083 } | 1095 } |
1084 | 1096 |
1085 #if !defined(SK_BUILD_FOR_IOS) | 1097 #if !defined(SK_BUILD_FOR_IOS) |
1086 int main(int argc, char * const argv[]) { | 1098 int main(int argc, char * const argv[]) { |
1087 return tool_main(argc, (char**) argv); | 1099 return tool_main(argc, (char**) argv); |
1088 } | 1100 } |
1089 #endif | 1101 #endif |
OLD | NEW |