Add a DEF_GPUTEST() macro.
authortfarina@chromium.org <tfarina@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 10 Jan 2014 22:08:27 +0000 (22:08 +0000)
committertfarina@chromium.org <tfarina@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 10 Jan 2014 22:08:27 +0000 (22:08 +0000)
This macro is similar to DEF_TEST() and simplifies the process of
setting up a GPU test.

BUG=skia:1952
TEST=tests
R=mtklein@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@13033 2bbb7eff-a529-9590-31e7-b0007b416f81

18 files changed:
tests/BlurTest.cpp
tests/ClipCacheTest.cpp
tests/DeferredCanvasTest.cpp
tests/GLInterfaceValidation.cpp
tests/GLProgramsTest.cpp
tests/GpuBitmapCopyTest.cpp
tests/GpuColorFilterTest.cpp
tests/GpuDrawPathTest.cpp
tests/GrContextFactoryTest.cpp
tests/GrDrawTargetTest.cpp
tests/GrSurfaceTest.cpp
tests/PremulAlphaRoundTripTest.cpp
tests/ReadPixelsTest.cpp
tests/ReadWriteAlphaTest.cpp
tests/ResourceCacheTest.cpp
tests/SurfaceTest.cpp
tests/TestClassDef.h
tests/WritePixelsTest.cpp

index a1eaca9..cfcc103 100644 (file)
@@ -5,12 +5,14 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
-#include "Test.h"
 #include "SkBlurMask.h"
 #include "SkBlurMaskFilter.h"
 #include "SkCanvas.h"
 #include "SkMath.h"
 #include "SkPaint.h"
+#include "Test.h"
+#include "TestClassDef.h"
+
 #if SK_SUPPORT_GPU
 #include "GrContextFactory.h"
 #include "SkGpuDevice.h"
@@ -383,12 +385,7 @@ static void test_sigma_range(skiatest::Reporter* reporter, GrContextFactory* fac
     }
 }
 
