From 4ee16bfaedb14aff8cf102f1f0722ff2529a9699 Mon Sep 17 00:00:00 2001 From: "tfarina@chromium.org" Date: Fri, 10 Jan 2014 22:08:27 +0000 Subject: [PATCH] Add a DEF_GPUTEST() macro. 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 --- tests/BlurTest.cpp | 11 ++++------- tests/ClipCacheTest.cpp | 9 ++------- tests/DeferredCanvasTest.cpp | 8 +++----- tests/GLInterfaceValidation.cpp | 13 +++---------- tests/GLProgramsTest.cpp | 6 ++---- tests/GpuBitmapCopyTest.cpp | 6 ++---- tests/GpuColorFilterTest.cpp | 12 +++--------- tests/GpuDrawPathTest.cpp | 10 +++------- tests/GrContextFactoryTest.cpp | 23 +++++++++-------------- tests/GrDrawTargetTest.cpp | 6 ++---- tests/GrSurfaceTest.cpp | 14 ++++---------- tests/PremulAlphaRoundTripTest.cpp | 10 ++++------ tests/ReadPixelsTest.cpp | 9 ++++----- tests/ReadWriteAlphaTest.cpp | 11 ++++------- tests/ResourceCacheTest.cpp | 13 ++++--------- tests/SurfaceTest.cpp | 8 +++----- tests/TestClassDef.h | 32 +++++++++++++++++--------------- tests/WritePixelsTest.cpp | 9 ++++----- 18 files changed, 77 insertions(+), 133 deletions(-) diff --git a/tests/BlurTest.cpp b/tests/BlurTest.cpp index a1eaca9..cfcc103 100644 --- a/tests/BlurTest.cpp +++ b/tests/BlurTest.cpp @@ -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) diff --git a/tests/ClipCacheTest.cpp b/tests/ClipCacheTest.cpp index 070f8eb..84564c4 100644 --- a/tests/ClipCacheTest.cpp +++ b/tests/ClipCacheTest.cpp @@ -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(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 diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp index 45d0292..132736e 100644 --- a/tests/DeferredCanvasTest.cpp +++ b/tests/DeferredCanvasTest.cpp @@ -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) diff --git a/tests/GLInterfaceValidation.cpp b/tests/GLInterfaceValidation.cpp index a4709ba..792ed03 100755 --- a/tests/GLInterfaceValidation.cpp +++ b/tests/GLInterfaceValidation.cpp @@ -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 diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 7e55cc7..10d56fe 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -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(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! diff --git a/tests/GpuBitmapCopyTest.cpp b/tests/GpuBitmapCopyTest.cpp index a1434dc..9d1a527 100644 --- a/tests/GpuBitmapCopyTest.cpp +++ b/tests/GpuBitmapCopyTest.cpp @@ -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 diff --git a/tests/GpuColorFilterTest.cpp b/tests/GpuColorFilterTest.cpp index 9fb1c77..0d8acc5 100644 --- a/tests/GpuColorFilterTest.cpp +++ b/tests/GpuColorFilterTest.cpp @@ -12,10 +12,9 @@ #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(type); @@ -123,9 +122,4 @@ static void TestGpuColorFilter(skiatest::Reporter* reporter, GrContextFactory* f } } -} - -#include "TestClassDef.h" -DEFINE_GPUTESTCLASS("GpuColorFilter", TestGpuColorFilterClass, TestGpuColorFilter) - #endif diff --git a/tests/GpuDrawPathTest.cpp b/tests/GpuDrawPathTest.cpp index fa844d0..f2a321f 100644 --- a/tests/GpuDrawPathTest.cpp +++ b/tests/GpuDrawPathTest.cpp @@ -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 diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp index 02b8c28..9ffbd64 100644 --- a/tests/GrContextFactoryTest.cpp +++ b/tests/GrContextFactoryTest.cpp @@ -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 diff --git a/tests/GrDrawTargetTest.cpp b/tests/GrDrawTargetTest.cpp index f2bcdc4..78d9025 100644 --- a/tests/GrDrawTargetTest.cpp +++ b/tests/GrDrawTargetTest.cpp @@ -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(type); @@ -33,7 +34,4 @@ static void TestGrDrawTarget(skiatest::Reporter* reporter, GrContextFactory* fac } } -#include "TestClassDef.h" -DEFINE_GPUTESTCLASS("GrDrawTarget", TestGrDrawTargetClass, TestGrDrawTarget) - #endif diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 3fe071c..07bf0ce 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -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 diff --git a/tests/PremulAlphaRoundTripTest.cpp b/tests/PremulAlphaRoundTripTest.cpp index 4a90c45..c963e23 100644 --- a/tests/PremulAlphaRoundTripTest.cpp +++ b/tests/PremulAlphaRoundTripTest.cpp @@ -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 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) diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp index 6e363fc..85846e7 100644 --- a/tests/ReadPixelsTest.cpp +++ b/tests/ReadPixelsTest.cpp @@ -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) diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp index fb177df..47a5f5a 100644 --- a/tests/ReadWriteAlphaTest.cpp +++ b/tests/ReadWriteAlphaTest.cpp @@ -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(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 diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index 1bb6766..6707ebf 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -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(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 diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 5e95017..b580999 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -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) diff --git a/tests/TestClassDef.h b/tests/TestClassDef.h index f874acc..8351ba7 100644 --- a/tests/TestClassDef.h +++ b/tests/TestClassDef.h @@ -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); } */ @@ -31,16 +31,18 @@ } \ 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) diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp index c7f77a7..c20ccd0 100644 --- a/tests/WritePixelsTest.cpp +++ b/tests/WritePixelsTest.cpp @@ -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) -- 2.7.4