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

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