From f2f1c17e331fe1e0ce695969970ecebc81e12ceb Mon Sep 17 00:00:00 2001 From: bsalomon Date: Tue, 5 Apr 2016 12:59:06 -0700 Subject: One signature for creating unit tests that run on premade GrContexts GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1860593002 Review URL: https://codereview.chromium.org/1860593002 --- tests/Test.h | 65 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 32 deletions(-) (limited to 'tests/Test.h') diff --git a/tests/Test.h b/tests/Test.h index 7430372e7d..de99fa53e0 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 -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 { \ -- cgit v1.2.3