aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-11-15 15:48:03 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-15 22:03:07 +0000
commitdcfca431e3c350e17eedb3402cc63577cea8d4ea (patch)
treeb65ff91284663aef37e7603bbdba1fda51eb0c89 /tests
parent20800c8b1bb7181fc7d3c6af756dc4440094ac90 (diff)
Use GrContextFactories that produce a single GrContext in unit tests.
This is to alleviate problems due to the command buffer getting bent out of shape when the current OpenGL context is switched out from under it (because we ran a test with a native GL context). This, however is not a full solution. More changes will be required to ensure that after running each command buffer or native test we bind the null context. This does allow us to take a step in that direction without breaking anything too badly. Moreover, there is no real benefit to reusing a GrContextFactory. Modifies DEF_GPUTEST to take GrContextOptions rather than a factory to use. Tests were already using their own factories anyway. In tests that use GrContextFactory the factory instance is moved to the inner loop. Modifies gpucts and skia_test to not use persistent GrContextFactories. Change-Id: Ie7a36793545c775f2f30653ead6fec93a3d22717 Reviewed-on: https://skia-review.googlesource.com/71861 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/GLProgramsTest.cpp6
-rw-r--r--tests/GpuDrawPathTest.cpp2
-rw-r--r--tests/GpuSampleLocationsTest.cpp2
-rw-r--r--tests/GrCCPRTest.cpp8
-rw-r--r--tests/GrContextAbandonTest.cpp4
-rw-r--r--tests/GrContextFactoryTest.cpp43
-rw-r--r--tests/GrPorterDuffTest.cpp4
-rw-r--r--tests/GrTRecorderTest.cpp2
-rw-r--r--tests/ImageTest.cpp13
-rw-r--r--tests/PathRendererCacheTests.cpp6
-rw-r--r--tests/ResourceCacheTest.cpp2
-rw-r--r--tests/SurfaceSemaphoreTest.cpp13
-rw-r--r--tests/Test.h39
-rw-r--r--tests/TestTest.cpp3
-rw-r--r--tests/skia_test.cpp70
15 files changed, 98 insertions, 119 deletions
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index e0ac272009..5c97b6b9fe 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -398,7 +398,7 @@ static void test_glprograms(skiatest::Reporter* reporter, const sk_gpu_test::Con
maxLevels));
}
-DEF_GPUTEST(GLPrograms, reporter, /*factory*/) {
+DEF_GPUTEST(GLPrograms, reporter, options) {
// Set a locale that would cause shader compilation to fail because of , as decimal separator.
// skbug 3330
#ifdef SK_BUILD_FOR_WIN
@@ -408,11 +408,11 @@ DEF_GPUTEST(GLPrograms, reporter, /*factory*/) {
#endif
// We suppress prints to avoid spew
- GrContextOptions opts;
+ GrContextOptions opts = options;
opts.fSuppressPrints = true;
sk_gpu_test::GrContextFactory debugFactory(opts);
skiatest::RunWithGPUTestContexts(test_glprograms, &skiatest::IsRenderingGLContextType, reporter,
- &debugFactory);
+ opts);
}
#endif
diff --git a/tests/GpuDrawPathTest.cpp b/tests/GpuDrawPathTest.cpp
index 83641cb2ec..012dc61cb8 100644
--- a/tests/GpuDrawPathTest.cpp
+++ b/tests/GpuDrawPathTest.cpp
@@ -91,7 +91,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GpuDrawPath, reporter, ctxInfo) {
}
}
-DEF_GPUTEST(GrPathKeys, reporter, /*factory*/) {
+DEF_GPUTEST(GrPathKeys, reporter, /* options */) {
SkPaint strokePaint;
strokePaint.setStyle(SkPaint::kStroke_Style);
strokePaint.setStrokeWidth(10.f);
diff --git a/tests/GpuSampleLocationsTest.cpp b/tests/GpuSampleLocationsTest.cpp
index 36b518111f..e78006344c 100644
--- a/tests/GpuSampleLocationsTest.cpp
+++ b/tests/GpuSampleLocationsTest.cpp
@@ -184,7 +184,7 @@ private:
SamplePattern fSamplePattern;
};
-DEF_GPUTEST(GLSampleLocations, reporter, /*factory*/) {
+DEF_GPUTEST(GLSampleLocations, reporter, /* options */) {
GLTestSampleLocationsInterface testInterface;
sk_sp<GrContext> ctx(GrContext::MakeGL(&testInterface));
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index b8e3db9c10..dc1025cf6e 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -124,10 +124,10 @@ protected:
SkPath fPath;
};
-#define DEF_CCPR_TEST(name) \
- DEF_GPUTEST(name, reporter, factory) { \
- name test; \
- test.run(reporter); \
+#define DEF_CCPR_TEST(name) \
+ DEF_GPUTEST(name, reporter, /* options */) { \
+ name test; \
+ test.run(reporter); \
}
class GrCCPRTest_cleanup : public CCPRTest {
diff --git a/tests/GrContextAbandonTest.cpp b/tests/GrContextAbandonTest.cpp
index 03e45128b0..544e121e04 100644
--- a/tests/GrContextAbandonTest.cpp
+++ b/tests/GrContextAbandonTest.cpp
@@ -14,10 +14,10 @@
using namespace sk_gpu_test;
-DEF_GPUTEST(GrContext_abandonContext, reporter, /*factory*/) {
+DEF_GPUTEST(GrContext_abandonContext, reporter, options) {
for (int testType = 0; testType < 6; ++testType) {
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
- GrContextFactory testFactory;
+ GrContextFactory testFactory(options);
GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType) i;
ContextInfo info = testFactory.getContextInfo(ctxType);
if (GrContext* context = info.grContext()) {
diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp
index 1514d67717..29f68366c3 100644
--- a/tests/GrContextFactoryTest.cpp
+++ b/tests/GrContextFactoryTest.cpp
@@ -17,12 +17,12 @@
using namespace sk_gpu_test;
-DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter, /*factory*/) {
+DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter, options) {
// Test that if NVPR is requested, the context always has path rendering
// or the context creation fails.
- GrContextFactory testFactory;
- // Test that if NVPR is possible, caps are in sync.
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ GrContextFactory testFactory(options);
+ // Test that if NVPR is possible, caps are in sync.
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
GrContext* context = testFactory.get(ctxType,
GrContextFactory::ContextOverrides::kRequireNVPRSupport);
@@ -35,11 +35,11 @@ DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter,
}
}
-DEF_GPUTEST(GrContextFactory_NoPathRenderingIfNVPRDisabled, reporter, /*factory*/) {
+DEF_GPUTEST(GrContextFactory_NoPathRenderingIfNVPRDisabled, reporter, options) {
// Test that if NVPR is explicitly disabled, the context has no path rendering support.
- GrContextFactory testFactory;
for (int i = 0; i <= GrContextFactory::kLastContextType; ++i) {
+ GrContextFactory testFactory(options);
GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType)i;
GrContext* context =
testFactory.get(ctxType, GrContextFactory::ContextOverrides::kDisableNVPR);
@@ -51,13 +51,13 @@ DEF_GPUTEST(GrContextFactory_NoPathRenderingIfNVPRDisabled, reporter, /*factory*
}
}
-DEF_GPUTEST(GrContextFactory_RequiredSRGBSupport, reporter, /*factory*/) {
+DEF_GPUTEST(GrContextFactory_RequiredSRGBSupport, reporter, options) {
// Test that if sRGB support is requested, the context always has that capability
// or the context creation fails. Also test that if the creation fails, a context
// created without that flag would not have had sRGB support.
- GrContextFactory testFactory;
- // Test that if sRGB is requested, caps are in sync.
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ GrContextFactory testFactory(options);
+ // Test that if sRGB is requested, caps are in sync.
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
GrContext* context =
testFactory.get(ctxType, GrContextFactory::ContextOverrides::kRequireSRGBSupport);
@@ -73,9 +73,9 @@ DEF_GPUTEST(GrContextFactory_RequiredSRGBSupport, reporter, /*factory*/) {
}
}
-DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) {
- GrContextFactory testFactory;
+DEF_GPUTEST(GrContextFactory_abandon, reporter, options) {
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ GrContextFactory testFactory(options);
GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType) i;
ContextInfo info1 = testFactory.getContextInfo(ctxType);
if (!info1.grContext()) {
@@ -98,10 +98,9 @@ DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) {
}
}
-DEF_GPUTEST(GrContextFactory_sharedContexts, reporter, /*factory*/) {
- GrContextFactory testFactory;
-
+DEF_GPUTEST(GrContextFactory_sharedContexts, reporter, options) {
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ GrContextFactory testFactory(options);
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
ContextInfo info1 = testFactory.getContextInfo(ctxType);
if (!info1.grContext()) {
@@ -141,17 +140,17 @@ DEF_GPUTEST(GrContextFactory_sharedContexts, reporter, /*factory*/) {
}
}
-DEF_GPUTEST(GrContextFactory_executorAndTaskGroup, reporter, /*factory*/) {
- // Verify that contexts have a task group iff we supply an executor with context options
- GrContextOptions contextOptions;
- contextOptions.fExecutor = nullptr;
- GrContextFactory serialFactory(contextOptions);
+DEF_GPUTEST(GrContextFactory_executorAndTaskGroup, reporter, options) {
+ for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ // Verify that contexts have a task group iff we supply an executor with context options
+ GrContextOptions contextOptions = options;
+ contextOptions.fExecutor = nullptr;
+ GrContextFactory serialFactory(contextOptions);
- std::unique_ptr<SkExecutor> threadPool = SkExecutor::MakeFIFOThreadPool(1);
- contextOptions.fExecutor = threadPool.get();
- GrContextFactory threadedFactory(contextOptions);
+ std::unique_ptr<SkExecutor> threadPool = SkExecutor::MakeFIFOThreadPool(1);
+ contextOptions.fExecutor = threadPool.get();
+ GrContextFactory threadedFactory(contextOptions);
- for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
ContextInfo serialInfo = serialFactory.getContextInfo(ctxType);
if (GrContext* serialContext = serialInfo.grContext()) {
diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp
index 6ce0458a56..ddfcdef602 100644
--- a/tests/GrPorterDuffTest.cpp
+++ b/tests/GrPorterDuffTest.cpp
@@ -1050,8 +1050,8 @@ static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const
TEST_ASSERT(blendInfo.fWriteColor);
}
-DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) {
- GrContextOptions opts;
+DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, options) {
+ GrContextOptions opts = options;
opts.fSuppressDualSourceBlending = true;
sk_gpu_test::GrContextFactory mockFactory(opts);
GrContext* ctx = mockFactory.get(sk_gpu_test::GrContextFactory::kNullGL_ContextType);
diff --git a/tests/GrTRecorderTest.cpp b/tests/GrTRecorderTest.cpp
index 0be0f68db9..5041dd9854 100644
--- a/tests/GrTRecorderTest.cpp
+++ b/tests/GrTRecorderTest.cpp
@@ -283,7 +283,7 @@ static void test_subclasses_iters(skiatest::Reporter* reporter, Order& order,
REPORTER_ASSERT(reporter, reverseIter.previous() == !!i);
}
-DEF_GPUTEST(GrTRecorder, reporter, factory) {
+DEF_GPUTEST(GrTRecorder, reporter, /* options */) {
test_empty_back_and_pop(reporter);
test_extra_data(reporter);
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 49ef86847d..30ae635c98 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -810,11 +810,10 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_NewFromTextureRelease, reporter, c
ctxInfo.grContext()->getGpu()->deleteTestingOnlyBackendTexture(backendTexHandle);
}
-static void test_cross_context_image(skiatest::Reporter* reporter,
+static void test_cross_context_image(skiatest::Reporter* reporter, const GrContextOptions& options,
std::function<sk_sp<SkImage>(GrContext*)> imageMaker) {
- GrContextFactory testFactory;
-
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ GrContextFactory testFactory(options);
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
ContextInfo ctxInfo = testFactory.getContextInfo(ctxType);
GrContext* ctx = ctxInfo.grContext();
@@ -958,21 +957,21 @@ static void test_cross_context_image(skiatest::Reporter* reporter,
}
}
-DEF_GPUTEST(SkImage_MakeCrossContextFromEncodedRelease, reporter, /*factory*/) {
+DEF_GPUTEST(SkImage_MakeCrossContextFromEncodedRelease, reporter, options) {
sk_sp<SkData> data = GetResourceAsData("mandrill_128.png");
SkASSERT(data.get());
- test_cross_context_image(reporter, [&data](GrContext* ctx) {
+ test_cross_context_image(reporter, options, [&data](GrContext* ctx) {
return SkImage::MakeCrossContextFromEncoded(ctx, data, false, nullptr);
});
}
-DEF_GPUTEST(SkImage_MakeCrossContextFromPixmapRelease, reporter, /*factory*/) {
+DEF_GPUTEST(SkImage_MakeCrossContextFromPixmapRelease, reporter, options) {
SkBitmap bitmap;
SkPixmap pixmap;
SkAssertResult(GetResourceAsBitmap("mandrill_128.png", &bitmap) && bitmap.peekPixels(&pixmap));
- test_cross_context_image(reporter, [&pixmap](GrContext* ctx) {
+ test_cross_context_image(reporter, options, [&pixmap](GrContext* ctx) {
return SkImage::MakeCrossContextFromPixmap(ctx, pixmap, false, nullptr);
});
}
diff --git a/tests/PathRendererCacheTests.cpp b/tests/PathRendererCacheTests.cpp
index dbf01ab029..8c3ba2a46c 100644
--- a/tests/PathRendererCacheTests.cpp
+++ b/tests/PathRendererCacheTests.cpp
@@ -109,7 +109,7 @@ static void test_path(skiatest::Reporter* reporter,
}
// Test that deleting the original path invalidates the VBs cached by the tessellating path renderer
-DEF_GPUTEST(TessellatingPathRendererCacheTest, reporter, factory) {
+DEF_GPUTEST(TessellatingPathRendererCacheTest, reporter, /* options */) {
auto createPR = [](GrContext*) {
return new GrTessellatingPathRenderer();
};
@@ -130,9 +130,7 @@ DEF_GPUTEST(TessellatingPathRendererCacheTest, reporter, factory) {
}
// Test that deleting the original path invalidates the textures cached by the SW path renderer
-DEF_GPUTEST(SoftwarePathRendererCacheTest, reporter, factory) {
-// Currently disabled since the test is only passing thanks to uninteded behavior in deleting a
-// resource since we are over budget. If we increase the cache budget the test will fail
+DEF_GPUTEST(SoftwarePathRendererCacheTest, reporter, /* options */) {
auto createPR = [](GrContext* ctx) {
return new GrSoftwarePathRenderer(ctx->resourceProvider(), true);
};
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 863830aefe..0d977796cd 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -1596,7 +1596,7 @@ static void test_tags(skiatest::Reporter* reporter) {
#endif
}
-DEF_GPUTEST(ResourceCacheMisc, reporter, factory) {
+DEF_GPUTEST(ResourceCacheMisc, reporter, /* options */) {
// The below tests create their own mock contexts.
test_no_key(reporter);
test_budgeting(reporter);
diff --git a/tests/SurfaceSemaphoreTest.cpp b/tests/SurfaceSemaphoreTest.cpp
index 9b3f90429a..8ae0953d88 100644
--- a/tests/SurfaceSemaphoreTest.cpp
+++ b/tests/SurfaceSemaphoreTest.cpp
@@ -169,7 +169,7 @@ void surface_semaphore_test(skiatest::Reporter* reporter,
draw_child(reporter, childInfo2, backendImage, semaphores[1]);
}
-DEF_GPUTEST(SurfaceSemaphores, reporter, factory) {
+DEF_GPUTEST(SurfaceSemaphores, reporter, options) {
#if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC)
static constexpr auto kNativeGLType = sk_gpu_test::GrContextFactory::kGL_ContextType;
#else
@@ -188,7 +188,8 @@ DEF_GPUTEST(SurfaceSemaphores, reporter, factory) {
continue;
}
}
- sk_gpu_test::ContextInfo ctxInfo = factory->getContextInfo(
+ sk_gpu_test::GrContextFactory factory(options);
+ sk_gpu_test::ContextInfo ctxInfo = factory.getContextInfo(
contextType, sk_gpu_test::GrContextFactory::ContextOverrides::kDisableNVPR);
if (!sk_gpu_test::GrContextFactory::IsRenderingContext(contextType)) {
continue;
@@ -196,10 +197,10 @@ DEF_GPUTEST(SurfaceSemaphores, reporter, factory) {
skiatest::ReporterContext ctx(
reporter, SkString(sk_gpu_test::GrContextFactory::ContextTypeName(contextType)));
if (ctxInfo.grContext()) {
- sk_gpu_test::ContextInfo child1 = factory->getSharedContextInfo(ctxInfo.grContext(),
- 0);
- sk_gpu_test::ContextInfo child2 = factory->getSharedContextInfo(ctxInfo.grContext(),
- 1);
+ sk_gpu_test::ContextInfo child1 =
+ factory.getSharedContextInfo(ctxInfo.grContext(), 0);
+ sk_gpu_test::ContextInfo child2 =
+ factory.getSharedContextInfo(ctxInfo.grContext(), 1);
if (!child1.grContext() || !child2.grContext()) {
continue;
}
diff --git a/tests/Test.h b/tests/Test.h
index 3e344743db..fc47d25932 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -89,7 +89,7 @@ private:
Reporter* fReporter;
};
-typedef void (*TestProc)(skiatest::Reporter*, sk_gpu_test::GrContextFactory*);
+typedef void (*TestProc)(skiatest::Reporter*, const GrContextOptions&);
typedef void (*ContextOptionsProc)(GrContextOptions*);
struct Test {
@@ -106,9 +106,9 @@ struct Test {
}
}
- void run(skiatest::Reporter* r, sk_gpu_test::GrContextFactory* factory) const {
+ void run(skiatest::Reporter* r, const GrContextOptions& options) const {
TRACE_EVENT1("test", TRACE_FUNC, "name", this->name/*these are static*/);
- this->proc(r, factory);
+ this->proc(r, options);
}
};
@@ -146,8 +146,8 @@ extern bool IsGLContextType(GrContextFactoryContextType);
extern bool IsVulkanContextType(GrContextFactoryContextType);
extern bool IsRenderingGLContextType(GrContextFactoryContextType);
extern bool IsNullGLContextType(GrContextFactoryContextType);
-void RunWithGPUTestContexts(GrContextTestFn*, GrContextTypeFilterFn*,
- Reporter*, sk_gpu_test::GrContextFactory*);
+void RunWithGPUTestContexts(GrContextTestFn*, GrContextTypeFilterFn*, Reporter*,
+ const GrContextOptions&);
/** Timer provides wall-clock duration since its creation. */
class Timer {
@@ -197,30 +197,25 @@ private:
} \
} while (0)
-#define DEF_TEST(name, reporter) \
- static void test_##name(skiatest::Reporter*, sk_gpu_test::GrContextFactory*); \
- skiatest::TestRegistry name##TestRegistry( \
- skiatest::Test(#name, false, test_##name)); \
- void test_##name(skiatest::Reporter* reporter, sk_gpu_test::GrContextFactory*)
+#define DEF_TEST(name, reporter) \
+ static void test_##name(skiatest::Reporter*, const GrContextOptions&); \
+ skiatest::TestRegistry name##TestRegistry(skiatest::Test(#name, false, test_##name)); \
+ void test_##name(skiatest::Reporter* reporter, const GrContextOptions&)
-
-#define DEF_GPUTEST(name, reporter, factory) \
- static void test_##name(skiatest::Reporter*, sk_gpu_test::GrContextFactory*); \
- skiatest::TestRegistry name##TestRegistry( \
- skiatest::Test(#name, true, test_##name)); \
- void test_##name(skiatest::Reporter* reporter, sk_gpu_test::GrContextFactory* factory)
+#define DEF_GPUTEST(name, reporter, options) \
+ static void test_##name(skiatest::Reporter*, const GrContextOptions&); \
+ skiatest::TestRegistry name##TestRegistry(skiatest::Test(#name, true, test_##name)); \
+ void test_##name(skiatest::Reporter* reporter, const GrContextOptions& options)
#define DEF_GPUTEST_FOR_CONTEXTS(name, context_filter, reporter, context_info, options_filter) \
- static void test_##name(skiatest::Reporter*, \
- const sk_gpu_test::ContextInfo& context_info); \
+ static void test_##name(skiatest::Reporter*, const sk_gpu_test::ContextInfo& context_info); \
static void test_gpu_contexts_##name(skiatest::Reporter* reporter, \
- sk_gpu_test::GrContextFactory* factory) { \
- skiatest::RunWithGPUTestContexts(test_##name, context_filter, reporter, factory); \
+ const GrContextOptions& options) { \
+ skiatest::RunWithGPUTestContexts(test_##name, context_filter, reporter, options); \
} \
skiatest::TestRegistry name##TestRegistry( \
skiatest::Test(#name, true, test_gpu_contexts_##name, options_filter)); \
- void test_##name(skiatest::Reporter* reporter, \
- const sk_gpu_test::ContextInfo& context_info)
+ void test_##name(skiatest::Reporter* reporter, const sk_gpu_test::ContextInfo& context_info)
#define DEF_GPUTEST_FOR_ALL_CONTEXTS(name, reporter, context_info) \
DEF_GPUTEST_FOR_CONTEXTS(name, nullptr, reporter, context_info, nullptr)
diff --git a/tests/TestTest.cpp b/tests/TestTest.cpp
index d366bb4703..fbec68340a 100644
--- a/tests/TestTest.cpp
+++ b/tests/TestTest.cpp
@@ -18,11 +18,10 @@ DEF_TEST(TestNormal, reporter) {
REPORTER_ASSERT(reporter, reporter);
}
-// This is an example of a GPU test that uses common GrContextFactory factory to do the test.
+// This is an example of a GPU test that uses GrContextOptions to do the test.
#if SK_SUPPORT_GPU
DEF_GPUTEST(TestGpuFactory, reporter, factory) {
REPORTER_ASSERT(reporter, reporter);
- REPORTER_ASSERT(reporter, factory);
}
#endif
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index 6b7df71c28..8e4cbae67a 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -22,6 +22,8 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextFactory.h"
+#else
+struct GrContextOptions {};
#endif
using namespace skiatest;
@@ -82,38 +84,32 @@ private:
class SkTestRunnable {
public:
- SkTestRunnable(const Test& test,
- Status* status,
- GrContextFactory* grContextFactory = nullptr)
- : fTest(test), fStatus(status), fGrContextFactory(grContextFactory) {}
-
- void operator()() {
- struct TestReporter : public skiatest::Reporter {
- public:
- TestReporter() : fStats(nullptr), fError(false), fTestCount(0) {}
- void bumpTestCount() override { ++fTestCount; }
- bool allowExtendedTest() const override {
- return FLAGS_extendedTest;
- }
- bool verbose() const override { return FLAGS_veryVerbose; }
- void reportFailed(const skiatest::Failure& failure) override {
- SkDebugf("\nFAILED: %s", failure.toString().c_str());
- fError = true;
- }
- void* stats() const override { return fStats; }
- void* fStats;
- bool fError;
- int fTestCount;
- } reporter;
-
- const Timer timer;
- fTest.proc(&reporter, fGrContextFactory);
- SkMSec elapsed = timer.elapsedMsInt();
- if (reporter.fError) {
- fStatus->reportFailure();
- }
- fStatus->endTest(fTest.name, !reporter.fError, elapsed,
- reporter.fTestCount);
+ SkTestRunnable(const Test& test, Status* status) : fTest(test), fStatus(status) {}
+
+ void operator()() {
+ struct TestReporter : public skiatest::Reporter {
+ public:
+ TestReporter() : fStats(nullptr), fError(false), fTestCount(0) {}
+ void bumpTestCount() override { ++fTestCount; }
+ bool allowExtendedTest() const override { return FLAGS_extendedTest; }
+ bool verbose() const override { return FLAGS_veryVerbose; }
+ void reportFailed(const skiatest::Failure& failure) override {
+ SkDebugf("\nFAILED: %s", failure.toString().c_str());
+ fError = true;
+ }
+ void* stats() const override { return fStats; }
+ void* fStats;
+ bool fError;
+ int fTestCount;
+ } reporter;
+
+ const Timer timer;
+ fTest.proc(&reporter, GrContextOptions());
+ SkMSec elapsed = timer.elapsedMsInt();
+ if (reporter.fError) {
+ fStatus->reportFailure();
+ }
+ fStatus->endTest(fTest.name, !reporter.fError, elapsed, reporter.fTestCount);
}
private:
@@ -233,17 +229,9 @@ int main(int argc, char** argv) {
}
}
- GrContextFactory* grContextFactoryPtr = nullptr;
-#if SK_SUPPORT_GPU
- // Give GPU tests a context factory if that makes sense on this machine.
- GrContextFactory grContextFactory;
- grContextFactoryPtr = &grContextFactory;
-
-#endif
-
// Run GPU tests on this thread.
for (int i = 0; i < gpuTests.count(); i++) {
- SkTestRunnable(*gpuTests[i], &status, grContextFactoryPtr)();
+ SkTestRunnable(*gpuTests[i], &status)();
}
// Block until threaded tests finish.