epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 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.com | 80e39a7 | 2009-04-02 16:59:40 +0000 | [diff] [blame] | 8 | /* This file is meant to be included by .cpp files, so it can spew out a |
reed@android.com | d8730ea | 2009-02-27 22:06:06 +0000 | [diff] [blame] | 9 | customized class + global definition. |
reed@android.com | 80e39a7 | 2009-04-02 16:59:40 +0000 | [diff] [blame] | 10 | |
reed@android.com | d8730ea | 2009-02-27 22:06:06 +0000 | [diff] [blame] | 11 | e.g. |
| 12 | #include "TestClassDef.h" |
| 13 | DEFINE_TESTCLASS("MyTest", MyTestClass, MyTestFunction) |
reed@android.com | 80e39a7 | 2009-04-02 16:59:40 +0000 | [diff] [blame] | 14 | |
reed@android.com | d8730ea | 2009-02-27 22:06:06 +0000 | [diff] [blame] | 15 | where MyTestFunction is declared as |
reed@android.com | 80e39a7 | 2009-04-02 16:59:40 +0000 | [diff] [blame] | 16 | |
reed@android.com | d8730ea | 2009-02-27 22:06:06 +0000 | [diff] [blame] | 17 | 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.com | a8e686e | 2011-08-16 15:45:58 +0000 | [diff] [blame] | 32 | #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.com | 9dfb757 | 2011-08-24 03:29:11 +0000 | [diff] [blame] | 40 | if (fContext) { \ |
| 41 | function(reporter, fContext); \ |
| 42 | } \ |
bsalomon@google.com | a8e686e | 2011-08-16 15:45:58 +0000 | [diff] [blame] | 43 | } \ |
| 44 | }; \ |
| 45 | static TestRegistry gReg(classname::Factory); \ |
| 46 | } |