Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1566)

Unified Diff: tests/Test.h

Issue 138563004: Move macros from TestClassDef.h to Test.h (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: upload Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/TSetTest.cpp ('k') | tests/TestClassDef.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/Test.h
diff --git a/tests/Test.h b/tests/Test.h
index ff6b4ac82c2a30c32f8d5cbc7de97cdd49932284..2dc7c66f7c2e2833eb2639b26989a73f06be93e0 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -87,7 +87,26 @@ namespace skiatest {
};
typedef SkTRegistry<Test*(*)(void*)> TestRegistry;
-}
+} // namespace skiatest
+
+/*
+ Use the following macros to make use of the skiatest classes, e.g.
+
+ #include "Test.h"
+
+ DEF_TEST(TestName, reporter) {
+ ...
+ REPORTER_ASSERT(reporter, x == 15);
+ ...
+ REPORTER_ASSERT_MESSAGE(reporter, x == 15, "x should be 15");
+ ...
+ if (x != 15) {
+ ERRORF(reporter, "x should be 15, but is %d", x);
+ return;
+ }
+ ...
+ }
+*/
#define REPORTER_ASSERT(r, cond) \
do { \
@@ -116,4 +135,38 @@ namespace skiatest {
(reporter)->reportFailed(desc); \
} while(0)
+#define DEF_TEST(name, reporter) \
+ static void name(skiatest::Reporter*); \
+ namespace skiatest { \
+ class name##Class : public Test { \
+ public: \
+ static Test* Factory(void*) { return SkNEW(name##Class); } \
+ protected: \
+ virtual void onGetName(SkString* name) SK_OVERRIDE { \
+ name->set(#name); \
+ } \
+ virtual void onRun(Reporter* r) SK_OVERRIDE { name(r); } \
+ }; \
+ static TestRegistry gReg_##name##Class(name##Class::Factory); \
+ } \
+ static void name(skiatest::Reporter* reporter)
+
+#define DEF_GPUTEST(name, reporter, factory) \
+ static void name(skiatest::Reporter*, GrContextFactory*); \
+ namespace skiatest { \
+ class name##Class : public GpuTest { \
+ public: \
+ static Test* Factory(void*) { return SkNEW(name##Class); } \
+ protected: \
+ virtual void onGetName(SkString* name) SK_OVERRIDE { \
+ name->set(#name); \
+ } \
+ virtual void onRun(Reporter* r) SK_OVERRIDE { \
+ name(r, GetGrContextFactory()); \
+ } \
+ }; \
+ static TestRegistry gReg_##name##Class(name##Class::Factory); \
+ } \
+ static void name(skiatest::Reporter* reporter, GrContextFactory* factory)
+
#endif
« no previous file with comments | « tests/TSetTest.cpp ('k') | tests/TestClassDef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698