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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/TessellatingPathRendererTests.cpp ('k') | tests/TestTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/Test.h
diff --git a/tests/Test.h b/tests/Test.h
index 7430372e7d9a3fb6586323faa1bb08d23d8fa335..de99fa53e030ce9d952d64915a5b1ba6d4a009cc 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -11,11 +11,16 @@
#include "SkTRegistry.h"
#include "SkTypes.h"
+#if SK_SUPPORT_GPU
+#include "GrContextFactory.h"
+#else
namespace sk_gpu_test {
class GrContextFactory;
+class ContextInfo;
class GLTestContext;
} // namespace sk_gpu_test
class GrContext;
+#endif
namespace skiatest {
@@ -83,9 +88,11 @@ enum GPUTestContexts {
| kNull_GPUTestContexts
| kDebug_GPUTestContexts
};
-template<typename T>
-void RunWithGPUTestContexts(T testFunction, GPUTestContexts contexts, Reporter* reporter,
- sk_gpu_test::GrContextFactory* factory);
+
+typedef void GrContextTestFn(Reporter*, const sk_gpu_test::ContextInfo&);
+
+void RunWithGPUTestContexts(GrContextTestFn* testFunction, GPUTestContexts contexts,
+ Reporter* reporter, sk_gpu_test::GrContextFactory* factory);
/** Timer provides wall-clock duration since its creation. */
class Timer {
@@ -141,38 +148,32 @@ private:
skiatest::Test(#name, false, test_##name)); \
void test_##name(skiatest::Reporter* reporter, sk_gpu_test::GrContextFactory*)
-#define GPUTEST_EXPAND_MSVC(x) x
-#define GPUTEST_APPLY(C, ...) GPUTEST_EXPAND_MSVC(C(__VA_ARGS__))
-#define GPUTEST_SELECT(a1, a2, N, ...) N
-#define GPUTEST_CONTEXT_ARGS1(a1) GrContext* a1
-#define GPUTEST_CONTEXT_ARGS2(a1, a2) GrContext* a1, sk_gpu_test::GLTestContext* a2
-#define GPUTEST_CONTEXT_ARGS(...) \
- GPUTEST_APPLY(GPUTEST_SELECT(__VA_ARGS__, GPUTEST_CONTEXT_ARGS2, GPUTEST_CONTEXT_ARGS1), \
- __VA_ARGS__)
-
-#define DEF_GPUTEST(name, reporter, factory) \
- static void test_##name(skiatest::Reporter*, sk_gpu_test::GrContextFactory*); \
- skiatest::TestRegistry name##TestRegistry( \
- skiatest::Test(#name, true, test_##name)); \
+#define DEF_GPUTEST(name, reporter, factory) \
+ static void test_##name(skiatest::Reporter*, sk_gpu_test::GrContextFactory*); \
+ skiatest::TestRegistry name##TestRegistry( \
+ skiatest::Test(#name, true, test_##name)); \
void test_##name(skiatest::Reporter* reporter, sk_gpu_test::GrContextFactory* factory)
-#define DEF_GPUTEST_FOR_CONTEXTS(name, contexts, reporter, ...) \
- static void test_##name(skiatest::Reporter*, GPUTEST_CONTEXT_ARGS(__VA_ARGS__)); \
- static void test_gpu_contexts_##name(skiatest::Reporter* reporter, \
- sk_gpu_test::GrContextFactory* factory) { \
- skiatest::RunWithGPUTestContexts(test_##name, contexts, reporter, factory); \
- } \
- skiatest::TestRegistry name##TestRegistry( \
- skiatest::Test(#name, true, test_gpu_contexts_##name)); \
- void test_##name(skiatest::Reporter* reporter, GPUTEST_CONTEXT_ARGS(__VA_ARGS__))
-
-#define DEF_GPUTEST_FOR_ALL_CONTEXTS(name, reporter, ...) \
- DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAll_GPUTestContexts, reporter, __VA_ARGS__)
-#define DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name, reporter, ...) \
- DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAllRendering_GPUTestContexts, reporter, __VA_ARGS__)
-#define DEF_GPUTEST_FOR_NULL_CONTEXT(name, reporter, ...) \
- DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kNull_GPUTestContexts, reporter, __VA_ARGS__)
+#define DEF_GPUTEST_FOR_CONTEXTS(name, contexts, reporter, context_info) \
+ static void test_##name(skiatest::Reporter*, \
+ const sk_gpu_test::ContextInfo& context_info); \
+ static void test_gpu_contexts_##name(skiatest::Reporter* reporter, \
+ sk_gpu_test::GrContextFactory* factory) { \
+ skiatest::RunWithGPUTestContexts(test_##name, contexts, reporter, factory); \
+ } \
+ skiatest::TestRegistry name##TestRegistry( \
+ skiatest::Test(#name, true, test_gpu_contexts_##name)); \
+ void test_##name(skiatest::Reporter* reporter, \
+ const sk_gpu_test::ContextInfo& context_info)
+
+#define DEF_GPUTEST_FOR_ALL_CONTEXTS(name, reporter, context_info) \
+ DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAll_GPUTestContexts, reporter, context_info)
+#define DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info) \
+ DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAllRendering_GPUTestContexts, reporter, \
+ context_info)
+#define DEF_GPUTEST_FOR_NULL_CONTEXT(name, reporter, context_info) \
+ DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kNull_GPUTestContexts, reporter, context_info)
#define REQUIRE_PDF_DOCUMENT(TEST_NAME, REPORTER) \
do { \
« 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