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 #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 
     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) {                        \
     40                 if (fContext) {                                             \
     41                     function(reporter, fContext);                           \
     42                 }                                                           \
     43             }                                                               \
     44         };                                                                  \
     45         static TestRegistry gReg(classname::Factory);                       \
     46     }
     47