summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-07-04 12:06:04 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-07-04 15:15:33 +0200
commitcf40ee4a162da5f357793463e5707492030eb5df (patch)
tree016affb79bc6bd8c8b5efee9ee33547f56366451 /vcl
parent5d439a07b60d505ac1a9fafad90849aa13f0c2aa (diff)
CppunitTest_vcl_graphic_test: Demultiplex test code
and relax hack a bit, enabling webp based on testname is dirty since they might change Change-Id: Id933095701d01426d2802d6a194d6f74c07baaa9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153957 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/GraphicTest.cxx100
-rw-r--r--vcl/source/filter/graphicfilter.cxx8
2 files changed, 83 insertions, 25 deletions
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 2dff15f29d34..d9ba3b875486 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -50,7 +50,11 @@ public:
private:
void testUnloadedGraphic();
- void testUnloadedGraphicLoading();
+ void testUnloadedGraphicLoadingPng();
+ void testUnloadedGraphicLoadingGif();
+ void testUnloadedGraphicLoadingJpg();
+ void testUnloadedGraphicLoadingTif();
+ void testUnloadedGraphicLoadingWebp();
void testUnloadedGraphicWmf();
void testUnloadedGraphicAlpha();
void testUnloadedGraphicSizeUnit();
@@ -91,7 +95,11 @@ private:
CPPUNIT_TEST_SUITE(GraphicTest);
CPPUNIT_TEST(testUnloadedGraphic);
- CPPUNIT_TEST(testUnloadedGraphicLoading);
+ CPPUNIT_TEST(testUnloadedGraphicLoadingPng);
+ CPPUNIT_TEST(testUnloadedGraphicLoadingGif);
+ CPPUNIT_TEST(testUnloadedGraphicLoadingJpg);
+ CPPUNIT_TEST(testUnloadedGraphicLoadingTif);
+ CPPUNIT_TEST(testUnloadedGraphicLoadingWebp);
CPPUNIT_TEST(testUnloadedGraphicWmf);
CPPUNIT_TEST(testUnloadedGraphicAlpha);
CPPUNIT_TEST(testUnloadedGraphicSizeUnit);
@@ -294,25 +302,79 @@ void GraphicTest::testUnloadedGraphic()
CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
}
-void GraphicTest::testUnloadedGraphicLoading()
+void GraphicTest::testUnloadedGraphicLoadingPng()
{
- const OUString aFormats[] = { "png", "gif", "jpg", "tif", "webp" };
+ Graphic aGraphic = makeUnloadedGraphic(u"png");
- for (OUString const& sFormat : aFormats)
- {
- Graphic aGraphic = makeUnloadedGraphic(sFormat);
-
- // check available
- CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
- CPPUNIT_ASSERT_EQUAL(tools::Long(120), aGraphic.GetSizePixel().Width());
- CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Height());
- CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
- CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > 0);
- CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
-
- if (sFormat != "jpg")
- CPPUNIT_ASSERT_EQUAL(true, checkBitmap(aGraphic));
- }
+ // check available
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(120), aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Height());
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > 0);
+ CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
+
+ CPPUNIT_ASSERT_EQUAL(true, checkBitmap(aGraphic));
+}
+
+void GraphicTest::testUnloadedGraphicLoadingGif()
+{
+ Graphic aGraphic = makeUnloadedGraphic(u"gif");
+
+ // check available
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(120), aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Height());
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > 0);
+ CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
+
+ CPPUNIT_ASSERT_EQUAL(true, checkBitmap(aGraphic));
+}
+
+void GraphicTest::testUnloadedGraphicLoadingJpg()
+{
+ Graphic aGraphic = makeUnloadedGraphic(u"jpg");
+
+ // check available
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(120), aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Height());
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > 0);
+ CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
+
+ CPPUNIT_ASSERT_EQUAL(false, checkBitmap(aGraphic));
+}
+
+void GraphicTest::testUnloadedGraphicLoadingTif()
+{
+ Graphic aGraphic = makeUnloadedGraphic(u"tif");
+
+ // check available
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(120), aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Height());
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > 0);
+ CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
+
+ CPPUNIT_ASSERT_EQUAL(true, checkBitmap(aGraphic));
+}
+
+void GraphicTest::testUnloadedGraphicLoadingWebp()
+{
+ Graphic aGraphic = makeUnloadedGraphic(u"webp");
+
+ // check available
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(120), aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Height());
+ CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > 0);
+ CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
+
+ CPPUNIT_ASSERT_EQUAL(true, checkBitmap(aGraphic));
}
void GraphicTest::testUnloadedGraphicWmf()
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 38983c7e3190..ffc3b7cb92de 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -100,13 +100,9 @@
// and somewhen later enable the support unconditionally.
static bool supportNativeWebp()
{
+ // Enable support only for unittests
const char* const testname = getenv("LO_TESTNAME");
- if(testname == nullptr)
- return false;
- // Enable support only for those unittests that test it.
- if( std::string_view("_anonymous_namespace___GraphicTest__testUnloadedGraphicLoading_") == testname
- || std::string_view("VclFiltersTest__testExportImport_") == testname
- || o3tl::starts_with(std::string_view(testname), "WebpFilterTest__"))
+ if(testname)
return true;
return false;
}