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 #ifndef skiatest_Test_DEFINED | 7 #ifndef skiatest_Test_DEFINED |
8 #define skiatest_Test_DEFINED | 8 #define skiatest_Test_DEFINED |
9 | 9 |
10 #include "SkString.h" | 10 #include "SkString.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 ... | 70 ... |
71 REPORTER_ASSERT_MESSAGE(reporter, x == 15, "x should be 15"); | 71 REPORTER_ASSERT_MESSAGE(reporter, x == 15, "x should be 15"); |
72 ... | 72 ... |
73 if (x != 15) { | 73 if (x != 15) { |
74 ERRORF(reporter, "x should be 15, but is %d", x); | 74 ERRORF(reporter, "x should be 15, but is %d", x); |
75 return; | 75 return; |
76 } | 76 } |
77 ... | 77 ... |
78 } | 78 } |
79 */ | 79 */ |
80 enum GPUTestContexts { | 80 |
81 kNone_GPUTestContexts = 0, | 81 #if SK_SUPPORT_GPU |
82 kNull_GPUTestContexts = 1, | 82 using GrContextFactoryContextType = sk_gpu_test::GrContextFactory::ContextType; |
83 kDebug_GPUTestContexts = 1 << 1, | 83 #else |
84 kNative_GPUTestContexts = 1 << 2, | 84 using GrContextFactoryContextType = int; |
85 kOther_GPUTestContexts = 1 << 3, // Other than native, used only for
below. | 85 #endif |
86 kAllRendering_GPUTestContexts = kNative_GPUTestContexts | kOther_GPUTestCont
exts, | |
87 kAll_GPUTestContexts = kAllRendering_GPUTestContexts | |
88 | kNull_GPUTestContexts | |
89 | kDebug_GPUTestContexts | |
90 }; | |
91 | 86 |
92 typedef void GrContextTestFn(Reporter*, const sk_gpu_test::ContextInfo&); | 87 typedef void GrContextTestFn(Reporter*, const sk_gpu_test::ContextInfo&); |
| 88 typedef bool GrContextTypeFilterFn(GrContextFactoryContextType); |
93 | 89 |
94 void RunWithGPUTestContexts(GrContextTestFn* testFunction, GPUTestContexts conte
xts, | 90 extern bool IsGLContextType(GrContextFactoryContextType); |
95 Reporter* reporter, sk_gpu_test::GrContextFactory* f
actory); | 91 extern bool IsRenderingGLContextType(GrContextFactoryContextType); |
| 92 extern bool IsNullGLContextType(GrContextFactoryContextType); |
| 93 |
| 94 void RunWithGPUTestContexts(GrContextTestFn*, GrContextTypeFilterFn*, |
| 95 Reporter*, sk_gpu_test::GrContextFactory*); |
96 | 96 |
97 /** Timer provides wall-clock duration since its creation. */ | 97 /** Timer provides wall-clock duration since its creation. */ |
98 class Timer { | 98 class Timer { |
99 public: | 99 public: |
100 /** Starts the timer. */ | 100 /** Starts the timer. */ |
101 Timer(); | 101 Timer(); |
102 | 102 |
103 /** Nanoseconds since creation. */ | 103 /** Nanoseconds since creation. */ |
104 double elapsedNs() const; | 104 double elapsedNs() const; |
105 | 105 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 const sk_gpu_test::ContextInfo& context_info);
\ | 160 const sk_gpu_test::ContextInfo& context_info);
\ |
161 static void test_gpu_contexts_##name(skiatest::Reporter* reporter,
\ | 161 static void test_gpu_contexts_##name(skiatest::Reporter* reporter,
\ |
162 sk_gpu_test::GrContextFactory* factory)
{ \ | 162 sk_gpu_test::GrContextFactory* factory)
{ \ |
163 skiatest::RunWithGPUTestContexts(test_##name, contexts, reporter, factor
y); \ | 163 skiatest::RunWithGPUTestContexts(test_##name, contexts, reporter, factor
y); \ |
164 }
\ | 164 }
\ |
165 skiatest::TestRegistry name##TestRegistry(
\ | 165 skiatest::TestRegistry name##TestRegistry(
\ |
166 skiatest::Test(#name, true, test_gpu_contexts_##name));
\ | 166 skiatest::Test(#name, true, test_gpu_contexts_##name));
\ |
167 void test_##name(skiatest::Reporter* reporter,
\ | 167 void test_##name(skiatest::Reporter* reporter,
\ |
168 const sk_gpu_test::ContextInfo& context_info) | 168 const sk_gpu_test::ContextInfo& context_info) |
169 | 169 |
170 #define DEF_GPUTEST_FOR_ALL_CONTEXTS(name, reporter, context_info)
\ | 170 #define DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(name, reporter, context_info)
\ |
171 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAll_GPUTestContexts, reporter,
context_info) | 171 DEF_GPUTEST_FOR_CONTEXTS(name, &skiatest::IsGLContextType, reporter, con
text_info) |
172 #define DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info)
\ | 172 #define DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(name, reporter, context_info)
\ |
173 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAllRendering_GPUTestContexts,
reporter, \ | 173 DEF_GPUTEST_FOR_CONTEXTS(name, &skiatest::IsRenderingGLContextType, repo
rter, context_info) |
174 context_info) | 174 #define DEF_GPUTEST_FOR_NULLGL_CONTEXT(name, reporter, context_info)
\ |
175 #define DEF_GPUTEST_FOR_NULL_CONTEXT(name, reporter, context_info)
\ | 175 DEF_GPUTEST_FOR_CONTEXTS(name, &skiatest::IsNullGLContextType, reporter,
context_info) |
176 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kNull_GPUTestContexts, reporter
, context_info) | |
177 | 176 |
178 #define REQUIRE_PDF_DOCUMENT(TEST_NAME, REPORTER) \ | 177 #define REQUIRE_PDF_DOCUMENT(TEST_NAME, REPORTER) \ |
179 do { \ | 178 do { \ |
180 SkDynamicMemoryWStream testStream; \ | 179 SkDynamicMemoryWStream testStream; \ |
181 SkAutoTUnref<SkDocument> testDoc(SkDocument::CreatePDF(&testStream)); \ | 180 SkAutoTUnref<SkDocument> testDoc(SkDocument::CreatePDF(&testStream)); \ |
182 if (!testDoc) { \ | 181 if (!testDoc) { \ |
183 INFOF(REPORTER, "PDF disabled; %s test skipped.", #TEST_NAME); \ | 182 INFOF(REPORTER, "PDF disabled; %s test skipped.", #TEST_NAME); \ |
184 return; \ | 183 return; \ |
185 } \ | 184 } \ |
186 } while (false) | 185 } while (false) |
187 | 186 |
188 #endif | 187 #endif |
OLD | NEW |