summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-05-06 16:28:26 -0400
committerAndreas Kling <kling@serenityos.org>2023-05-07 07:08:05 +0200
commitae7e26e095c2cd860cdaec3231ae42e4a4570cbb (patch)
tree7ce9b28f0e859048e23f714445de53331e756541
parent18d527fce132eaad595008577da4a2530fd2bcb4 (diff)
downloadserenity-ae7e26e095c2cd860cdaec3231ae42e4a4570cbb.zip
Tests/LibGfx: Add some test coverage for animated webp decoding
Also add two FIXME comments for lossy decoding.
-rw-r--r--Tests/LibGfx/TestImageDecoder.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp
index 4a843d37e0..9faaecaa2f 100644
--- a/Tests/LibGfx/TestImageDecoder.cpp
+++ b/Tests/LibGfx/TestImageDecoder.cpp
@@ -288,6 +288,8 @@ TEST_CASE(test_webp_simple_lossy)
EXPECT(!plugin_decoder->loop_count());
EXPECT_EQ(plugin_decoder->size(), Gfx::IntSize(240, 240));
+
+ // FIXME: test plugin_decoder->frame(0) once webp lossy decoding is implemented.
}
TEST_CASE(test_webp_simple_lossless)
@@ -328,6 +330,8 @@ TEST_CASE(test_webp_extended_lossy)
EXPECT(!plugin_decoder->loop_count());
EXPECT_EQ(plugin_decoder->size(), Gfx::IntSize(417, 223));
+
+ // FIXME: test plugin_decoder->frame(0) once webp lossy decoding is implemented.
}
TEST_CASE(test_webp_extended_lossless)
@@ -453,4 +457,15 @@ TEST_CASE(test_webp_extended_lossless_animated)
EXPECT_EQ(plugin_decoder->loop_count(), 42u);
EXPECT_EQ(plugin_decoder->size(), Gfx::IntSize(990, 1050));
+
+ for (size_t frame_index = 0; frame_index < plugin_decoder->frame_count(); ++frame_index) {
+ auto frame = MUST(plugin_decoder->frame(frame_index));
+ EXPECT_EQ(frame.image->size(), Gfx::IntSize(990, 1050));
+
+ // This pixel happens to be the same color in all frames.
+ EXPECT_EQ(frame.image->get_pixel(500, 700), Gfx::Color::Yellow);
+
+ // This one isn't the same in all frames.
+ EXPECT_EQ(frame.image->get_pixel(500, 0), (frame_index == 2 || frame_index == 6) ? Gfx::Color::Black : Gfx::Color(255, 255, 255, 0));
+ }
}