Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: tests/Test.h

Issue 1860593002: One signature for creating unit tests that run on premade GrContexts (Closed) Base URL: https://skia.googlesource.com/skia.git@try_no_native
Patch Set: another guess to fix windows Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/TessellatingPathRendererTests.cpp ('k') | tests/TestTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "SkTRegistry.h" 11 #include "SkTRegistry.h"
12 #include "SkTypes.h" 12 #include "SkTypes.h"
13 13
14 #if SK_SUPPORT_GPU
15 #include "GrContextFactory.h"
16 #else
14 namespace sk_gpu_test { 17 namespace sk_gpu_test {
15 class GrContextFactory; 18 class GrContextFactory;
19 class ContextInfo;
16 class GLTestContext; 20 class GLTestContext;
17 } // namespace sk_gpu_test 21 } // namespace sk_gpu_test
18 class GrContext; 22 class GrContext;
23 #endif
19 24
20 namespace skiatest { 25 namespace skiatest {
21 26
22 SkString GetTmpDir(); 27 SkString GetTmpDir();
23 28
24 struct Failure { 29 struct Failure {
25 Failure(const char* f, int l, const char* c, const SkString& m) 30 Failure(const char* f, int l, const char* c, const SkString& m)
26 : fileName(f), lineNo(l), condition(c), message(m) {} 31 : fileName(f), lineNo(l), condition(c), message(m) {}
27 const char* fileName; 32 const char* fileName;
28 int lineNo; 33 int lineNo;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 kNone_GPUTestContexts = 0, 81 kNone_GPUTestContexts = 0,
77 kNull_GPUTestContexts = 1, 82 kNull_GPUTestContexts = 1,
78 kDebug_GPUTestContexts = 1 << 1, 83 kDebug_GPUTestContexts = 1 << 1,
79 kNative_GPUTestContexts = 1 << 2, 84 kNative_GPUTestContexts = 1 << 2,
80 kOther_GPUTestContexts = 1 << 3, // Other than native, used only for below. 85 kOther_GPUTestContexts = 1 << 3, // Other than native, used only for below.
81 kAllRendering_GPUTestContexts = kNative_GPUTestContexts | kOther_GPUTestCont exts, 86 kAllRendering_GPUTestContexts = kNative_GPUTestContexts | kOther_GPUTestCont exts,
82 kAll_GPUTestContexts = kAllRendering_GPUTestContexts 87 kAll_GPUTestContexts = kAllRendering_GPUTestContexts
83 | kNull_GPUTestContexts 88 | kNull_GPUTestContexts
84 | kDebug_GPUTestContexts 89 | kDebug_GPUTestContexts
85 }; 90 };
86 template<typename T> 91
87 void RunWithGPUTestContexts(T testFunction, GPUTestContexts contexts, Reporter* reporter, 92 typedef void GrContextTestFn(Reporter*, const sk_gpu_test::ContextInfo&);
88 sk_gpu_test::GrContextFactory* factory); 93
94 void RunWithGPUTestContexts(GrContextTestFn* testFunction, GPUTestContexts conte xts,
95 Reporter* reporter, sk_gpu_test::GrContextFactory* f actory);
89 96
90 /** Timer provides wall-clock duration since its creation. */ 97 /** Timer provides wall-clock duration since its creation. */
91 class Timer { 98 class Timer {
92 public: 99 public:
93 /** Starts the timer. */ 100 /** Starts the timer. */
94 Timer(); 101 Timer();
95 102
96 /** Nanoseconds since creation. */ 103 /** Nanoseconds since creation. */
97 double elapsedNs() const; 104 double elapsedNs() const;
98 105
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 SkDebugf(__VA_ARGS__); \ 141 SkDebugf(__VA_ARGS__); \
135 } \ 142 } \
136 } while (0) 143 } while (0)
137 144
138 #define DEF_TEST(name, reporter) \ 145 #define DEF_TEST(name, reporter) \
139 static void test_##name(skiatest::Reporter*, sk_gpu_test::GrContextFactory*) ; \ 146 static void test_##name(skiatest::Reporter*, sk_gpu_test::GrContextFactory*) ; \
140 skiatest::TestRegistry name##TestRegistry( \ 147 skiatest::TestRegistry name##TestRegistry( \
141 skiatest::Test(#name, false, test_##name)); \ 148 skiatest::Test(#name, false, test_##name)); \
142 void test_##name(skiatest::Reporter* reporter, sk_gpu_test::GrContextFactory *) 149 void test_##name(skiatest::Reporter* reporter, sk_gpu_test::GrContextFactory *)
143 150
144 #define GPUTEST_EXPAND_MSVC(x) x
145 #define GPUTEST_APPLY(C, ...) GPUTEST_EXPAND_MSVC(C(__VA_ARGS__))
146 #define GPUTEST_SELECT(a1, a2, N, ...) N
147 151
148 #define GPUTEST_CONTEXT_ARGS1(a1) GrContext* a1 152 #define DEF_GPUTEST(name, reporter, factory) \
149 #define GPUTEST_CONTEXT_ARGS2(a1, a2) GrContext* a1, sk_gpu_test::GLTestContext* a2 153 static void test_##name(skiatest::Reporter*, sk_gpu_test::GrContextFactory*) ; \
150 #define GPUTEST_CONTEXT_ARGS(...) \ 154 skiatest::TestRegistry name##TestRegistry( \
151 GPUTEST_APPLY(GPUTEST_SELECT(__VA_ARGS__, GPUTEST_CONTEXT_ARGS2, GPUTEST_CON TEXT_ARGS1), \ 155 skiatest::Test(#name, true, test_##name)); \
152 __VA_ARGS__)
153
154 #define DEF_GPUTEST(name, reporter, factory) \
155 static void test_##name(skiatest::Reporter*, sk_gpu_test::GrContextFactory*) ; \
156 skiatest::TestRegistry name##TestRegistry( \
157 skiatest::Test(#name, true, test_##name)); \
158 void test_##name(skiatest::Reporter* reporter, sk_gpu_test::GrContextFactory * factory) 156 void test_##name(skiatest::Reporter* reporter, sk_gpu_test::GrContextFactory * factory)
159 157
160 #define DEF_GPUTEST_FOR_CONTEXTS(name, contexts, reporter, ...) \ 158 #define DEF_GPUTEST_FOR_CONTEXTS(name, contexts, reporter, context_info) \
161 static void test_##name(skiatest::Reporter*, GPUTEST_CONTEXT_ARGS(__VA_ARGS_ _)); \ 159 static void test_##name(skiatest::Reporter*, \
162 static void test_gpu_contexts_##name(skiatest::Reporter* reporter, \ 160 const sk_gpu_test::ContextInfo& context_info); \
163 sk_gpu_test::GrContextFactory* factory) { \ 161 static void test_gpu_contexts_##name(skiatest::Reporter* reporter, \
164 skiatest::RunWithGPUTestContexts(test_##name, contexts, reporter, factor y); \ 162 sk_gpu_test::GrContextFactory* factory) { \
165 } \ 163 skiatest::RunWithGPUTestContexts(test_##name, contexts, reporter, factor y); \
166 skiatest::TestRegistry name##TestRegistry( \ 164 } \
167 skiatest::Test(#name, true, test_gpu_contexts_##name)); \ 165 skiatest::TestRegistry name##TestRegistry( \
168 void test_##name(skiatest::Reporter* reporter, GPUTEST_CONTEXT_ARGS(__VA_ARG S__)) 166 skiatest::Test(#name, true, test_gpu_contexts_##name)); \
167 void test_##name(skiatest::Reporter* reporter, \
168 const sk_gpu_test::ContextInfo& context_info)
169 169
170 #define DEF_GPUTEST_FOR_ALL_CONTEXTS(name, reporter, ...) \ 170 #define DEF_GPUTEST_FOR_ALL_CONTEXTS(name, reporter, context_info) \
171 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAll_GPUTestContexts, reporter, __VA_ARGS__) 171 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAll_GPUTestContexts, reporter, context_info)
172 #define DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name, reporter, ...) \ 172 #define DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info) \
173 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAllRendering_GPUTestContexts, reporter, __VA_ARGS__) 173 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAllRendering_GPUTestContexts, reporter, \
174 #define DEF_GPUTEST_FOR_NULL_CONTEXT(name, reporter, ...) \ 174 context_info)
175 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kNull_GPUTestContexts, reporter , __VA_ARGS__) 175 #define DEF_GPUTEST_FOR_NULL_CONTEXT(name, reporter, context_info) \
176 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kNull_GPUTestContexts, reporter , context_info)
176 177
177 #define REQUIRE_PDF_DOCUMENT(TEST_NAME, REPORTER) \ 178 #define REQUIRE_PDF_DOCUMENT(TEST_NAME, REPORTER) \
178 do { \ 179 do { \
179 SkDynamicMemoryWStream testStream; \ 180 SkDynamicMemoryWStream testStream; \
180 SkAutoTUnref<SkDocument> testDoc(SkDocument::CreatePDF(&testStream)); \ 181 SkAutoTUnref<SkDocument> testDoc(SkDocument::CreatePDF(&testStream)); \
181 if (!testDoc) { \ 182 if (!testDoc) { \
182 INFOF(REPORTER, "PDF disabled; %s test skipped.", #TEST_NAME); \ 183 INFOF(REPORTER, "PDF disabled; %s test skipped.", #TEST_NAME); \
183 return; \ 184 return; \
184 } \ 185 } \
185 } while (false) 186 } while (false)
186 187
187 #endif 188 #endif
OLDNEW
« no previous file with comments | « tests/TessellatingPathRendererTests.cpp ('k') | tests/TestTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698