From 5be603c756f407f9968edbdb3840d715a06e3901 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 14 May 2024 18:37:06 -0400 Subject: [PATCH] Tests/TestImageWriter: Make test_gif() not use test_roundtrip() This allows using more detailed assertions that match the gif loader. --- Tests/LibGfx/TestImageWriter.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Tests/LibGfx/TestImageWriter.cpp b/Tests/LibGfx/TestImageWriter.cpp index 81307a244e555e..573a8d6cbd8663 100644 --- a/Tests/LibGfx/TestImageWriter.cpp +++ b/Tests/LibGfx/TestImageWriter.cpp @@ -113,14 +113,20 @@ TEST_CASE(test_bmp) TEST_CASE(test_gif) { - // We only support grayscale and non-animated images yet auto bitmap = TRY_OR_FAIL(create_test_rgb_bitmap()); - // Convert bitmap to grayscale + // We only support grayscale and non-animated images at the moment - convert bitmap to grayscale. for (auto& argb : *bitmap) argb = Color::from_argb(argb).to_grayscale().value(); - TRY_OR_FAIL((test_roundtrip(bitmap, true))); + auto encoded_bitmap = TRY_OR_FAIL((encode_bitmap(bitmap))); + auto decoder = TRY_OR_FAIL(Gfx::GIFImageDecoderPlugin::create(encoded_bitmap)); + + EXPECT_EQ(decoder->size(), bitmap->size()); + EXPECT_EQ(decoder->frame_count(), 1u); + EXPECT(!decoder->is_animated()); + + expect_bitmaps_equal(*TRY_OR_FAIL(decoder->frame(0)).image, bitmap); } TEST_CASE(test_jpeg)