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

Side by Side Diff: tests/Test.h

Issue 1815823002: Move SkGLContext and some GrGLInterface implementations to skgputest module (Closed) Base URL: https://chromium.googlesource.com/skia.git@debugobject
Patch Set: rebase, readd null interface to main lib 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #ifndef skiatest_Test_DEFINED 8 #ifndef skiatest_Test_DEFINED
9 #define skiatest_Test_DEFINED 9 #define skiatest_Test_DEFINED
10 10
11 #include "SkString.h" 11 #include "SkString.h"
12 #include "SkTRegistry.h" 12 #include "SkTRegistry.h"
13 #include "SkTypes.h" 13 #include "SkTypes.h"
14 14
15 namespace sk_gpu_test {
15 class GrContextFactory; 16 class GrContextFactory;
17 class GLContext;
18 } // namespace sk_gpu_test
16 class GrContext; 19 class GrContext;
17 class SkGLContext;
18 20
19 namespace skiatest { 21 namespace skiatest {
20 22
21 SkString GetTmpDir(); 23 SkString GetTmpDir();
22 24
23 struct Failure { 25 struct Failure {
24 Failure(const char* f, int l, const char* c, const SkString& m) 26 Failure(const char* f, int l, const char* c, const SkString& m)
25 : fileName(f), lineNo(l), condition(c), message(m) {} 27 : fileName(f), lineNo(l), condition(c), message(m) {}
26 const char* fileName; 28 const char* fileName;
27 int lineNo; 29 int lineNo;
28 const char* condition; 30 const char* condition;
29 SkString message; 31 SkString message;
30 SkString toString() const; 32 SkString toString() const;
31 }; 33 };
32 34
33 class Reporter : SkNoncopyable { 35 class Reporter : SkNoncopyable {
34 public: 36 public:
35 virtual ~Reporter() {} 37 virtual ~Reporter() {}
36 virtual void bumpTestCount(); 38 virtual void bumpTestCount();
37 virtual void reportFailed(const skiatest::Failure&) = 0; 39 virtual void reportFailed(const skiatest::Failure&) = 0;
38 virtual bool allowExtendedTest() const; 40 virtual bool allowExtendedTest() const;
39 virtual bool verbose() const; 41 virtual bool verbose() const;
40 }; 42 };
41 43
42 #define REPORT_FAILURE(reporter, cond, message) \ 44 #define REPORT_FAILURE(reporter, cond, message) \
43 reporter->reportFailed(skiatest::Failure(__FILE__, __LINE__, cond, message)) 45 reporter->reportFailed(skiatest::Failure(__FILE__, __LINE__, cond, message))
44 46
45 typedef void (*TestProc)(skiatest::Reporter*, GrContextFactory*); 47 typedef void (*TestProc)(skiatest::Reporter*, sk_gpu_test::GrContextFactory*);
46 48
47 struct Test { 49 struct Test {
48 Test(const char* n, bool g, TestProc p) : name(n), needsGpu(g), proc(p) {} 50 Test(const char* n, bool g, TestProc p) : name(n), needsGpu(g), proc(p) {}
49 const char* name; 51 const char* name;
50 bool needsGpu; 52 bool needsGpu;
51 TestProc proc; 53 TestProc proc;
52 }; 54 };
53 55
54 typedef SkTRegistry<Test> TestRegistry; 56 typedef SkTRegistry<Test> TestRegistry;
55 57
(...skipping 21 matching lines...) Expand all
77 kDebug_GPUTestContexts = 1 << 1, 79 kDebug_GPUTestContexts = 1 << 1,
78 kNative_GPUTestContexts = 1 << 2, 80 kNative_GPUTestContexts = 1 << 2,
79 kOther_GPUTestContexts = 1 << 3, // Other than native, used only for below. 81 kOther_GPUTestContexts = 1 << 3, // Other than native, used only for below.
80 kAllRendering_GPUTestContexts = kNative_GPUTestContexts | kOther_GPUTestCont exts, 82 kAllRendering_GPUTestContexts = kNative_GPUTestContexts | kOther_GPUTestCont exts,
81 kAll_GPUTestContexts = kAllRendering_GPUTestContexts 83 kAll_GPUTestContexts = kAllRendering_GPUTestContexts
82 | kNull_GPUTestContexts 84 | kNull_GPUTestContexts
83 | kDebug_GPUTestContexts 85 | kDebug_GPUTestContexts
84 }; 86 };
85 template<typename T> 87 template<typename T>
86 void RunWithGPUTestContexts(T testFunction, GPUTestContexts contexts, Reporter* reporter, 88 void RunWithGPUTestContexts(T testFunction, GPUTestContexts contexts, Reporter* reporter,
87 GrContextFactory* factory); 89 sk_gpu_test::GrContextFactory* factory);
88 90
89 /** Timer provides wall-clock duration since its creation. */ 91 /** Timer provides wall-clock duration since its creation. */
90 class Timer { 92 class Timer {
91 public: 93 public:
92 /** Starts the timer. */ 94 /** Starts the timer. */
93 Timer(); 95 Timer();
94 96
95 /** Nanoseconds since creation. */ 97 /** Nanoseconds since creation. */
96 double elapsedNs() const; 98 double elapsedNs() const;
97 99
(...skipping 29 matching lines...) Expand all
127 REPORT_FAILURE(r, "", SkStringPrintf(__VA_ARGS__)); \ 129 REPORT_FAILURE(r, "", SkStringPrintf(__VA_ARGS__)); \
128 } while (0) 130 } while (0)
129 131
130 #define INFOF(REPORTER, ...) \ 132 #define INFOF(REPORTER, ...) \
131 do { \ 133 do { \
132 if ((REPORTER)->verbose()) { \ 134 if ((REPORTER)->verbose()) { \
133 SkDebugf(__VA_ARGS__); \ 135 SkDebugf(__VA_ARGS__); \
134 } \ 136 } \
135 } while (0) 137 } while (0)
136 138
137 #define DEF_TEST(name, reporter) \ 139 #define DEF_TEST(name, reporter) \
138 static void test_##name(skiatest::Reporter*, GrContextFactory*); \ 140 static void test_##name(skiatest::Reporter*, sk_gpu_test::GrContextFactory*) ; \
139 skiatest::TestRegistry name##TestRegistry( \ 141 skiatest::TestRegistry name##TestRegistry( \
140 skiatest::Test(#name, false, test_##name)); \ 142 skiatest::Test(#name, false, test_##name)); \
141 void test_##name(skiatest::Reporter* reporter, GrContextFactory*) 143 void test_##name(skiatest::Reporter* reporter, sk_gpu_test::GrContextFactory *)
142 144
143 #define GPUTEST_EXPAND_MSVC(x) x 145 #define GPUTEST_EXPAND_MSVC(x) x
144 #define GPUTEST_APPLY(C, ...) GPUTEST_EXPAND_MSVC(C(__VA_ARGS__)) 146 #define GPUTEST_APPLY(C, ...) GPUTEST_EXPAND_MSVC(C(__VA_ARGS__))
145 #define GPUTEST_SELECT(a1, a2, N, ...) N 147 #define GPUTEST_SELECT(a1, a2, N, ...) N
146 148
147 #define GPUTEST_CONTEXT_ARGS1(a1) GrContext* a1 149 #define GPUTEST_CONTEXT_ARGS1(a1) GrContext* a1
148 #define GPUTEST_CONTEXT_ARGS2(a1, a2) GrContext* a1, SkGLContext* a2 150 #define GPUTEST_CONTEXT_ARGS2(a1, a2) GrContext* a1, sk_gpu_test::GLContext* a2
149 #define GPUTEST_CONTEXT_ARGS(...) \ 151 #define GPUTEST_CONTEXT_ARGS(...) \
150 GPUTEST_APPLY(GPUTEST_SELECT(__VA_ARGS__, GPUTEST_CONTEXT_ARGS2, GPUTEST_CON TEXT_ARGS1), \ 152 GPUTEST_APPLY(GPUTEST_SELECT(__VA_ARGS__, GPUTEST_CONTEXT_ARGS2, GPUTEST_CON TEXT_ARGS1), \
151 __VA_ARGS__) 153 __VA_ARGS__)
152 154
153 #define DEF_GPUTEST(name, reporter, factory) \ 155 #define DEF_GPUTEST(name, reporter, factory) \
154 static void test_##name(skiatest::Reporter*, GrContextFactory*); \ 156 static void test_##name(skiatest::Reporter*, sk_gpu_test::GrContextFactory*) ; \
155 skiatest::TestRegistry name##TestRegistry( \ 157 skiatest::TestRegistry name##TestRegistry( \
156 skiatest::Test(#name, true, test_##name)); \ 158 skiatest::Test(#name, true, test_##name)); \
157 void test_##name(skiatest::Reporter* reporter, GrContextFactory* factory) 159 void test_##name(skiatest::Reporter* reporter, sk_gpu_test::GrContextFactory * factory)
158 160
159 #define DEF_GPUTEST_FOR_CONTEXTS(name, contexts, reporter, ...) \ 161 #define DEF_GPUTEST_FOR_CONTEXTS(name, contexts, reporter, ...) \
160 static void test_##name(skiatest::Reporter*, GPUTEST_CONTEXT_ARGS(__VA_ARGS_ _)); \ 162 static void test_##name(skiatest::Reporter*, GPUTEST_CONTEXT_ARGS(__VA_ARGS_ _)); \
161 static void test_gpu_contexts_##name(skiatest::Reporter* reporter, \ 163 static void test_gpu_contexts_##name(skiatest::Reporter* reporter, \
162 GrContextFactory* factory) { \ 164 sk_gpu_test::GrContextFactory* factory) { \
163 skiatest::RunWithGPUTestContexts(test_##name, contexts, reporter, factor y); \ 165 skiatest::RunWithGPUTestContexts(test_##name, contexts, reporter, factor y); \
164 } \ 166 } \
165 skiatest::TestRegistry name##TestRegistry( \ 167 skiatest::TestRegistry name##TestRegistry( \
166 skiatest::Test(#name, true, test_gpu_contexts_##name)); \ 168 skiatest::Test(#name, true, test_gpu_contexts_##name)); \
167 void test_##name(skiatest::Reporter* reporter, GPUTEST_CONTEXT_ARGS(__VA_ARG S__)) 169 void test_##name(skiatest::Reporter* reporter, GPUTEST_CONTEXT_ARGS(__VA_ARG S__))
168 170
169 #define DEF_GPUTEST_FOR_ALL_CONTEXTS(name, reporter, ...) \ 171 #define DEF_GPUTEST_FOR_ALL_CONTEXTS(name, reporter, ...) \
170 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAll_GPUTestContexts, reporter, __VA_ARGS__) 172 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAll_GPUTestContexts, reporter, __VA_ARGS__)
171 #define DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name, reporter, ...) \ 173 #define DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name, reporter, ...) \
172 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAllRendering_GPUTestContexts, reporter, __VA_ARGS__) 174 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAllRendering_GPUTestContexts, reporter, __VA_ARGS__)
173 #define DEF_GPUTEST_FOR_NULL_CONTEXT(name, reporter, ...) \ 175 #define DEF_GPUTEST_FOR_NULL_CONTEXT(name, reporter, ...) \
174 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kNull_GPUTestContexts, reporter , __VA_ARGS__) 176 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kNull_GPUTestContexts, reporter , __VA_ARGS__)
175 #define DEF_GPUTEST_FOR_NATIVE_CONTEXT(name, reporter, ...) \ 177 #define DEF_GPUTEST_FOR_NATIVE_CONTEXT(name, reporter, ...) \
176 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kNative_GPUTestContexts, report er, __VA_ARGS__) 178 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kNative_GPUTestContexts, report er, __VA_ARGS__)
177 179
178 #define REQUIRE_PDF_DOCUMENT(TEST_NAME, REPORTER) \ 180 #define REQUIRE_PDF_DOCUMENT(TEST_NAME, REPORTER) \
179 do { \ 181 do { \
180 SkDynamicMemoryWStream testStream; \ 182 SkDynamicMemoryWStream testStream; \
181 SkAutoTUnref<SkDocument> testDoc(SkDocument::CreatePDF(&testStream)); \ 183 SkAutoTUnref<SkDocument> testDoc(SkDocument::CreatePDF(&testStream)); \
182 if (!testDoc) { \ 184 if (!testDoc) { \
183 INFOF(REPORTER, "PDF disabled; %s test skipped.", #TEST_NAME); \ 185 INFOF(REPORTER, "PDF disabled; %s test skipped.", #TEST_NAME); \
184 return; \ 186 return; \
185 } \ 187 } \
186 } while (false) 188 } while (false)
187 189
188 #endif 190 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698