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

Side by Side Diff: tests/Test.h

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

Powered by Google App Engine
This is Rietveld 408576698