blob: f874acc007f32638c58211245289d5314e1529d9 [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.org78e7b4e2014-01-02 21:45:03 +000014 DEF_TEST(some_test_name, r) {
15 ...
16 REPORTER_ASSERT(r, 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
bsalomon@google.com67b915d2013-02-04 16:13:32 +000034#define DEFINE_GPUTESTCLASS(uiname, classname, function) \
35 namespace skiatest { \
36 class classname : public GpuTest { \
37 public: \
38 static Test* Factory(void*) { return SkNEW(classname); } \
39 protected: \
40 virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(uiname); } \
41 virtual void onRun(Reporter* reporter) SK_OVERRIDE { \
42 function(reporter, GetGrContextFactory()); \
43 } \
44 }; \
junov@chromium.org995beb62013-03-28 13:49:22 +000045 static TestRegistry gReg_##classname(classname::Factory); \
bsalomon@google.coma8e686e2011-08-16 15:45:58 +000046 }