mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-07 08:29:58 +00:00
Tests/LibGfx: Consolidate jbig2 decode tests
Removes some duplication, and makes it easier to add additional tests. No behavior change.
This commit is contained in:
parent
4329983cde
commit
576bc0e55b
|
@ -336,38 +336,28 @@ TEST_CASE(test_jbig2_white_47x23)
|
|||
EXPECT_EQ(pixel, Gfx::Color(Gfx::Color::White).value());
|
||||
}
|
||||
|
||||
TEST_CASE(test_jbig2_generic_region_arithmetic_code)
|
||||
TEST_CASE(test_jbig2_decode)
|
||||
{
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("jbig2/bitmap.jbig2"sv)));
|
||||
EXPECT(Gfx::JBIG2ImageDecoderPlugin::sniff(file->bytes()));
|
||||
auto plugin_decoder = TRY_OR_FAIL(Gfx::JBIG2ImageDecoderPlugin::create(file->bytes()));
|
||||
|
||||
auto bmp_file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("bmp/bitmap.bmp"sv)));
|
||||
auto bmp_plugin_decoder = TRY_OR_FAIL(Gfx::BMPImageDecoderPlugin::create(bmp_file->bytes()));
|
||||
|
||||
auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 399, 400 }));
|
||||
auto bmp_frame = TRY_OR_FAIL(expect_single_frame_of_size(*bmp_plugin_decoder, { 399, 400 }));
|
||||
|
||||
for (int y = 0; y < frame.image->height(); ++y)
|
||||
for (int x = 0; x < frame.image->width(); ++x)
|
||||
EXPECT_EQ(frame.image->get_pixel(x, y), bmp_frame.image->get_pixel(x, y));
|
||||
}
|
||||
Array test_inputs = {
|
||||
TEST_INPUT("jbig2/bitmap.jbig2"sv),
|
||||
TEST_INPUT("jbig2/bitmap-tpgdon.jbig2"sv),
|
||||
};
|
||||
|
||||
TEST_CASE(test_jbig2_generic_region_arithmetic_code_tpgdon)
|
||||
{
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("jbig2/bitmap-tpgdon.jbig2"sv)));
|
||||
EXPECT(Gfx::JBIG2ImageDecoderPlugin::sniff(file->bytes()));
|
||||
auto plugin_decoder = TRY_OR_FAIL(Gfx::JBIG2ImageDecoderPlugin::create(file->bytes()));
|
||||
for (auto test_input : test_inputs) {
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(test_input));
|
||||
EXPECT(Gfx::JBIG2ImageDecoderPlugin::sniff(file->bytes()));
|
||||
auto plugin_decoder = TRY_OR_FAIL(Gfx::JBIG2ImageDecoderPlugin::create(file->bytes()));
|
||||
|
||||
auto bmp_file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("bmp/bitmap.bmp"sv)));
|
||||
auto bmp_plugin_decoder = TRY_OR_FAIL(Gfx::BMPImageDecoderPlugin::create(bmp_file->bytes()));
|
||||
auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 399, 400 }));
|
||||
|
||||
auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 399, 400 }));
|
||||
auto bmp_frame = TRY_OR_FAIL(expect_single_frame_of_size(*bmp_plugin_decoder, { 399, 400 }));
|
||||
|
||||
for (int y = 0; y < frame.image->height(); ++y)
|
||||
for (int x = 0; x < frame.image->width(); ++x)
|
||||
EXPECT_EQ(frame.image->get_pixel(x, y), bmp_frame.image->get_pixel(x, y));
|
||||
for (int y = 0; y < frame.image->height(); ++y)
|
||||
for (int x = 0; x < frame.image->width(); ++x)
|
||||
EXPECT_EQ(frame.image->get_pixel(x, y), bmp_frame.image->get_pixel(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(test_jbig2_arithmetic_decoder)
|
||||
|
|
Loading…
Reference in a new issue