From f7d3f6170fc8efb16a98cf8c52a32060c5c21631 Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Thu, 22 Mar 2018 15:17:42 -0400 Subject: [PATCH] tests/ImageTest: fail gracefully Change-Id: Ib3bca9d1cfda17d3b63afb7d54a14ea8e6094ac1 Reviewed-on: https://skia-review.googlesource.com/115986 Reviewed-by: Brian Salomon Commit-Queue: Hal Canary --- tests/ImageTest.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index b2a65b653b..726a06adc3 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -842,6 +842,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_NewFromTextureRelease, reporter, c } static void test_cross_context_image(skiatest::Reporter* reporter, const GrContextOptions& options, + const char* testName, std::function(GrContext*)> imageMaker) { for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) { GrContextFactory testFactory(options); @@ -875,6 +876,11 @@ static void test_cross_context_image(skiatest::Reporter* reporter, const GrConte SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128); sk_sp surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info); + if (!surface) { + ERRORF(reporter, "SkSurface::MakeRenderTarget failed for %s.", testName); + continue; + } + SkCanvas* canvas = surface->getCanvas(); // Case #2: Create image, draw, flush, free image @@ -998,7 +1004,8 @@ DEF_GPUTEST(SkImage_MakeCrossContextFromEncodedRelease, reporter, options) { sk_sp data = GetResourceAsData("images/mandrill_128.png"); SkASSERT(data.get()); - test_cross_context_image(reporter, options, [&data](GrContext* ctx) { + test_cross_context_image(reporter, options, "SkImage_MakeCrossContextFromEncodedRelease", + [&data](GrContext* ctx) { return SkImage::MakeCrossContextFromEncoded(ctx, data, false, nullptr); }); } @@ -1008,7 +1015,8 @@ DEF_GPUTEST(SkImage_MakeCrossContextFromPixmapRelease, reporter, options) { SkPixmap pixmap; SkAssertResult(GetResourceAsBitmap("images/mandrill_128.png", &bitmap) && bitmap.peekPixels(&pixmap)); - test_cross_context_image(reporter, options, [&pixmap](GrContext* ctx) { + test_cross_context_image(reporter, options, "SkImage_MakeCrossContextFromPixmapRelease", + [&pixmap](GrContext* ctx) { return SkImage::MakeCrossContextFromPixmap(ctx, pixmap, false, nullptr); }); }