blob: 8351ba71ec03875f5cafdbf5bc05acce3b1aa4ea [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
tfarina@chromium.org9f9d5822013-12-18 22:15:12 +00007
reed@android.com80e39a72009-04-02 16:59:40 +00008/* This file is meant to be included by .cpp files, so it can spew out a
reed@android.comd8730ea2009-02-27 22:06:06 +00009 customized class + global definition.
reed@android.com80e39a72009-04-02 16:59:40 +000010
reed@android.comd8730ea2009-02-27 22:06:06 +000011 e.g.
12 #include "TestClassDef.h"
reed@android.com80e39a72009-04-02 16:59:40 +000013
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +000014 DEF_TEST(TestName, reporter) {
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000015 ...
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +000016 REPORTER_ASSERT(reporter, x == 15);
tfarina@chromium.org9f9d5822013-12-18 22:15:12 +000017 }
reed@android.comd8730ea2009-02-27 22:06:06 +000018*/
19
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000020#define DEF_TEST(name, reporter) \
21 static void name(skiatest::Reporter* reporter); \
22 namespace skiatest { \
23 class name##Class : public Test { \
24 public: \
25 static Test* Factory(void*) { return SkNEW(name##Class); } \
26 protected: \
27 virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(#name); } \
28 virtual void onRun(Reporter* reporter) SK_OVERRIDE { name(reporter); } \
29 }; \
30 static TestRegistry gReg_##name##Class(name##Class::Factory); \
31 } \
32 static void name(skiatest::Reporter* reporter)
caryclark@google.comad65a3e2013-04-15 19:13:59 +000033
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +000034#define DEF_GPUTEST(name, reporter, factory) \
35 static void name(skiatest::Reporter* reporter, GrContextFactory* factory); \
36 namespace skiatest { \
37 class name##Class : public GpuTest { \
38 public: \
39 static Test* Factory(void*) { return SkNEW(name##Class); } \
40 protected: \
41 virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(#name); } \
42 virtual void onRun(Reporter* reporter) SK_OVERRIDE { \
43 name(reporter, GetGrContextFactory()); \
44 } \
45 }; \
46 static TestRegistry gReg_##name##Class(name##Class::Factory); \
47 } \
48 static void name(skiatest::Reporter* reporter, GrContextFactory* factory)