From 4bcef3c40ad8d3a16bbca4ab74fa15256fb4b125 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Fri, 8 Dec 2017 11:46:09 -0500 Subject: minor cleanup to typeface serial test Bug: skia: Change-Id: I572fbcbb382a665c4e4e27a7cee718c4eaa7743d Reviewed-on: https://skia-review.googlesource.com/82801 Reviewed-by: Mike Reed Commit-Queue: Mike Reed --- tests/TextBlobTest.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'tests/TextBlobTest.cpp') diff --git a/tests/TextBlobTest.cpp b/tests/TextBlobTest.cpp index f20e3e15cf..8e272a5869 100644 --- a/tests/TextBlobTest.cpp +++ b/tests/TextBlobTest.cpp @@ -11,6 +11,7 @@ #include "SkTypeface.h" #include "Test.h" +#include "sk_tool_utils.h" class TextBlobTester { public: @@ -424,14 +425,15 @@ static sk_sp render(const SkTextBlob* blob) { * Then draw the new instance and assert it draws the same as the original. */ DEF_TEST(TextBlob_serialize, reporter) { - SkTextBlobBuilder builder; + sk_sp blob0 = []() { + sk_sp tf0; + sk_sp tf1 = SkTypeface::MakeFromName("Times", SkFontStyle()); - sk_sp tf0; - sk_sp tf1 = SkTypeface::MakeFromName("Times", SkFontStyle()); - - add_run(&builder, "Hello", 10, 20, tf0); - add_run(&builder, "World", 10, 40, tf1); - sk_sp blob0 = builder.make(); + SkTextBlobBuilder builder; + add_run(&builder, "Hello", 10, 20, tf0); + add_run(&builder, "World", 10, 40, tf1); + return builder.make(); + }(); SkTDArray array; sk_sp data = blob0->serialize([](SkTypeface* tf, void* ctx) { @@ -457,15 +459,6 @@ DEF_TEST(TextBlob_serialize, reporter) { sk_sp img0 = render(blob0.get()); sk_sp img1 = render(blob1.get()); if (img0 && img1) { - REPORTER_ASSERT(reporter, img0->width() == img1->width()); - REPORTER_ASSERT(reporter, img0->height() == img1->height()); - - sk_sp enc0 = img0->encodeToData(); - sk_sp enc1 = img1->encodeToData(); - REPORTER_ASSERT(reporter, enc0->equals(enc1.get())); - if (false) { // in case you want to actually see the images... - SkFILEWStream("textblob_serialize_img0.png").write(enc0->data(), enc0->size()); - SkFILEWStream("textblob_serialize_img1.png").write(enc1->data(), enc1->size()); - } + REPORTER_ASSERT(reporter, sk_tool_utils::equal_pixels(img0.get(), img1.get())); } } -- cgit v1.2.3