From aff38ae80fb4d3371ada8c9026d8d81bc6325aec Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Wed, 5 Jul 2023 11:19:43 -0400 Subject: [PATCH] Tests: Add a test for grayscale JPEGs with an App14 segment See af14ed6b2e3 for more details. This test has been created by artificially adding an App14 segment to an existing grayscale image. --- Tests/LibGfx/TestImageDecoder.cpp | 10 ++++++++++ Tests/LibGfx/test-inputs/jpg/grayscale_app14.jpg | Bin 0 -> 686 bytes 2 files changed, 10 insertions(+) create mode 100644 Tests/LibGfx/test-inputs/jpg/grayscale_app14.jpg diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index 4fbf6ae5822..915ef3bd006 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -187,6 +187,16 @@ TEST_CASE(test_jpeg_empty_icc) expect_single_frame_of_size(*plugin_decoder, { 80, 80 }); } +TEST_CASE(test_jpeg_grayscale_with_app14) +{ + auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/grayscale_app14.jpg"sv))); + EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())); + auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes())); + MUST(plugin_decoder->initialize()); + + expect_single_frame_of_size(*plugin_decoder, { 80, 80 }); +} + TEST_CASE(test_pbm) { auto file = MUST(Core::MappedFile::map(TEST_INPUT("pnm/buggie-raw.pbm"sv))); diff --git a/Tests/LibGfx/test-inputs/jpg/grayscale_app14.jpg b/Tests/LibGfx/test-inputs/jpg/grayscale_app14.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a67a7edddca76826f454f11b419f422a0be9a9c3 GIT binary patch literal 686 zcmex=M)G;tLF)@)>x3sk|ve7d( zG5UXift!ONfFXd9QIO&P5e9jnWvq-~0I~xF7@3$^SlQS)IJvli3bqO`FflSSGqEtU zva+xMWov=*3@n1ILW+itY{G$w>`H|qMvW5}awt1(JSZA;@q>zSQc)8pmzcPOq?D?f zx`w8fiK&^ng{76Vi>sTvho@I?NN8AiL}XNQN@`kqMrKxVNoiSmMP*fUOKV$uM`zch z$y26In?7UatVN5LEM2yI#mZHiHgDOwZTpU$yAB;ba`f2o6DLnyx_ss8wd*%--g@}x z@sp>|p1*kc>f@)+U%r0({^RGb|F;-8K*4Cw@ZG!b>%`)FoARu$xt^~&x#NALxb17T z=X+CP%GY%FeVtr4A5+#4xqJq+F-lBuix~p`kF7qK#&6vb`=8M z2DIyZ)o(qJtHOMNt_0d44s;OIjxMmBKs#20U9m|IXwvzr6DVE*x*Ft_Q$RtGSKw{{ pdmZc*xFJAK1MS2#1Zs19DllYb0|O22FlZov!UyPOpiTd80s!b6I~f1~ literal 0 HcmV?d00001