skia2/tests/TestClassDef.h
tfarina@chromium.org 9f9d5829c2 Get rid of DEFINE_TESTCLASS() macro.
Remaining tests were rewrite to use DEF_TEST() macro instead. This fixes
the FIXME in TestClassDef.h

BUG=None
TEST=tests
R=mtklein@google.com

Review URL: https://codereview.chromium.org/114563003

git-svn-id: http://skia.googlecode.com/svn/trunk@12760 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-12-18 22:15:12 +00:00

58 lines
2.7 KiB
C++

/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* This file is meant to be included by .cpp files, so it can spew out a
customized class + global definition.
e.g.
#include "TestClassDef.h"
DEFINE_TESTCLASS_SHORT(MyTestFunction)
where MyTestFunction is declared as:
static void MyTestFunction(skiatest::Reporter* reporter) {
}
*/
#define DEFINE_TESTCLASS_SHORT(function) \
namespace skiatest { \
class function##Class : public Test { \
public: \
static Test* Factory(void*) { return SkNEW(function##Class); } \
protected: \
virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(#function); } \
virtual void onRun(Reporter* reporter) SK_OVERRIDE { function(reporter); } \
}; \
static TestRegistry gReg_##function##Class(function##Class::Factory); \
}
#define DEFINE_GPUTESTCLASS(uiname, classname, function) \
namespace skiatest { \
class classname : public GpuTest { \
public: \
static Test* Factory(void*) { return SkNEW(classname); } \
protected: \
virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(uiname); } \
virtual void onRun(Reporter* reporter) SK_OVERRIDE { \
function(reporter, GetGrContextFactory()); \
} \
}; \
static TestRegistry gReg_##classname(classname::Factory); \
}
// Yet shorter way to define a test. E.g.
//
// DEF_TEST(some_test_name, r) {
// ...
// REPORTER_ASSERT(r, x == 15);
// }
#define DEF_TEST(name, reporter) \
static void name(skiatest::Reporter* reporter); \
DEFINE_TESTCLASS_SHORT(name) \
static void name(skiatest::Reporter* reporter)