From ba8f4e73bfae4af76a79c688977c03d8fe6d914f Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 25 Jan 2024 11:29:05 -0500 Subject: [PATCH] Tests: Add a pam test file Hand-written in a text editor. I verified that `convert` converts it to a png that looks like the test expectations. --- Tests/LibGfx/TestImageDecoder.cpp | 13 +++++++++++++ Tests/LibGfx/test-inputs/pnm/2x1.pam | 8 ++++++++ 2 files changed, 21 insertions(+) create mode 100644 Tests/LibGfx/test-inputs/pnm/2x1.pam diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index 8253e27ebb..b31b16d739 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -444,6 +445,18 @@ TEST_CASE(test_jpeg_malformed_frame) } } +TEST_CASE(test_pam_rgb) +{ + auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("pnm/2x1.pam"sv))); + EXPECT(Gfx::PAMImageDecoderPlugin::sniff(file->bytes())); + auto plugin_decoder = TRY_OR_FAIL(Gfx::PAMImageDecoderPlugin::create(file->bytes())); + + auto frame = TRY_OR_FAIL(expect_single_frame(*plugin_decoder)); + EXPECT_EQ(frame.image->size(), Gfx::IntSize(2, 1)); + EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color('0', 'z', '0')); + EXPECT_EQ(frame.image->get_pixel(1, 0), Gfx::Color('0', '0', 'z')); +} + TEST_CASE(test_pbm) { auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("pnm/buggie-raw.pbm"sv))); diff --git a/Tests/LibGfx/test-inputs/pnm/2x1.pam b/Tests/LibGfx/test-inputs/pnm/2x1.pam new file mode 100644 index 0000000000..99b09aacc8 --- /dev/null +++ b/Tests/LibGfx/test-inputs/pnm/2x1.pam @@ -0,0 +1,8 @@ +P7 +WIDTH 2 +HEIGHT 1 +DEPTH 3 +MAXVAL 255 +TUPLTYPE RGB +ENDHDR +0z000z