Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 4 * | 3 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 7 | |
| 8 /* This file is meant to be included by .cpp files, so it can spew out a | 8 /* This file is meant to be included by .cpp files, so it can spew out a |
| 9 customized class + global definition. | 9 customized class + global definition. |
| 10 | 10 |
| 11 e.g. | 11 e.g. |
| 12 #include "TestClassDef.h" | 12 #include "TestClassDef.h" |
| 13 DEFINE_TESTCLASS("MyTest", MyTestClass, MyTestFunction) | 13 DEFINE_TESTCLASS_SHORT(MyTestFunction) |
| 14 | 14 |
| 15 where MyTestFunction is declared as | 15 where MyTestFunction is declared as: |
| 16 | 16 |
| 17 void MyTestFunction(skiatest::Reporter*) | 17 static void MyTestFunction(skiatest::Reporter* reporter) { |
| 18 } | |
| 18 */ | 19 */ |
| 19 | 20 |
| 20 // FIXME: replace all three param callers with the short one param version | |
| 21 #define DEFINE_TESTCLASS_SHORT(function) \ | 21 #define DEFINE_TESTCLASS_SHORT(function) \ |
|
mtklein
2013/12/13 15:24:31
Does anything still use DEFINE_TESTCLASS_SHORT now
tfarina
2013/12/13 21:00:08
It is still used, mainly by the PathOps* tests. I
| |
| 22 namespace skiatest { \ | 22 namespace skiatest { \ |
| 23 class function##Class : public Test { \ | 23 class function##Class : public Test { \ |
| 24 public: \ | 24 public: \ |
| 25 static Test* Factory(void*) { return SkNEW(function##Class); } \ | 25 static Test* Factory(void*) { return SkNEW(function##Class); } \ |
| 26 protected: \ | 26 protected: \ |
| 27 virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(#func tion); } \ | 27 virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(#func tion); } \ |
| 28 virtual void onRun(Reporter* reporter) SK_OVERRIDE { function(report er); } \ | 28 virtual void onRun(Reporter* reporter) SK_OVERRIDE { function(report er); } \ |
| 29 }; \ | 29 }; \ |
| 30 static TestRegistry gReg_##function##Class(function##Class::Factory); \ | 30 static TestRegistry gReg_##function##Class(function##Class::Factory); \ |
| 31 } | 31 } |
| 32 | 32 |
| 33 #define DEFINE_TESTCLASS(uiname, classname, function) \ | |
| 34 namespace skiatest { \ | |
| 35 class classname : public Test { \ | |
| 36 public: \ | |
| 37 static Test* Factory(void*) { return SkNEW(classname); } \ | |
| 38 protected: \ | |
| 39 virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(uinam e); } \ | |
| 40 virtual void onRun(Reporter* reporter) SK_OVERRIDE { function(report er); } \ | |
| 41 }; \ | |
| 42 static TestRegistry gReg_##classname(classname::Factory); \ | |
| 43 } | |
| 44 | |
| 45 #define DEFINE_GPUTESTCLASS(uiname, classname, function) \ | 33 #define DEFINE_GPUTESTCLASS(uiname, classname, function) \ |
| 46 namespace skiatest { \ | 34 namespace skiatest { \ |
| 47 class classname : public GpuTest { \ | 35 class classname : public GpuTest { \ |
| 48 public: \ | 36 public: \ |
| 49 static Test* Factory(void*) { return SkNEW(classname); } \ | 37 static Test* Factory(void*) { return SkNEW(classname); } \ |
| 50 protected: \ | 38 protected: \ |
| 51 virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(uinam e); } \ | 39 virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(uinam e); } \ |
| 52 virtual void onRun(Reporter* reporter) SK_OVERRIDE { \ | 40 virtual void onRun(Reporter* reporter) SK_OVERRIDE { \ |
| 53 function(reporter, GetGrContextFactory()); \ | 41 function(reporter, GetGrContextFactory()); \ |
| 54 } \ | 42 } \ |
| 55 }; \ | 43 }; \ |
| 56 static TestRegistry gReg_##classname(classname::Factory); \ | 44 static TestRegistry gReg_##classname(classname::Factory); \ |
| 57 } | 45 } |
| 58 | 46 |
| 59 | 47 |
| 60 // Yet shorter way to define a test. E.g. | 48 // Yet shorter way to define a test. E.g. |
| 61 // | 49 // |
| 62 // DEF_TEST(some_test_name, r) { | 50 // DEF_TEST(some_test_name, r) { |
| 63 // ... | 51 // ... |
| 64 // REPORTER_ASSERT(r, x == 15); | 52 // REPORTER_ASSERT(r, x == 15); |
| 65 // } | 53 // } |
| 66 #define DEF_TEST(name, reporter) \ | 54 #define DEF_TEST(name, reporter) \ |
| 67 static void name(skiatest::Reporter* reporter); \ | 55 static void name(skiatest::Reporter* reporter); \ |
| 68 DEFINE_TESTCLASS_SHORT(name) \ | 56 DEFINE_TESTCLASS_SHORT(name) \ |
| 69 static void name(skiatest::Reporter* reporter) | 57 static void name(skiatest::Reporter* reporter) |
| OLD | NEW |