diff options
author | Nico Weber <thakis@chromium.org> | 2023-05-29 13:01:45 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-29 19:44:45 +0200 |
commit | 358d94b57a60a757f5f79d0a4f826ea7b9d68f22 (patch) | |
tree | cc101a310612fc43c4ae1659c93051f0396b119e /Tests/LibGfx/TestImageDecoder.cpp | |
parent | f8e4a0a268bfdc94e2ed6cba3eb67966ea49730d (diff) | |
download | serenity-358d94b57a60a757f5f79d0a4f826ea7b9d68f22.zip |
WebP/Lossy: Add some basic tests
Diffstat (limited to 'Tests/LibGfx/TestImageDecoder.cpp')
-rw-r--r-- | Tests/LibGfx/TestImageDecoder.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index d8dd90da8d..23a633e581 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -311,7 +311,13 @@ TEST_CASE(test_webp_simple_lossy) EXPECT_EQ(plugin_decoder->size(), Gfx::IntSize(240, 240)); - // FIXME: test plugin_decoder->frame(0) once webp lossy decoding is implemented. + auto frame = MUST(plugin_decoder->frame(0)); + EXPECT_EQ(frame.image->size(), Gfx::IntSize(240, 240)); + + // While VP8 YUV contents are defined bit-exact, the YUV->RGB conversion isn't. + // So pixels changing by 1 or so below is fine if you change code. + EXPECT_EQ(frame.image->get_pixel(120, 232), Gfx::Color(0xf2, 0xef, 0xf0, 255)); + EXPECT_EQ(frame.image->get_pixel(198, 202), Gfx::Color(0x7b, 0xaa, 0xd5, 255)); } TEST_CASE(test_webp_simple_lossless) @@ -353,7 +359,24 @@ TEST_CASE(test_webp_extended_lossy) EXPECT_EQ(plugin_decoder->size(), Gfx::IntSize(417, 223)); - // FIXME: test plugin_decoder->frame(0) once webp lossy decoding is implemented. + auto frame = MUST(plugin_decoder->frame(0)); + EXPECT_EQ(frame.image->size(), Gfx::IntSize(417, 223)); + + // While VP8 YUV contents are defined bit-exact, the YUV->RGB conversion isn't. + // So pixels changing by 1 or so below is fine if you change code. + EXPECT_EQ(frame.image->get_pixel(89, 72), Gfx::Color(255, 1, 0, 255)); + EXPECT_EQ(frame.image->get_pixel(174, 69), Gfx::Color(0, 255, 0, 255)); + EXPECT_EQ(frame.image->get_pixel(245, 84), Gfx::Color(0, 0, 255, 255)); + EXPECT_EQ(frame.image->get_pixel(352, 125), Gfx::Color(0, 0, 0, 128)); + EXPECT_EQ(frame.image->get_pixel(355, 106), Gfx::Color(0, 0, 0, 0)); + + // Check same basic pixels as in test_webp_extended_lossless too. + // (The top-left pixel in the lossy version is fully transparent white, compared to fully transparent black in the lossless version). + EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color(255, 255, 255, 0)); + EXPECT_EQ(frame.image->get_pixel(43, 75), Gfx::Color(255, 0, 2, 255)); + EXPECT_EQ(frame.image->get_pixel(141, 75), Gfx::Color(0, 255, 3, 255)); + EXPECT_EQ(frame.image->get_pixel(235, 75), Gfx::Color(0, 0, 255, 255)); + EXPECT_EQ(frame.image->get_pixel(341, 75), Gfx::Color(0, 0, 0, 128)); } TEST_CASE(test_webp_extended_lossless) |