From bea3f3fc46fed2b43dbf822df9a84c111ad6d17f Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 31 Jan 2023 14:00:33 -0500 Subject: LibGfx: Move TestImageDecoder over to input file approach in 8cfabbcd933 Rather than reading files out of /res, put them in a subfolder of Tests/LibGfx/ and pick the path based on AK_OS_SERENITY. That way, the tests can also pass when run under lagom. (I just `cp`d all the files that the test previously read from random places into Tests/LibGfx/test-inputs.) --- Tests/LibGfx/TestImageDecoder.cpp | 32 ++++++++++++--------- .../test-inputs/buggie-bottom-left-compressed.tga | Bin 0 -> 23955 bytes .../buggie-bottom-left-uncompressed.tga | Bin 0 -> 66044 bytes Tests/LibGfx/test-inputs/buggie-raw.pbm | Bin 0 -> 2917 bytes Tests/LibGfx/test-inputs/buggie-raw.pgm | Bin 0 -> 22015 bytes Tests/LibGfx/test-inputs/buggie-raw.ppm | Bin 0 -> 66061 bytes .../test-inputs/buggie-top-left-compressed.tga | Bin 0 -> 23955 bytes .../test-inputs/buggie-top-left-uncompressed.tga | Bin 0 -> 66044 bytes Tests/LibGfx/test-inputs/buggie.png | Bin 0 -> 9015 bytes Tests/LibGfx/test-inputs/download-animation.gif | Bin 0 -> 4542 bytes Tests/LibGfx/test-inputs/rgb24.jpg | Bin 0 -> 2319 bytes Tests/LibGfx/test-inputs/rgba32-1.bmp | Bin 0 -> 32650 bytes Tests/LibGfx/test-inputs/serenity.ico | Bin 0 -> 1150 bytes 13 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 Tests/LibGfx/test-inputs/buggie-bottom-left-compressed.tga create mode 100644 Tests/LibGfx/test-inputs/buggie-bottom-left-uncompressed.tga create mode 100644 Tests/LibGfx/test-inputs/buggie-raw.pbm create mode 100644 Tests/LibGfx/test-inputs/buggie-raw.pgm create mode 100644 Tests/LibGfx/test-inputs/buggie-raw.ppm create mode 100644 Tests/LibGfx/test-inputs/buggie-top-left-compressed.tga create mode 100644 Tests/LibGfx/test-inputs/buggie-top-left-uncompressed.tga create mode 100644 Tests/LibGfx/test-inputs/buggie.png create mode 100644 Tests/LibGfx/test-inputs/download-animation.gif create mode 100644 Tests/LibGfx/test-inputs/rgb24.jpg create mode 100644 Tests/LibGfx/test-inputs/rgba32-1.bmp create mode 100644 Tests/LibGfx/test-inputs/serenity.ico (limited to 'Tests') diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index 633450f526..58dc750e3e 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -21,9 +21,15 @@ #include #include +#ifdef AK_OS_SERENITY +# define TEST_INPUT(x) ("/usr/Tests/LibGfx/test-inputs/" x) +#else +# define TEST_INPUT(x) ("test-inputs/" x) +#endif + TEST_CASE(test_bmp) { - auto file = MUST(Core::MappedFile::map("/res/html/misc/bmpsuite_files/rgba32-1.bmp"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("rgba32-1.bmp"sv))); EXPECT(MUST(Gfx::BMPImageDecoderPlugin::sniff(file->bytes()))); auto plugin_decoder = MUST(Gfx::BMPImageDecoderPlugin::create(file->bytes())); EXPECT(plugin_decoder->initialize()); @@ -38,7 +44,7 @@ TEST_CASE(test_bmp) TEST_CASE(test_gif) { - auto file = MUST(Core::MappedFile::map("/res/graphics/download-animation.gif"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("download-animation.gif"sv))); EXPECT(MUST(Gfx::GIFImageDecoderPlugin::sniff(file->bytes()))); auto plugin_decoder = MUST(Gfx::GIFImageDecoderPlugin::create(file->bytes())); EXPECT(plugin_decoder->initialize()); @@ -53,7 +59,7 @@ TEST_CASE(test_gif) TEST_CASE(test_not_ico) { - auto file = MUST(Core::MappedFile::map("/res/graphics/buggie.png"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie.png"sv))); EXPECT(!MUST(Gfx::ICOImageDecoderPlugin::sniff(file->bytes()))); auto plugin_decoder = MUST(Gfx::ICOImageDecoderPlugin::create(file->bytes())); EXPECT(!plugin_decoder->initialize()); @@ -67,7 +73,7 @@ TEST_CASE(test_not_ico) TEST_CASE(test_bmp_embedded_in_ico) { - auto file = MUST(Core::MappedFile::map("/res/icons/16x16/serenity.ico"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("serenity.ico"sv))); EXPECT(MUST(Gfx::ICOImageDecoderPlugin::sniff(file->bytes()))); auto plugin_decoder = MUST(Gfx::ICOImageDecoderPlugin::create(file->bytes())); EXPECT(plugin_decoder->initialize()); @@ -81,7 +87,7 @@ TEST_CASE(test_bmp_embedded_in_ico) TEST_CASE(test_jpg) { - auto file = MUST(Core::MappedFile::map("/res/html/misc/bmpsuite_files/rgb24.jpg"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("rgb24.jpg"sv))); EXPECT(MUST(Gfx::JPGImageDecoderPlugin::sniff(file->bytes()))); auto plugin_decoder = MUST(Gfx::JPGImageDecoderPlugin::create(file->bytes())); EXPECT(plugin_decoder->initialize()); @@ -98,7 +104,7 @@ TEST_CASE(test_jpg) TEST_CASE(test_pbm) { - auto file = MUST(Core::MappedFile::map("/res/html/misc/pbmsuite_files/buggie-raw.pbm"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie-raw.pbm"sv))); EXPECT(MUST(Gfx::PBMImageDecoderPlugin::sniff(file->bytes()))); auto plugin_decoder = MUST(Gfx::PBMImageDecoderPlugin::create(file->bytes())); EXPECT(plugin_decoder->initialize()); @@ -115,7 +121,7 @@ TEST_CASE(test_pbm) TEST_CASE(test_pgm) { - auto file = MUST(Core::MappedFile::map("/res/html/misc/pgmsuite_files/buggie-raw.pgm"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie-raw.pgm"sv))); EXPECT(MUST(Gfx::PGMImageDecoderPlugin::sniff(file->bytes()))); auto plugin_decoder = MUST(Gfx::PGMImageDecoderPlugin::create(file->bytes())); EXPECT(plugin_decoder->initialize()); @@ -132,7 +138,7 @@ TEST_CASE(test_pgm) TEST_CASE(test_png) { - auto file = MUST(Core::MappedFile::map("/res/graphics/buggie.png"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie.png"sv))); EXPECT(MUST(Gfx::PNGImageDecoderPlugin::sniff(file->bytes()))); auto plugin_decoder = MUST(Gfx::PNGImageDecoderPlugin::create(file->bytes())); EXPECT(plugin_decoder->initialize()); @@ -149,7 +155,7 @@ TEST_CASE(test_png) TEST_CASE(test_ppm) { - auto file = MUST(Core::MappedFile::map("/res/html/misc/ppmsuite_files/buggie-raw.ppm"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie-raw.ppm"sv))); EXPECT(MUST(Gfx::PPMImageDecoderPlugin::sniff(file->bytes()))); auto plugin_decoder = MUST(Gfx::PPMImageDecoderPlugin::create(file->bytes())); EXPECT(plugin_decoder->initialize()); @@ -166,7 +172,7 @@ TEST_CASE(test_ppm) TEST_CASE(test_targa_bottom_left) { - auto file = MUST(Core::MappedFile::map("/res/html/misc/targasuite_files/buggie-bottom-left-uncompressed.tga"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie-bottom-left-uncompressed.tga"sv))); EXPECT(MUST(Gfx::TGAImageDecoderPlugin::validate_before_create(file->bytes()))); auto plugin_decoder = MUST(Gfx::TGAImageDecoderPlugin::create(file->bytes())); EXPECT(plugin_decoder->initialize()); @@ -185,7 +191,7 @@ TEST_CASE(test_targa_bottom_left) TEST_CASE(test_targa_top_left) { - auto file = MUST(Core::MappedFile::map("/res/html/misc/targasuite_files/buggie-top-left-uncompressed.tga"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie-top-left-uncompressed.tga"sv))); EXPECT(MUST(Gfx::TGAImageDecoderPlugin::validate_before_create(file->bytes()))); auto plugin_decoder = MUST(Gfx::TGAImageDecoderPlugin::create(file->bytes())); EXPECT(plugin_decoder->initialize()); @@ -204,7 +210,7 @@ TEST_CASE(test_targa_top_left) TEST_CASE(test_targa_bottom_left_compressed) { - auto file = MUST(Core::MappedFile::map("/res/html/misc/targasuite_files/buggie-bottom-left-compressed.tga"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie-bottom-left-compressed.tga"sv))); EXPECT(MUST(Gfx::TGAImageDecoderPlugin::validate_before_create(file->bytes()))); auto plugin_decoder = MUST(Gfx::TGAImageDecoderPlugin::create(file->bytes())); EXPECT(plugin_decoder->initialize()); @@ -223,7 +229,7 @@ TEST_CASE(test_targa_bottom_left_compressed) TEST_CASE(test_targa_top_left_compressed) { - auto file = MUST(Core::MappedFile::map("/res/html/misc/targasuite_files/buggie-top-left-compressed.tga"sv)); + auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie-top-left-compressed.tga"sv))); EXPECT(MUST(Gfx::TGAImageDecoderPlugin::validate_before_create(file->bytes()))); auto plugin_decoder = MUST(Gfx::TGAImageDecoderPlugin::create(file->bytes())); EXPECT(plugin_decoder->initialize()); diff --git a/Tests/LibGfx/test-inputs/buggie-bottom-left-compressed.tga b/Tests/LibGfx/test-inputs/buggie-bottom-left-compressed.tga new file mode 100644 index 0000000000..187d49bec5 Binary files /dev/null and b/Tests/LibGfx/test-inputs/buggie-bottom-left-compressed.tga differ diff --git a/Tests/LibGfx/test-inputs/buggie-bottom-left-uncompressed.tga b/Tests/LibGfx/test-inputs/buggie-bottom-left-uncompressed.tga new file mode 100644 index 0000000000..5f0a8aaf61 Binary files /dev/null and b/Tests/LibGfx/test-inputs/buggie-bottom-left-uncompressed.tga differ diff --git a/Tests/LibGfx/test-inputs/buggie-raw.pbm b/Tests/LibGfx/test-inputs/buggie-raw.pbm new file mode 100644 index 0000000000..71d0b504e3 Binary files /dev/null and b/Tests/LibGfx/test-inputs/buggie-raw.pbm differ diff --git a/Tests/LibGfx/test-inputs/buggie-raw.pgm b/Tests/LibGfx/test-inputs/buggie-raw.pgm new file mode 100644 index 0000000000..0b7142d396 Binary files /dev/null and b/Tests/LibGfx/test-inputs/buggie-raw.pgm differ diff --git a/Tests/LibGfx/test-inputs/buggie-raw.ppm b/Tests/LibGfx/test-inputs/buggie-raw.ppm new file mode 100644 index 0000000000..84f7c3469a Binary files /dev/null and b/Tests/LibGfx/test-inputs/buggie-raw.ppm differ diff --git a/Tests/LibGfx/test-inputs/buggie-top-left-compressed.tga b/Tests/LibGfx/test-inputs/buggie-top-left-compressed.tga new file mode 100644 index 0000000000..45cbda9521 Binary files /dev/null and b/Tests/LibGfx/test-inputs/buggie-top-left-compressed.tga differ diff --git a/Tests/LibGfx/test-inputs/buggie-top-left-uncompressed.tga b/Tests/LibGfx/test-inputs/buggie-top-left-uncompressed.tga new file mode 100644 index 0000000000..8952ffaf36 Binary files /dev/null and b/Tests/LibGfx/test-inputs/buggie-top-left-uncompressed.tga differ diff --git a/Tests/LibGfx/test-inputs/buggie.png b/Tests/LibGfx/test-inputs/buggie.png new file mode 100644 index 0000000000..94558bd2d3 Binary files /dev/null and b/Tests/LibGfx/test-inputs/buggie.png differ diff --git a/Tests/LibGfx/test-inputs/download-animation.gif b/Tests/LibGfx/test-inputs/download-animation.gif new file mode 100644 index 0000000000..f5e55e40f5 Binary files /dev/null and b/Tests/LibGfx/test-inputs/download-animation.gif differ diff --git a/Tests/LibGfx/test-inputs/rgb24.jpg b/Tests/LibGfx/test-inputs/rgb24.jpg new file mode 100644 index 0000000000..c43698c9b1 Binary files /dev/null and b/Tests/LibGfx/test-inputs/rgb24.jpg differ diff --git a/Tests/LibGfx/test-inputs/rgba32-1.bmp b/Tests/LibGfx/test-inputs/rgba32-1.bmp new file mode 100644 index 0000000000..3c1e2648fc Binary files /dev/null and b/Tests/LibGfx/test-inputs/rgba32-1.bmp differ diff --git a/Tests/LibGfx/test-inputs/serenity.ico b/Tests/LibGfx/test-inputs/serenity.ico new file mode 100644 index 0000000000..89dd18839b Binary files /dev/null and b/Tests/LibGfx/test-inputs/serenity.ico differ -- cgit v1.2.3