Skip to content

Commit

Permalink
Tests/TestImageWriter: Make test_gif() not use test_roundtrip()
Browse files Browse the repository at this point in the history
This allows using more detailed assertions that match the gif loader.
  • Loading branch information
nico committed May 15, 2024
1 parent 99579f1 commit 5be603c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Tests/LibGfx/TestImageWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Gfx::GIFWriter, Gfx::GIFImageDecoderPlugin>(bitmap, true)));
auto encoded_bitmap = TRY_OR_FAIL((encode_bitmap<Gfx::GIFWriter>(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)
Expand Down

0 comments on commit 5be603c

Please sign in to comment.