Home | History | Annotate | Download | only in tests
      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  */
      8 /*  This file is meant to be included by .cpp files, so it can spew out a
      9     customized class + global definition.
     10 
     11     e.g.
     12     #include "TestClassDef.h"
     13     DEFINE_TESTCLASS("MyTest", MyTestClass, MyTestFunction)
     14 
     15     where MyTestFunction is declared as
     16 
     17         void MyTestFunction(skiatest::Reporter*)
     18 */
     19 
     20 // FIXME: replace all three param callers with the short one param version
     21 #define DEFINE_TESTCLASS_SHORT(function)                                                 \
     22     namespace skiatest {                                                                 \
     23         class function##Class : public Test {                                            \
     24         public:                                                                          \
     25             static Test* Factory(void*) { return SkNEW(function##Class); }               \
     26         protected:                                                                       \
     27             virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(#function); } \
     28             virtual void onRun(Reporter* reporter) SK_OVERRIDE { function(reporter); }   \
     29         };                                                                               \
     30         static TestRegistry gReg_##function##Class(function##Class::Factory);            \
     31     }
     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(uiname); }   \
     40             virtual void onRun(Reporter* reporter) SK_OVERRIDE { function(reporter); }  \
     41         };                                                                              \
     42         static TestRegistry gReg_##classname(classname::Factory);                       \
     43     }
     44 
     45 #define DEFINE_GPUTESTCLASS(uiname, classname, function)                                \
     46     namespace skiatest {                                                                \
     47         class classname : public GpuTest {                                              \
     48         public:                                                                         \
     49             static Test* Factory(void*) { return SkNEW(classname); }                    \
     50         protected:                                                                      \
     51             virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(uiname); }   \
     52             virtual void onRun(Reporter* reporter) SK_OVERRIDE {                        \
     53                 function(reporter, GetGrContextFactory());                              \
     54             }                                                                           \
     55         };                                                                              \
     56         static TestRegistry gReg_##classname(classname::Factory);                       \
     57     }
     58