-///////////////////////////////////////////////////////////////////////////////
-
-static void test_blur(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(Blur, reporter, factory) {
     test_blur_drawing(reporter);
     test_sigma_range(reporter, factory);
 }
-
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("BlurMaskFilter", BlurTestClass, test_blur)
index 070f8eb..84564c4 100644 (file)
@@ -5,8 +5,8 @@
  * found in the LICENSE file.
  */
 
-
 #include "Test.h"
+#include "TestClassDef.h"
 // This is a GR test
 #if SK_SUPPORT_GPU
 #include "GrContextFactory.h"
@@ -220,8 +220,7 @@ static void test_cache(skiatest::Reporter* reporter, GrContext* context) {
 #endif
 }
 
-////////////////////////////////////////////////////////////////////////////////
-static void TestClipCache(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(ClipCache, reporter, factory) {
     for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
         GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
         if (!GrContextFactory::IsRenderingGLContext(glType)) {
@@ -237,8 +236,4 @@ static void TestClipCache(skiatest::Reporter* reporter, GrContextFactory* factor
     }
 }
 
-////////////////////////////////////////////////////////////////////////////////
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("ClipCache", ClipCacheTestClass, TestClipCache)
-
 #endif
index 45d0292..132736e 100644 (file)
@@ -1,11 +1,12 @@
-
 /*
  * Copyright 2012 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
 #include "Test.h"
+#include "TestClassDef.h"
 #include "SkBitmap.h"
 #include "SkBitmapDevice.h"
 #include "SkBitmapProcShader.h"
@@ -832,7 +833,7 @@ static void TestDeferredCanvasCreateCompatibleDevice(skiatest::Reporter* reporte
     REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount == 1);
 }
 
-static void TestDeferredCanvas(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(DeferredCanvas, reporter, factory) {
     TestDeferredCanvasBitmapAccess(reporter);
     TestDeferredCanvasFlush(reporter);
     TestDeferredCanvasFreshFrame(reporter);
@@ -850,6 +851,3 @@ static void TestDeferredCanvas(skiatest::Reporter* reporter, GrContextFactory* f
         TestDeferredCanvasSetSurface(reporter, factory);
     }
 }
-
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("DeferredCanvas", TestDeferredCanvasClass, TestDeferredCanvas)
index a4709ba..792ed03 100755 (executable)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
@@ -6,15 +5,15 @@
  * found in the LICENSE file.
  */
 
-
-
 #include "Test.h"
+#include "TestClassDef.h"
+
 // This is a GPU-backend specific test
 #if SK_SUPPORT_GPU
 
 #include "GrContextFactory.h"
 
-static void GLInterfaceValidationTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(GLInterfaceValidation, reporter, factory) {
     for (int i = 0; i <= GrContextFactory::kLastGLContextType; ++i) {
         GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType)i;
         // this forces the factory to make the context if it hasn't yet
@@ -34,10 +33,4 @@ static void GLInterfaceValidationTest(skiatest::Reporter* reporter, GrContextFac
     }
 }
 
-
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("GLInterfaceValidation",
-                    GLInterfaceValidationTestClass,
-                    GLInterfaceValidationTest)
-
 #endif
index 7e55cc7..10d56fe 100644 (file)
@@ -21,6 +21,7 @@
 #include "SkChecksum.h"
 #include "SkRandom.h"
 #include "Test.h"
+#include "TestClassDef.h"
 
 void GrGLProgramDesc::setRandom(SkRandom* random,
                                 const GrGpuGL* gpu,
@@ -226,7 +227,7 @@ bool GrGpuGL::programUnitTest(int maxStages) {
     return true;
 }
 
-static void GLProgramsTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(GLPrograms, reporter, factory) {
     for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
         GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(type));
         if (NULL != context) {
@@ -243,9 +244,6 @@ static void GLProgramsTest(skiatest::Reporter* reporter, GrContextFactory* facto
     }
 }
 
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("GLPrograms", GLProgramsTestClass, GLProgramsTest)
-
 // This is evil evil evil. The linker may throw away whole translation units as dead code if it
 // thinks none of the functions are called. It will do this even if there are static initializers
 // in the unit that could pass pointers to functions from the unit out to other translation units!
index a1434dc..9d1a527 100644 (file)
@@ -18,6 +18,7 @@
 #include "SkPixelRef.h"
 #include "SkRect.h"
 #include "Test.h"
+#include "TestClassDef.h"
 
 static const char* boolStr(bool value) {
     return value ? "true" : "false";
@@ -98,7 +99,7 @@ static void TestIndividualCopy(skiatest::Reporter* reporter, const SkBitmap::Con
 
 // Stripped down version of TestBitmapCopy that checks basic fields (width, height, config, genID)
 // to ensure that they were copied properly.
-static void TestGpuBitmapCopy(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(GpuBitmapCopy, reporter, factory) {
 #ifdef SK_BUILD_FOR_ANDROID // https://code.google.com/p/skia/issues/detail?id=753
     return;
 #endif
@@ -188,7 +189,4 @@ static void TestGpuBitmapCopy(skiatest::Reporter* reporter, GrContextFactory* fa
     } // GrContextFactory::GLContextType
 }
 
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("GpuBitmapCopy", TestGpuBitmapCopyClass, TestGpuBitmapCopy)
-
 #endif
index 9fb1c77..0d8acc5 100644 (file)
 #include "GrContextFactory.h"
 #include "GrEffect.h"
 #include "SkColorFilter.h"
-#include "Test.h"
 #include "SkGr.h"
-
-namespace {
+#include "Test.h"
+#include "TestClassDef.h"
 
 static GrColor filterColor(const GrColor& color, uint32_t flags)  {
     uint32_t mask = 0;
@@ -110,7 +109,7 @@ static void test_getConstantColorComponents(skiatest::Reporter* reporter, GrCont
     }
 }
 
-static void TestGpuColorFilter(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(GpuColorFilter, reporter, factory) {
     for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
         GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
 
@@ -123,9 +122,4 @@ static void TestGpuColorFilter(skiatest::Reporter* reporter, GrContextFactory* f
     }
 }
 
-}
-
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("GpuColorFilter", TestGpuColorFilterClass, TestGpuColorFilter)
-
 #endif
index fa844d0..f2a321f 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2013 Google Inc.
  *
@@ -18,9 +17,9 @@
 #include "SkRect.h"
 #include "SkRRect.h"
 #include "Test.h"
+#include "TestClassDef.h"
 
-static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas)
-{
+static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) {
     // Filling an empty path should not crash.
     SkPaint paint;
     canvas->drawRect(SkRect(), paint);
@@ -43,7 +42,7 @@ static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas)
 }
 
 
-static void TestGpuDrawPath(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(GpuDrawPath, reporter, factory) {
     return;
 
     for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
@@ -74,7 +73,4 @@ static void TestGpuDrawPath(skiatest::Reporter* reporter, GrContextFactory* fact
     }
 }
 
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("GpuDrawPath", TestGpuDrawPathClass, TestGpuDrawPath)
-
 #endif
index 02b8c28..9ffbd64 100644 (file)
@@ -5,34 +5,29 @@
  * found in the LICENSE file.
  */
 
-#include "Test.h"
-
-// This is a GPU-backend specific test
 #if SK_SUPPORT_GPU
+
 #include "GrContextFactory.h"
+#include "Test.h"
+#include "TestClassDef.h"
 
-static void test_context_factory(skiatest::Reporter* reporter,
-                                 GrContextFactory* contextFactory) {
+DEF_GPUTEST(GrContextFactoryTest, reporter, factory) {
     // Reset in case some other test has been using it first.
-    contextFactory->destroyContexts();
+    factory->destroyContexts();
 
     // Before we ask for a context, we expect the GL context to not be there.
     REPORTER_ASSERT(reporter,
-                    NULL == contextFactory->getGLContext(GrContextFactory::kNative_GLContextType));
+                    NULL == factory->getGLContext(GrContextFactory::kNative_GLContextType));
 
     // After we ask for a context, we expect that the GL context to be there.
-    contextFactory->get(GrContextFactory::kNative_GLContextType);
+    factory->get(GrContextFactory::kNative_GLContextType);
     REPORTER_ASSERT(reporter,
-                    contextFactory->getGLContext(GrContextFactory::kNative_GLContextType) != NULL);
+                    factory->getGLContext(GrContextFactory::kNative_GLContextType) != NULL);
 
     // If we did not ask for a context with the particular GL context, we would
     // expect the particular GL context to not be there.
     REPORTER_ASSERT(reporter,
-                    NULL == contextFactory->getGLContext(GrContextFactory::kNull_GLContextType));
+                    NULL == factory->getGLContext(GrContextFactory::kNull_GLContextType));
 }
 
-
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("GrContextFactory", GrContextFactoryClass, test_context_factory);
-
 #endif
index f2bcdc4..78d9025 100644 (file)
@@ -13,6 +13,7 @@
 #include "GrGpu.h"
 #include "GrDrawTargetCaps.h"
 #include "Test.h"
+#include "TestClassDef.h"
 
 static void test_print(skiatest::Reporter*, const GrDrawTargetCaps* caps) {
     // This used to assert.
@@ -20,7 +21,7 @@ static void test_print(skiatest::Reporter*, const GrDrawTargetCaps* caps) {
     SkASSERT(!result.isEmpty());
 }
 
-static void TestGrDrawTarget(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(GrDrawTarget, reporter, factory) {
     for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
         GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
 
@@ -33,7 +34,4 @@ static void TestGrDrawTarget(skiatest::Reporter* reporter, GrContextFactory* fac
     }
 }
 
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("GrDrawTarget", TestGrDrawTargetClass, TestGrDrawTarget)
-
 #endif
index 3fe071c..07bf0ce 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2013 Google Inc.
  *
@@ -6,19 +5,17 @@
  * found in the LICENSE file.
  */
 
-// This is a GPU-backend specific test.
-
-#include "SkTypes.h"
-
 #if SK_SUPPORT_GPU
 
-#include "Test.h"
 #include "GrContext.h"
 #include "GrContextFactory.h"
 #include "GrRenderTarget.h"
 #include "GrTexture.h"
+#include "SkTypes.h"
+#include "Test.h"
+#include "TestClassDef.h"
 
-static void GrSurfaceIsSameTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(GrSurfaceTest, reporter, factory) {
     GrContext* context = factory->get(GrContextFactory::kNull_GLContextType);
     if (NULL != context) {
         GrTextureDesc desc;
@@ -62,7 +59,4 @@ static void GrSurfaceIsSameTest(skiatest::Reporter* reporter, GrContextFactory*
     }
 }
 
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("GrSurfaceIsSame", GrSurfaceIsSameTestClass, GrSurfaceIsSameTest)
-
 #endif
index 4a90c45..c963e23 100644 (file)
@@ -5,10 +5,11 @@
  * found in the LICENSE file.
  */
 
-#include "Test.h"
+#include "SkBitmapDevice.h"
 #include "SkCanvas.h"
 #include "SkConfig8888.h"
-#include "SkBitmapDevice.h"
+#include "Test.h"
+#include "TestClassDef.h"
 
 #if SK_SUPPORT_GPU
 #include "GrContextFactory.h"
@@ -36,7 +37,7 @@ static const SkCanvas::Config8888 gUnpremulConfigs[] = {
     SkCanvas::kRGBA_Unpremul_Config8888,
 };
 
-static void PremulAlphaRoundTripTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) {
     SkAutoTUnref<SkBaseDevice> device;
     for (int dtype = 0; dtype < 2; ++dtype) {
 
@@ -110,6 +111,3 @@ static void PremulAlphaRoundTripTest(skiatest::Reporter* reporter, GrContextFact
         }
     }
 }
-
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("PremulAlphaRoundTripTest", PremulAlphaRoundTripTestClass, PremulAlphaRoundTripTest)
index 6e363fc..85846e7 100644 (file)
@@ -5,12 +5,14 @@
  * found in the LICENSE file.
  */
 
-#include "Test.h"
 #include "SkBitmapDevice.h"
 #include "SkCanvas.h"
 #include "SkColorPriv.h"
 #include "SkMathPriv.h"
 #include "SkRegion.h"
+#include "Test.h"
+#include "TestClassDef.h"
+
 #if SK_SUPPORT_GPU
 #include "SkGpuDevice.h"
 #include "GrContextFactory.h"
@@ -251,7 +253,7 @@ static void init_bitmap(SkBitmap* bitmap, const SkIRect& rect, BitmapInit init)
     }
 }
 
-static void ReadPixelsTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(ReadPixels, reporter, factory) {
     const SkIRect testRects[] = {
         // entire thing
         DEV_RECT,
@@ -406,6 +408,3 @@ static void ReadPixelsTest(skiatest::Reporter* reporter, GrContextFactory* facto
         }
     }
 }
-
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("ReadPixels", ReadPixelsTestClass, ReadPixelsTest)
index fb177df..47a5f5a 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2012 Google Inc.
  *
@@ -9,14 +8,15 @@
 // This test is specific to the GPU backend.
 #if SK_SUPPORT_GPU && !defined(SK_BUILD_FOR_ANDROID)
 
-#include "Test.h"
-#include "SkGpuDevice.h"
 #include "GrContextFactory.h"
+#include "SkGpuDevice.h"
+#include "Test.h"
+#include "TestClassDef.h"
 
 static const int X_SIZE = 12;
 static const int Y_SIZE = 12;
 
-static void ReadWriteAlphaTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(ReadWriteAlpha, reporter, factory) {
     for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
         GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
         if (!GrContextFactory::IsRenderingGLContext(glType)) {
@@ -110,7 +110,4 @@ static void ReadWriteAlphaTest(skiatest::Reporter* reporter, GrContextFactory* f
     }
 }
 
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("ReadWriteAlpha", ReadWriteAlphaTestClass, ReadWriteAlphaTest)
-
 #endif
index 1bb6766..6707ebf 100644 (file)
@@ -5,12 +5,12 @@
  * found in the LICENSE file.
  */
 
-#include "Test.h"
-
-// This is a GPU test
 #if SK_SUPPORT_GPU
+
 #include "GrContextFactory.h"
 #include "SkGpuDevice.h"
+#include "Test.h"
+#include "TestClassDef.h"
 
 static const int gWidth = 640;
 static const int gHeight = 480;
@@ -58,8 +58,7 @@ static void test_cache(skiatest::Reporter* reporter,
     context->setTextureCacheLimits(oldMaxNum, oldMaxBytes);
 }
 
-////////////////////////////////////////////////////////////////////////////////
-static void TestResourceCache(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(ResourceCache, reporter, factory) {
     for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
         GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
         if (!GrContextFactory::IsRenderingGLContext(glType)) {
@@ -84,8 +83,4 @@ static void TestResourceCache(skiatest::Reporter* reporter, GrContextFactory* fa
     }
 }
 
-////////////////////////////////////////////////////////////////////////////////
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("ResourceCache", ResourceCacheTestClass, TestResourceCache)
-
 #endif
index 5e95017..b580999 100644 (file)
@@ -1,14 +1,15 @@
-
 /*
  * Copyright 2013 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
 #include "SkCanvas.h"
 #include "SkRRect.h"
 #include "SkSurface.h"
 #include "Test.h"
+#include "TestClassDef.h"
 
 #if SK_SUPPORT_GPU
 #include "GrContextFactory.h"
@@ -231,7 +232,7 @@ static void TestSurfaceNoCanvas(skiatest::Reporter* reporter,
 
 }
 
-static void TestSurface(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(Surface, reporter, factory) {
     TestSurfaceCopyOnWrite(reporter, kRaster_SurfaceType, NULL);
     TestSurfaceCopyOnWrite(reporter, kPicture_SurfaceType, NULL);
     TestSurfaceWritableAfterSnapshotRelease(reporter, kRaster_SurfaceType, NULL);
@@ -254,6 +255,3 @@ static void TestSurface(skiatest::Reporter* reporter, GrContextFactory* factory)
     }
 #endif
 }
-
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("Surface", SurfaceTestClass, TestSurface)
index f874acc..8351ba7 100644 (file)
@@ -11,9 +11,9 @@
     e.g.
     #include "TestClassDef.h"
 
-    DEF_TEST(some_test_name, r) {
+    DEF_TEST(TestName, reporter) {
         ...
-        REPORTER_ASSERT(r, x == 15);
+        REPORTER_ASSERT(reporter, x == 15);
     }
 */
 
     }                                                                                \
     static void name(skiatest::Reporter* reporter)
 
-#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);                       \
-    }
+#define DEF_GPUTEST(name, reporter, factory)                                         \
+    static void name(skiatest::Reporter* reporter, GrContextFactory* factory);       \
+    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* reporter) SK_OVERRIDE {                     \
+                name(reporter, GetGrContextFactory());                               \
+            }                                                                        \
+        };                                                                           \
+        static TestRegistry gReg_##name##Class(name##Class::Factory);                \
+    }                                                                                \
+    static void name(skiatest::Reporter* reporter, GrContextFactory* factory)
index c7f77a7..c20ccd0 100644 (file)
@@ -5,12 +5,14 @@
  * found in the LICENSE file.
  */
 
-#include "Test.h"
 #include "SkBitmapDevice.h"
 #include "SkCanvas.h"
 #include "SkColorPriv.h"
 #include "SkMathPriv.h"
 #include "SkRegion.h"
+#include "Test.h"
+#include "TestClassDef.h"
+
 #if SK_SUPPORT_GPU
 #include "SkGpuDevice.h"
 #include "GrContextFactory.h"
@@ -358,7 +360,7 @@ static bool setupBitmap(SkBitmap* bitmap,
     return true;
 }
 
-static void WritePixelsTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
+DEF_GPUTEST(WritePixels, reporter, factory) {
     SkCanvas canvas;
 
     const SkIRect testRects[] = {
@@ -469,6 +471,3 @@ static void WritePixelsTest(skiatest::Reporter* reporter, GrContextFactory* fact
         }
     }
 }
-
-#include "TestClassDef.h"
-DEFINE_GPUTESTCLASS("WritePixels", WritePixelsTestClass, WritePixelsTest)