diff options
-rw-r--r-- | include/core/SkString.h | 3 | ||||
-rw-r--r-- | tests/CanvasStateTest.cpp | 2 | ||||
-rw-r--r-- | tests/CanvasTest.cpp | 51 | ||||
-rw-r--r-- | tests/ClipStackTest.cpp | 65 | ||||
-rw-r--r-- | tests/DrawPathTest.cpp | 4 | ||||
-rw-r--r-- | tests/FontHostTest.cpp | 2 | ||||
-rw-r--r-- | tests/FontNamesTest.cpp | 36 | ||||
-rw-r--r-- | tests/GrSurfaceTest.cpp | 14 | ||||
-rw-r--r-- | tests/ImageFilterTest.cpp | 6 | ||||
-rw-r--r-- | tests/PaintBreakTextTest.cpp | 20 | ||||
-rw-r--r-- | tests/PathTest.cpp | 6 | ||||
-rw-r--r-- | tests/ReadWriteAlphaTest.cpp | 8 | ||||
-rw-r--r-- | tests/RecordingXfermodeTest.cpp | 2 | ||||
-rw-r--r-- | tests/SurfaceTest.cpp | 8 | ||||
-rw-r--r-- | tests/Test.h | 19 |
15 files changed, 118 insertions, 128 deletions
diff --git a/include/core/SkString.h b/include/core/SkString.h index b96efe730b..3d2373758d 100644 --- a/include/core/SkString.h +++ b/include/core/SkString.h @@ -272,6 +272,9 @@ private: /// Creates a new string and writes into it using a printf()-style format. SkString SkStringPrintf(const char* format, ...); +/// This makes it easier to write a caller as a VAR_ARGS function where the format string is +/// optional. +static inline SkString SkStringPrintf() { return SkString(); } // Specialized to take advantage of SkString's fast swap path. The unspecialized function is // declared in SkTypes.h and called by SkTSort. diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp index 6f2ebf8833..2e78d15866 100644 --- a/tests/CanvasStateTest.cpp +++ b/tests/CanvasStateTest.cpp @@ -40,7 +40,7 @@ public: OpenLibResult(skiatest::Reporter* reporter) { if (FLAGS_library.count() == 1) { fHandle = dlopen(FLAGS_library[0], RTLD_LAZY | RTLD_LOCAL); - REPORTER_ASSERT_MESSAGE(reporter, fHandle != nullptr, "Failed to open library!"); + REPORTER_ASSERT(reporter, fHandle != nullptr, "Failed to open library!"); } else { fHandle = nullptr; } diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp index e83777ba96..f027071b53 100644 --- a/tests/CanvasTest.cpp +++ b/tests/CanvasTest.cpp @@ -24,7 +24,7 @@ * { * canvas->someCanvasAPImethod(); * (...) - * REPORTER_ASSERT_MESSAGE(reporter, (...), \ + * REPORTER_ASSERT(reporter, (...), \ * testStep->assertMessage()); * } * @@ -355,14 +355,12 @@ static void NAME##TestStep(SkCanvas* canvas, const TestData& d, \ } \ TEST_STEP(NAME, NAME##TestStep ) -#define SIMPLE_TEST_STEP_WITH_ASSERT(NAME, CALL) \ -static void NAME##TestStep(SkCanvas* canvas, const TestData& d, \ - skiatest::Reporter*, CanvasTestStep* testStep) { \ - REPORTER_ASSERT_MESSAGE(reporter, canvas-> CALL , \ - testStep->assertMessage()); \ -} \ -TEST_STEP(NAME, NAME##TestStep ) - +#define SIMPLE_TEST_STEP_WITH_ASSERT(NAME, CALL) \ + static void NAME##TestStep(SkCanvas* canvas, const TestData& d, skiatest::Reporter*, \ + CanvasTestStep* testStep) { \ + REPORTER_ASSERT(reporter, canvas->CALL, testStep->assertMessage()); \ + } \ + TEST_STEP(NAME, NAME##TestStep) /////////////////////////////////////////////////////////////////////////////// // Basic test steps for most virtual methods in SkCanvas that draw or affect @@ -389,11 +387,10 @@ static void SaveMatrixClipStep(SkCanvas* canvas, const TestData& d, canvas->translate(SkIntToScalar(1), SkIntToScalar(2)); canvas->clipRegion(d.fRegion); canvas->restore(); - REPORTER_ASSERT_MESSAGE(reporter, canvas->getSaveCount() == saveCount, - testStep->assertMessage()); - REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalMatrix().isIdentity(), - testStep->assertMessage()); -// REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() != kTestRegion, testStep->assertMessage()); + REPORTER_ASSERT(reporter, canvas->getSaveCount() == saveCount, testStep->assertMessage()); + REPORTER_ASSERT(reporter, canvas->getTotalMatrix().isIdentity(), testStep->assertMessage()); + // REPORTER_ASSERT(reporter, canvas->getTotalClip() != kTestRegion, + // testStep->assertMessage()); } TEST_STEP(SaveMatrixClip, SaveMatrixClipStep); @@ -402,8 +399,7 @@ static void SaveLayerStep(SkCanvas* canvas, const TestData& d, int saveCount = canvas->getSaveCount(); canvas->saveLayer(nullptr, nullptr); canvas->restore(); - REPORTER_ASSERT_MESSAGE(reporter, canvas->getSaveCount() == saveCount, - testStep->assertMessage()); + REPORTER_ASSERT(reporter, canvas->getSaveCount() == saveCount, testStep->assertMessage()); } TEST_STEP(SaveLayer, SaveLayerStep); @@ -412,8 +408,7 @@ static void BoundedSaveLayerStep(SkCanvas* canvas, const TestData& d, int saveCount = canvas->getSaveCount(); canvas->saveLayer(&d.fRect, nullptr); canvas->restore(); - REPORTER_ASSERT_MESSAGE(reporter, canvas->getSaveCount() == saveCount, - testStep->assertMessage()); + REPORTER_ASSERT(reporter, canvas->getSaveCount() == saveCount, testStep->assertMessage()); } TEST_STEP(BoundedSaveLayer, BoundedSaveLayerStep); @@ -422,8 +417,7 @@ static void PaintSaveLayerStep(SkCanvas* canvas, const TestData& d, int saveCount = canvas->getSaveCount(); canvas->saveLayer(nullptr, &d.fPaint); canvas->restore(); - REPORTER_ASSERT_MESSAGE(reporter, canvas->getSaveCount() == saveCount, - testStep->assertMessage()); + REPORTER_ASSERT(reporter, canvas->getSaveCount() == saveCount, testStep->assertMessage()); } TEST_STEP(PaintSaveLayer, PaintSaveLayerStep); @@ -484,21 +478,20 @@ static void SaveRestoreTestStep(SkCanvas* canvas, const TestData& d, skiatest::Reporter* reporter, CanvasTestStep* testStep) { int baseSaveCount = canvas->getSaveCount(); int n = canvas->save(); - REPORTER_ASSERT_MESSAGE(reporter, baseSaveCount == n, testStep->assertMessage()); - REPORTER_ASSERT_MESSAGE(reporter, baseSaveCount + 1 == canvas->getSaveCount(), - testStep->assertMessage()); + REPORTER_ASSERT(reporter, baseSaveCount == n, testStep->assertMessage()); + REPORTER_ASSERT(reporter, baseSaveCount + 1 == canvas->getSaveCount(), + testStep->assertMessage()); canvas->save(); canvas->save(); - REPORTER_ASSERT_MESSAGE(reporter, baseSaveCount + 3 == canvas->getSaveCount(), - testStep->assertMessage()); + REPORTER_ASSERT(reporter, baseSaveCount + 3 == canvas->getSaveCount(), + testStep->assertMessage()); canvas->restoreToCount(baseSaveCount + 1); - REPORTER_ASSERT_MESSAGE(reporter, baseSaveCount + 1 == canvas->getSaveCount(), - testStep->assertMessage()); + REPORTER_ASSERT(reporter, baseSaveCount + 1 == canvas->getSaveCount(), + testStep->assertMessage()); // should this pin to 1, or be a no-op, or crash? canvas->restoreToCount(0); - REPORTER_ASSERT_MESSAGE(reporter, 1 == canvas->getSaveCount(), - testStep->assertMessage()); + REPORTER_ASSERT(reporter, 1 == canvas->getSaveCount(), testStep->assertMessage()); } TEST_STEP(SaveRestore, SaveRestoreTestStep); diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp index c078422868..fb46681f0f 100644 --- a/tests/ClipStackTest.cpp +++ b/tests/ClipStackTest.cpp @@ -1033,17 +1033,17 @@ static void test_reduced_clip_stack(skiatest::Reporter* reporter) { queryBounds.outset(kBounds.width() / 2, kBounds.height() / 2); const GrReducedClip* reduced = new (storage.get()) GrReducedClip(stack, queryBounds, caps); - REPORTER_ASSERT_MESSAGE(reporter, - reduced->maskElements().isEmpty() || + REPORTER_ASSERT(reporter, + reduced->maskElements().isEmpty() || SkClipStack::kInvalidGenID != reduced->maskGenID(), - testCase.c_str()); + testCase.c_str()); if (!reduced->maskElements().isEmpty()) { - REPORTER_ASSERT_MESSAGE(reporter, reduced->hasScissor(), testCase.c_str()); + REPORTER_ASSERT(reporter, reduced->hasScissor(), testCase.c_str()); SkRect stackBounds; SkClipStack::BoundsType stackBoundsType; stack.getBounds(&stackBounds, &stackBoundsType); - REPORTER_ASSERT_MESSAGE(reporter, reduced->maskRequiresAA() == doAA, testCase.c_str()); + REPORTER_ASSERT(reporter, reduced->maskRequiresAA() == doAA, testCase.c_str()); } // Build a new clip stack based on the reduced clip elements @@ -1069,7 +1069,7 @@ static void test_reduced_clip_stack(skiatest::Reporter* reporter) { SkRegion reducedRegion; set_region_to_stack(reducedStack, scissor, &reducedRegion); - REPORTER_ASSERT_MESSAGE(reporter, region == reducedRegion, testCase.c_str()); + REPORTER_ASSERT(reporter, region == reducedRegion, testCase.c_str()); reduced->~GrReducedClip(); } @@ -1240,35 +1240,33 @@ static void test_aa_query(skiatest::Reporter* reporter, const SkString& testName switch (expectedMethod) { case ClipMethod::kSkipDraw: SkASSERT(0 == numExpectedElems); - REPORTER_ASSERT_MESSAGE(reporter, - reduced.maskElements().isEmpty(), testName.c_str()); - REPORTER_ASSERT_MESSAGE(reporter, - GrReducedClip::InitialState::kAllOut == reduced.initialState(), - testName.c_str()); + REPORTER_ASSERT(reporter, reduced.maskElements().isEmpty(), testName.c_str()); + REPORTER_ASSERT(reporter, + GrReducedClip::InitialState::kAllOut == reduced.initialState(), + testName.c_str()); return; case ClipMethod::kIgnoreClip: SkASSERT(0 == numExpectedElems); - REPORTER_ASSERT_MESSAGE(reporter, - !reduced.hasScissor() || - GrClip::IsInsideClip(reduced.scissor(), queryBounds), - testName.c_str()); - REPORTER_ASSERT_MESSAGE(reporter, reduced.maskElements().isEmpty(), testName.c_str()); - REPORTER_ASSERT_MESSAGE(reporter, - GrReducedClip::InitialState::kAllIn == reduced.initialState(), - testName.c_str()); + REPORTER_ASSERT( + reporter, + !reduced.hasScissor() || GrClip::IsInsideClip(reduced.scissor(), queryBounds), + testName.c_str()); + REPORTER_ASSERT(reporter, reduced.maskElements().isEmpty(), testName.c_str()); + REPORTER_ASSERT(reporter, + GrReducedClip::InitialState::kAllIn == reduced.initialState(), + testName.c_str()); return; case ClipMethod::kScissor: { SkASSERT(SkClipStack::kNormal_BoundsType == stackBoundsType); SkASSERT(0 == numExpectedElems); SkIRect expectedScissor; stackBounds.round(&expectedScissor); - REPORTER_ASSERT_MESSAGE(reporter, reduced.maskElements().isEmpty(), testName.c_str()); - REPORTER_ASSERT_MESSAGE(reporter, reduced.hasScissor(), testName.c_str()); - REPORTER_ASSERT_MESSAGE(reporter, expectedScissor == reduced.scissor(), - testName.c_str()); - REPORTER_ASSERT_MESSAGE(reporter, - GrReducedClip::InitialState::kAllIn == reduced.initialState(), - testName.c_str()); + REPORTER_ASSERT(reporter, reduced.maskElements().isEmpty(), testName.c_str()); + REPORTER_ASSERT(reporter, reduced.hasScissor(), testName.c_str()); + REPORTER_ASSERT(reporter, expectedScissor == reduced.scissor(), testName.c_str()); + REPORTER_ASSERT(reporter, + GrReducedClip::InitialState::kAllIn == reduced.initialState(), + testName.c_str()); return; } case ClipMethod::kAAElements: { @@ -1276,14 +1274,13 @@ static void test_aa_query(skiatest::Reporter* reporter, const SkString& testName if (SkClipStack::kNormal_BoundsType == stackBoundsType) { SkAssertResult(expectedClipIBounds.intersect(GrClip::GetPixelIBounds(stackBounds))); } - REPORTER_ASSERT_MESSAGE(reporter, numExpectedElems == reduced.maskElements().count(), - testName.c_str()); - REPORTER_ASSERT_MESSAGE(reporter, reduced.hasScissor(), testName.c_str()); - REPORTER_ASSERT_MESSAGE(reporter, expectedClipIBounds == reduced.scissor(), - testName.c_str()); - REPORTER_ASSERT_MESSAGE(reporter, - reduced.maskElements().isEmpty() || reduced.maskRequiresAA(), - testName.c_str()); + REPORTER_ASSERT(reporter, numExpectedElems == reduced.maskElements().count(), + testName.c_str()); + REPORTER_ASSERT(reporter, reduced.hasScissor(), testName.c_str()); + REPORTER_ASSERT(reporter, expectedClipIBounds == reduced.scissor(), testName.c_str()); + REPORTER_ASSERT(reporter, + reduced.maskElements().isEmpty() || reduced.maskRequiresAA(), + testName.c_str()); break; } } diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp index 3893981c00..0682319a01 100644 --- a/tests/DrawPathTest.cpp +++ b/tests/DrawPathTest.cpp @@ -29,7 +29,7 @@ static void test_big_aa_rect(skiatest::Reporter* reporter) { if (surf->readPixels(output, x, y)) { REPORTER_ASSERT(reporter, 0 == pixel[0]); } else { - REPORTER_ASSERT_MESSAGE(reporter, false, "readPixels failed"); + REPORTER_ASSERT(reporter, false, "readPixels failed"); } SkPaint paint; @@ -44,7 +44,7 @@ static void test_big_aa_rect(skiatest::Reporter* reporter) { // appear the same. REPORTER_ASSERT(reporter, 0xFFFFFFFF == pixel[0]); } else { - REPORTER_ASSERT_MESSAGE(reporter, false, "readPixels failed"); + REPORTER_ASSERT(reporter, false, "readPixels failed"); } } diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp index 3285198931..fc1b53d81c 100644 --- a/tests/FontHostTest.cpp +++ b/tests/FontHostTest.cpp @@ -107,7 +107,7 @@ static void test_charsToGlyphs(skiatest::Reporter* reporter, const sk_sp<SkTypef SkString a; a.appendf("%s, paintGlyphIds[%d] = %d, faceGlyphIds[%d] = %d, face = %s", test.name, i, (int)paintGlyphIds[i], i, (int)faceGlyphIds[i], name.c_str()); - REPORTER_ASSERT_MESSAGE(reporter, paintGlyphIds[i] == faceGlyphIds[i], a.c_str()); + REPORTER_ASSERT(reporter, paintGlyphIds[i] == faceGlyphIds[i], a.c_str()); } } } diff --git a/tests/FontNamesTest.cpp b/tests/FontNamesTest.cpp index e5dce32a1a..3218b29e52 100644 --- a/tests/FontNamesTest.cpp +++ b/tests/FontNamesTest.cpp @@ -115,26 +115,22 @@ static void test_synthetic(skiatest::Reporter* reporter, bool verbose) { SkOTTableName::Iterator::Record record; size_t nameIndex = 0; while (nameIndex < test[i].nameCount && iter.next(record)) { - REPORTER_ASSERT_MESSAGE(reporter, - strcmp(test[i].names[nameIndex].name, record.name.c_str()) == 0, - "Name did not match." - ); + REPORTER_ASSERT(reporter, + strcmp(test[i].names[nameIndex].name, record.name.c_str()) == 0, + "Name did not match."); - REPORTER_ASSERT_MESSAGE(reporter, - strcmp(test[i].names[nameIndex].language, record.language.c_str()) == 0, - "Language did not match." - ); + REPORTER_ASSERT(reporter, + strcmp(test[i].names[nameIndex].language, record.language.c_str()) == 0, + "Language did not match."); //printf("%s <%s>\n", record.name.c_str(), record.language.c_str()); ++nameIndex; } - REPORTER_ASSERT_MESSAGE(reporter, nameIndex == test[i].nameCount, - "Fewer names than expected."); + REPORTER_ASSERT(reporter, nameIndex == test[i].nameCount, "Fewer names than expected."); - REPORTER_ASSERT_MESSAGE(reporter, !iter.next(record), - "More names than expected."); + REPORTER_ASSERT(reporter, !iter.next(record), "More names than expected."); } } @@ -183,10 +179,10 @@ static void test_systemfonts(skiatest::Reporter* reporter, bool verbose) { SkOTTableName::Iterator familyNameIter(*((SkOTTableName*)nameTableData.get()), SkOTTableName::Record::NameID::Predefined::FontFamilyName); while (familyNameIter.next(record)) { - REPORTER_ASSERT_MESSAGE(reporter, - SkOTTableName::Record::NameID::Predefined::FontFamilyName == record.type, - "Requested family name, got something else." - ); + REPORTER_ASSERT( + reporter, + SkOTTableName::Record::NameID::Predefined::FontFamilyName == record.type, + "Requested family name, got something else."); if (verbose) { SkDebugf("{%s} <%s>\n", record.name.c_str(), record.language.c_str()); } @@ -195,10 +191,10 @@ static void test_systemfonts(skiatest::Reporter* reporter, bool verbose) { SkOTTableName::Iterator styleNameIter(*((SkOTTableName*)nameTableData.get()), SkOTTableName::Record::NameID::Predefined::FontSubfamilyName); while (styleNameIter.next(record)) { - REPORTER_ASSERT_MESSAGE(reporter, - SkOTTableName::Record::NameID::Predefined::FontSubfamilyName == record.type, - "Requested subfamily name, got something else." - ); + REPORTER_ASSERT( + reporter, + SkOTTableName::Record::NameID::Predefined::FontSubfamilyName == record.type, + "Requested subfamily name, got something else."); if (verbose) { SkDebugf("{{%s}} <%s>\n", record.name.c_str(), record.language.c_str()); } diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 72a92a709d..d1385b826c 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -123,7 +123,9 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) { desc.fSampleCnt = 0; sk_sp<GrSurface> tex = resourceProvider->createTexture(desc, SkBudgeted::kNo); - REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigTexturable(desc.fConfig)); + bool ict = caps->isConfigTexturable(desc.fConfig); + REPORTER_ASSERT(reporter, SkToBool(tex) == ict, + "config:%d, tex:%d, isConfigTexturable:%d", config, SkToBool(tex), ict); size_t rowBytes = desc.fWidth * GrBytesPerPixel(desc.fConfig); for (int i = 0; i < levelCount; ++i) { @@ -141,11 +143,17 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) { desc.fFlags = kRenderTarget_GrSurfaceFlag; tex = resourceProvider->createTexture(desc, SkBudgeted::kNo); - REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigRenderable(config, false)); + bool icr = caps->isConfigRenderable(config, false); + REPORTER_ASSERT(reporter, SkToBool(tex) == icr, + "config:%d, tex:%d, isConfigRenderable(false):%d", config, + SkToBool(tex), icr); desc.fSampleCnt = 4; tex = resourceProvider->createTexture(desc, SkBudgeted::kNo); - REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigRenderable(config, true)); + icr = caps->isConfigRenderable(config, true); + REPORTER_ASSERT(reporter, SkToBool(tex) == icr, + "config:%d, tex:%d, isConfigRenderable(true):%d", config, SkToBool(tex), + icr); } } } diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp index 8aa3190bcd..1d9b585128 100644 --- a/tests/ImageFilterTest.cpp +++ b/tests/ImageFilterTest.cpp @@ -570,8 +570,8 @@ static void test_crop_rects(skiatest::Reporter* reporter, SkImageFilter::OutputProperties noColorSpace(nullptr); SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr, noColorSpace); sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset)); - REPORTER_ASSERT_MESSAGE(reporter, resultImg, filters.getName(i)); - REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, filters.getName(i)); + REPORTER_ASSERT(reporter, resultImg, filters.getName(i)); + REPORTER_ASSERT(reporter, offset.fX == 20 && offset.fY == 30, filters.getName(i)); } } @@ -776,7 +776,7 @@ DEF_TEST(ImageFilterDrawTiled, reporter) { untiledCanvas.flush(); tiledCanvas.flush(); if (!sk_tool_utils::equal_pixels(untiledResult, tiledResult, 1)) { - REPORTER_ASSERT_MESSAGE(reporter, false, filters.getName(i)); + REPORTER_ASSERT(reporter, false, filters.getName(i)); break; } } diff --git a/tests/PaintBreakTextTest.cpp b/tests/PaintBreakTextTest.cpp index b716c60c99..d0b9c0827d 100644 --- a/tests/PaintBreakTextTest.cpp +++ b/tests/PaintBreakTextTest.cpp @@ -23,18 +23,18 @@ static void test_monotonic(skiatest::Reporter* reporter, SkScalar m; const size_t n = paint.breakText(text, length, w, &m); - REPORTER_ASSERT_MESSAGE(reporter, n <= length, msg); - REPORTER_ASSERT_MESSAGE(reporter, m <= width, msg); + REPORTER_ASSERT(reporter, n <= length, msg); + REPORTER_ASSERT(reporter, m <= width, msg); if (n == 0) { - REPORTER_ASSERT_MESSAGE(reporter, m == 0, msg); + REPORTER_ASSERT(reporter, m == 0, msg); } else { // now assert that we're monotonic if (n == nn) { - REPORTER_ASSERT_MESSAGE(reporter, m == mm, msg); + REPORTER_ASSERT(reporter, m == mm, msg); } else { - REPORTER_ASSERT_MESSAGE(reporter, n > nn, msg); - REPORTER_ASSERT_MESSAGE(reporter, m > mm, msg); + REPORTER_ASSERT(reporter, n > nn, msg); + REPORTER_ASSERT(reporter, m > mm, msg); } } nn = n; @@ -52,8 +52,8 @@ static void test_eq_measure_text(skiatest::Reporter* reporter, SkScalar mm; const size_t length2 = paint.breakText(text, length, width, &mm); - REPORTER_ASSERT_MESSAGE(reporter, length2 == length, msg); - REPORTER_ASSERT_MESSAGE(reporter, mm == width, msg); + REPORTER_ASSERT(reporter, length2 == length, msg); + REPORTER_ASSERT(reporter, mm == width, msg); } static void test_long_text(skiatest::Reporter* reporter, @@ -68,8 +68,8 @@ static void test_long_text(skiatest::Reporter* reporter, SkScalar mm; const size_t length = paint.breakText(text, kSize, width, &mm); - REPORTER_ASSERT_MESSAGE(reporter, length == kSize, msg); - REPORTER_ASSERT_MESSAGE(reporter, mm == width, msg); + REPORTER_ASSERT(reporter, length == kSize, msg); + REPORTER_ASSERT(reporter, mm == width, msg); } DEF_TEST(PaintBreakText, reporter) { diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp index 037bda781d..984ec41bcb 100644 --- a/tests/PathTest.cpp +++ b/tests/PathTest.cpp @@ -987,13 +987,13 @@ static void test_poly(skiatest::Reporter* reporter, const SkPath& path, srcPts++; break; case SkPath::kQuad_Verb: - REPORTER_ASSERT_MESSAGE(reporter, false, "unexpected quad verb"); + REPORTER_ASSERT(reporter, false, "unexpected quad verb"); break; case SkPath::kConic_Verb: - REPORTER_ASSERT_MESSAGE(reporter, false, "unexpected conic verb"); + REPORTER_ASSERT(reporter, false, "unexpected conic verb"); break; case SkPath::kCubic_Verb: - REPORTER_ASSERT_MESSAGE(reporter, false, "unexpected cubic verb"); + REPORTER_ASSERT(reporter, false, "unexpected cubic verb"); break; case SkPath::kClose_Verb: REPORTER_ASSERT(reporter, !firstTime); diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp index 00891c1677..57739ccda6 100644 --- a/tests/ReadWriteAlphaTest.cpp +++ b/tests/ReadWriteAlphaTest.cpp @@ -84,7 +84,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { // upload the texture (do per-rowbytes iteration because we may overwrite below). bool result = sContext->writePixels(ii, alphaData, 0, 0, 0); - REPORTER_ASSERT_MESSAGE(reporter, result, "Initial A8 writePixels failed"); + REPORTER_ASSERT(reporter, result, "Initial A8 writePixels failed"); size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE; std::unique_ptr<uint8_t[]> readback(new uint8_t[nonZeroRowBytes * Y_SIZE]); @@ -93,7 +93,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { // read the texture back result = sContext->readPixels(ii, readback.get(), rowBytes, 0, 0); - REPORTER_ASSERT_MESSAGE(reporter, result, "Initial A8 readPixels failed"); + REPORTER_ASSERT(reporter, result, "Initial A8 readPixels failed"); // make sure the original & read back versions match SkString msg; @@ -115,7 +115,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE); result = surf->readPixels(ii, readback.get(), nonZeroRowBytes, 0, 0); - REPORTER_ASSERT_MESSAGE(reporter, result, "A8 readPixels after clear failed"); + REPORTER_ASSERT(reporter, result, "A8 readPixels after clear failed"); match = true; for (int y = 0; y < Y_SIZE && match; ++y) { @@ -190,7 +190,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { // read the texture back bool result = sContext->readPixels(dstInfo, readback.get(), rowBytes, 0, 0); - REPORTER_ASSERT_MESSAGE(reporter, result, "8888 readPixels failed"); + REPORTER_ASSERT(reporter, result, "8888 readPixels failed"); // make sure the original & read back versions match SkString msg; diff --git a/tests/RecordingXfermodeTest.cpp b/tests/RecordingXfermodeTest.cpp index 25e99ba23d..87a8f8008d 100644 --- a/tests/RecordingXfermodeTest.cpp +++ b/tests/RecordingXfermodeTest.cpp @@ -168,6 +168,6 @@ DEF_TEST(SkRecordingAccuracyXfermode, reporter) { } #if !FINEGRAIN - REPORTER_ASSERT_MESSAGE(reporter, 0 == numErrors, errors.c_str()); + REPORTER_ASSERT(reporter, 0 == numErrors, errors.c_str()); #endif } diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 9827bcf913..471953b373 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -856,14 +856,14 @@ static void test_surface_creation_and_snapshot_with_color_space( (f16Support || kRGBA_F16_SkColorType != testConfig.fColorType); auto surface(surfaceMaker(info)); - REPORTER_ASSERT_MESSAGE(reporter, SkToBool(surface) == shouldWork, fullTestName.c_str()); + REPORTER_ASSERT(reporter, SkToBool(surface) == shouldWork, fullTestName.c_str()); if (shouldWork && surface) { sk_sp<SkImage> image(surface->makeImageSnapshot()); - REPORTER_ASSERT_MESSAGE(reporter, image, testConfig.fDescription); + REPORTER_ASSERT(reporter, image, testConfig.fDescription); SkColorSpace* imageColorSpace = as_IB(image)->onImageInfo().colorSpace(); - REPORTER_ASSERT_MESSAGE(reporter, imageColorSpace == testConfig.fColorSpace.get(), - fullTestName.c_str()); + REPORTER_ASSERT(reporter, imageColorSpace == testConfig.fColorSpace.get(), + fullTestName.c_str()); } } } diff --git a/tests/Test.h b/tests/Test.h index fc47d25932..f74b98aa9c 100644 --- a/tests/Test.h +++ b/tests/Test.h @@ -123,7 +123,7 @@ typedef sk_tools::Registry<Test> TestRegistry; ... REPORTER_ASSERT(reporter, x == 15); ... - REPORTER_ASSERT_MESSAGE(reporter, x == 15, "x should be 15"); + REPORTER_ASSERT(reporter, x == 15, "x should be 15"); ... if (x != 15) { ERRORF(reporter, "x should be 15, but is %d", x); @@ -171,18 +171,11 @@ private: } // namespace skiatest -#define REPORTER_ASSERT(r, cond) \ - do { \ - if (!(cond)) { \ - REPORT_FAILURE(r, #cond, SkString()); \ - } \ - } while (0) - -#define REPORTER_ASSERT_MESSAGE(r, cond, message) \ - do { \ - if (!(cond)) { \ - REPORT_FAILURE(r, #cond, SkString(message)); \ - } \ +#define REPORTER_ASSERT(r, cond, ...) \ + do { \ + if (!(cond)) { \ + REPORT_FAILURE(r, #cond, SkStringPrintf(__VA_ARGS__)); \ + } \ } while (0) #define ERRORF(r, ...) \ |