blob: ffef2a157b819e3e3e645b221207a25abf86d8ad [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
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"
13 DEFINE_TESTCLASS("MyTest", MyTestClass, MyTestFunction)
reed@android.com80e39a72009-04-02 16:59:40 +000014
reed@android.comd8730ea2009-02-27 22:06:06 +000015 where MyTestFunction is declared as
reed@android.com80e39a72009-04-02 16:59:40 +000016
reed@android.comd8730ea2009-02-27 22:06:06 +000017 void MyTestFunction(skiatest::Reporter*)
18*/
19
20#define DEFINE_TESTCLASS(uiname, classname, function) \
21 namespace skiatest { \
22 class classname : public Test { \
23 public: \
24 static Test* Factory(void*) { return SkNEW(classname); } \
25 protected: \
26 virtual void onGetName(SkString* name) { name->set(uiname); } \
27 virtual void onRun(Reporter* reporter) { function(reporter); } \
28 }; \
29 static TestRegistry gReg(classname::Factory); \
30 }
31
bsalomon@google.coma8e686e2011-08-16 15:45:58 +000032#define DEFINE_GPUTESTCLASS(uiname, classname, function) \
33 namespace skiatest { \
34 class classname : public GpuTest { \
35 public: \
36 static Test* Factory(void*) { return SkNEW(classname); } \
37 protected: \
38 virtual void onGetName(SkString* name) { name->set(uiname); } \
39 virtual void onRun(Reporter* reporter) { \
bsalomon@google.com9dfb7572011-08-24 03:29:11 +000040 if (fContext) { \
41 function(reporter, fContext); \
42 } \
bsalomon@google.coma8e686e2011-08-16 15:45:58 +000043 } \
44 }; \
45 static TestRegistry gReg(classname::Factory); \
46 }