LibGfx: Move TestImageDecoder over to input file approach in 8cfabbcd93

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.)
This commit is contained in:
Nico Weber 2023-01-31 14:00:33 -05:00 committed by Tim Flynn
parent b8b5e0f680
commit bea3f3fc46
13 changed files with 19 additions and 13 deletions

View file

@ -21,9 +21,15 @@
#include <stdio.h>
#include <string.h>
#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());

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB