mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
Tests/LibGfx: Actually test image decoders in TestImageDecoder
We were passing raw Gfx::Bitmap objects into the various image decoders instead of encoded image data. This made all of them fail, but the test expectations were set up in a way that aligned with this outcome. With this patch, we now test the codecs for real. Except ICO, since we don't have an ICO file handy. That's a FIXME.
This commit is contained in:
parent
ba29798039
commit
09780ba7a9
|
@ -5,6 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/MappedFile.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/BMPLoader.h>
|
||||
#include <LibGfx/GIFLoader.h>
|
||||
|
@ -22,11 +23,11 @@
|
|||
|
||||
TEST_CASE(test_bmp)
|
||||
{
|
||||
auto image = Gfx::load_bmp("/res/html/misc/bmpsuite_files/rgba32-1.bmp");
|
||||
auto bmp = Gfx::BMPImageDecoderPlugin((const u8*)&image, sizeof(*image));
|
||||
auto file = MappedFile::map("/res/html/misc/bmpsuite_files/rgba32-1.bmp").release_value();
|
||||
auto bmp = Gfx::BMPImageDecoderPlugin((u8 const*)file->data(), file->size());
|
||||
EXPECT(bmp.frame_count());
|
||||
|
||||
EXPECT(!bmp.sniff());
|
||||
EXPECT(bmp.sniff());
|
||||
EXPECT(!bmp.is_animated());
|
||||
EXPECT(!bmp.loop_count());
|
||||
|
||||
|
@ -36,25 +37,23 @@ TEST_CASE(test_bmp)
|
|||
|
||||
TEST_CASE(test_gif)
|
||||
{
|
||||
auto image = Gfx::load_gif("/res/graphics/download-animation.gif");
|
||||
auto gif = Gfx::GIFImageDecoderPlugin((const u8*)&image, sizeof(*image));
|
||||
auto file = MappedFile::map("/res/graphics/download-animation.gif").release_value();
|
||||
auto gif = Gfx::GIFImageDecoderPlugin((u8 const*)file->data(), file->size());
|
||||
EXPECT(gif.frame_count());
|
||||
|
||||
EXPECT(!gif.sniff());
|
||||
// FIXME: is_animated() should return true
|
||||
// LibGfx::load_gif() returns a bitmap and lies about is_animated()
|
||||
EXPECT(!gif.is_animated());
|
||||
EXPECT(gif.sniff());
|
||||
EXPECT(gif.is_animated());
|
||||
EXPECT(!gif.loop_count());
|
||||
|
||||
auto frame = gif.frame(1);
|
||||
EXPECT(frame.duration == 0);
|
||||
EXPECT(frame.duration == 400);
|
||||
}
|
||||
|
||||
TEST_CASE(test_ico)
|
||||
{
|
||||
// FIXME: Use an ico file
|
||||
auto image = Gfx::load_ico("/res/graphics/buggie.png");
|
||||
auto ico = Gfx::ICOImageDecoderPlugin((const u8*)&image, sizeof(*image));
|
||||
auto file = MappedFile::map("/res/graphics/buggie.png").release_value();
|
||||
auto ico = Gfx::ICOImageDecoderPlugin((u8 const*)file->data(), file->size());
|
||||
EXPECT(ico.frame_count());
|
||||
|
||||
EXPECT(!ico.sniff());
|
||||
|
@ -67,11 +66,11 @@ TEST_CASE(test_ico)
|
|||
|
||||
TEST_CASE(test_jpg)
|
||||
{
|
||||
auto image = Gfx::load_jpg("/res/html/misc/bmpsuite_files/rgb24.jpg");
|
||||
auto jpg = Gfx::JPGImageDecoderPlugin((const u8*)&image, sizeof(*image));
|
||||
auto file = MappedFile::map("/res/html/misc/bmpsuite_files/rgb24.jpg").release_value();
|
||||
auto jpg = Gfx::JPGImageDecoderPlugin((u8 const*)file->data(), file->size());
|
||||
EXPECT(jpg.frame_count());
|
||||
|
||||
EXPECT(!jpg.sniff());
|
||||
EXPECT(jpg.sniff());
|
||||
EXPECT(!jpg.is_animated());
|
||||
EXPECT(!jpg.loop_count());
|
||||
|
||||
|
@ -81,11 +80,11 @@ TEST_CASE(test_jpg)
|
|||
|
||||
TEST_CASE(test_pbm)
|
||||
{
|
||||
auto image = Gfx::load_pbm("/res/html/misc/pbmsuite_files/buggie-raw.pbm");
|
||||
auto pbm = Gfx::PBMImageDecoderPlugin((const u8*)&image, sizeof(*image));
|
||||
auto file = MappedFile::map("/res/html/misc/pbmsuite_files/buggie-raw.pbm").release_value();
|
||||
auto pbm = Gfx::PBMImageDecoderPlugin((u8 const*)file->data(), file->size());
|
||||
EXPECT(pbm.frame_count());
|
||||
|
||||
EXPECT(!pbm.sniff());
|
||||
EXPECT(pbm.sniff());
|
||||
EXPECT(!pbm.is_animated());
|
||||
EXPECT(!pbm.loop_count());
|
||||
|
||||
|
@ -95,11 +94,11 @@ TEST_CASE(test_pbm)
|
|||
|
||||
TEST_CASE(test_pgm)
|
||||
{
|
||||
auto image = Gfx::load_pbm("/res/html/misc/pbmsuite_files/buggie-raw.pbm");
|
||||
auto pgm = Gfx::PGMImageDecoderPlugin((const u8*)&image, sizeof(*image));
|
||||
auto file = MappedFile::map("/res/html/misc/pgmsuite_files/buggie-raw.pgm").release_value();
|
||||
auto pgm = Gfx::PGMImageDecoderPlugin((u8 const*)file->data(), file->size());
|
||||
EXPECT(pgm.frame_count());
|
||||
|
||||
EXPECT(!pgm.sniff());
|
||||
EXPECT(pgm.sniff());
|
||||
EXPECT(!pgm.is_animated());
|
||||
EXPECT(!pgm.loop_count());
|
||||
|
||||
|
@ -109,11 +108,11 @@ TEST_CASE(test_pgm)
|
|||
|
||||
TEST_CASE(test_png)
|
||||
{
|
||||
auto image = Gfx::load_png("/res/graphics/buggie.png");
|
||||
auto png = Gfx::PNGImageDecoderPlugin((const u8*)&image, sizeof(*image));
|
||||
auto file = MappedFile::map("/res/graphics/buggie.png").release_value();
|
||||
auto png = Gfx::PNGImageDecoderPlugin((u8 const*)file->data(), file->size());
|
||||
EXPECT(png.frame_count());
|
||||
|
||||
EXPECT(!png.sniff());
|
||||
EXPECT(png.sniff());
|
||||
EXPECT(!png.is_animated());
|
||||
EXPECT(!png.loop_count());
|
||||
|
||||
|
@ -123,11 +122,11 @@ TEST_CASE(test_png)
|
|||
|
||||
TEST_CASE(test_ppm)
|
||||
{
|
||||
auto image = Gfx::load_ppm("/res/html/misc/ppmsuite_files/buggie-raw.ppm");
|
||||
auto ppm = Gfx::PPMImageDecoderPlugin((const u8*)&image, sizeof(*image));
|
||||
auto file = MappedFile::map("/res/html/misc/ppmsuite_files/buggie-raw.ppm").release_value();
|
||||
auto ppm = Gfx::PPMImageDecoderPlugin((u8 const*)file->data(), file->size());
|
||||
EXPECT(ppm.frame_count());
|
||||
|
||||
EXPECT(!ppm.sniff());
|
||||
EXPECT(ppm.sniff());
|
||||
EXPECT(!ppm.is_animated());
|
||||
EXPECT(!ppm.loop_count());
|
||||
|
||||
|
|
Loading…
Reference in a new issue