diff options
author | bsalomon <bsalomon@google.com> | 2016-04-05 12:59:06 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-05 12:59:06 -0700 |
commit | f2f1c17e331fe1e0ce695969970ecebc81e12ceb (patch) | |
tree | e4dc53ee03e1803307a43917fb440d19cfe3f6f1 /tests/Test.h | |
parent | 4319593988db5796023d9f5f34a8ed285c2097dd (diff) |
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
Diffstat (limited to 'tests/Test.h')
-rw-r--r-- | tests/Test.h | 65 |
1 files changed, 33 insertions, 32 deletions
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<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 { \ |