From 1a6c5746db942606f5036ab6fc22f498d8afde18 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 8 Jun 2022 17:04:15 +0100 Subject: [PATCH] Add a simple test allowing to load an arbitrary image This test is disabled by default but useful for checking if the given image can be loaded. --- tests/image/image.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/image/image.cpp b/tests/image/image.cpp index 1f43fb810e..202ae777cc 100644 --- a/tests/image/image.cpp +++ b/tests/image/image.cpp @@ -2326,6 +2326,28 @@ TEST_CASE("wxImage::SizeLimits", "[image]") #endif // SIZEOF_VOID_P == 8 } +// This can be used to test loading an arbitrary image file by setting the +// environment variable WX_TEST_IMAGE_PATH to point to it. +TEST_CASE("wxImage::LoadPath", "[.]") +{ + wxString path; + REQUIRE( wxGetEnv("WX_TEST_IMAGE_PATH", &path) ); + + TestLogEnabler enableLogs; + + wxInitAllImageHandlers(); + + wxImage image; + REQUIRE( image.LoadFile(path) ); + + WARN("Image " + << image.GetWidth() + << "*" + << image.GetHeight() + << (image.HasAlpha() ? " with alpha" : "") + << " loaded"); +} + /* TODO: add lots of more tests to wxImage functions */