[Libreoffice-commits] core.git: vcl/qa
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Tue Feb 16 02:19:16 UTC 2021
vcl/qa/cppunit/GraphicTest.cxx | 93 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+)
New commits:
commit 79b4e2b3b18611f2b18508e8cba5f068b4be29ba
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Feb 15 14:30:01 2021 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Feb 16 03:18:35 2021 +0100
vcl: add test to load graphic of some less common formats
Change-Id: Id23d2fc7a57d264b4fda2a2f2c39ab2cbc7cd477
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110897
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 2c64ce856692..55858e85ca13 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -71,6 +71,15 @@ private:
void testSwappingAnimationGraphic_GIF_WithGfxLink();
void testSwappingAnimationGraphic_GIF_WithoutGfxLink();
+ void testLoadMET();
+ void testLoadBMP();
+ void testLoadPSD();
+ void testLoadTGA();
+ void testLoadXBM();
+ void testLoadXPM();
+ void testLoadPCX();
+ void testLoadEPS();
+
CPPUNIT_TEST_SUITE(GraphicTest);
CPPUNIT_TEST(testUnloadedGraphic);
CPPUNIT_TEST(testUnloadedGraphicLoading);
@@ -95,6 +104,16 @@ private:
CPPUNIT_TEST(testSwappingAnimationGraphic_GIF_WithGfxLink);
CPPUNIT_TEST(testSwappingAnimationGraphic_GIF_WithoutGfxLink);
+
+ CPPUNIT_TEST(testLoadMET);
+ CPPUNIT_TEST(testLoadBMP);
+ CPPUNIT_TEST(testLoadPSD);
+ CPPUNIT_TEST(testLoadTGA);
+ CPPUNIT_TEST(testLoadXBM);
+ CPPUNIT_TEST(testLoadXPM);
+ CPPUNIT_TEST(testLoadPCX);
+ CPPUNIT_TEST(testLoadEPS);
+
CPPUNIT_TEST_SUITE_END();
};
@@ -214,6 +233,20 @@ bool checkBitmap(Graphic& rGraphic)
constexpr OUStringLiteral DATA_DIRECTORY = u"/vcl/qa/cppunit/data/";
constexpr OUStringLiteral PDFEXPORT_DATA_DIRECTORY = u"/vcl/qa/cppunit/pdfexport/data/";
+Graphic loadGraphic(std::u16string_view const& rFilename)
+{
+ test::Directories aDirectories;
+ OUString aFilename = aDirectories.getURLFromSrc(DATA_DIRECTORY) + rFilename;
+ SvFileStream aFileStream(aFilename, StreamMode::READ);
+ GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+
+ Graphic aGraphic;
+ CPPUNIT_ASSERT_EQUAL(
+ ERRCODE_NONE,
+ rGraphicFilter.ImportGraphic(aGraphic, OUString(), aFileStream, GRFILTER_FORMAT_DONTKNOW));
+ return aGraphic;
+}
+
void GraphicTest::testUnloadedGraphic()
{
// make unloaded test graphic
@@ -1126,6 +1159,66 @@ void GraphicTest::testSwappingAnimationGraphic_GIF_WithoutGfxLink()
CPPUNIT_ASSERT_EQUAL(rByteSize, aGraphic.GetSizeBytes());
}
+void GraphicTest::testLoadMET()
+{
+ Graphic aGraphic = loadGraphic(u"TypeDetectionExample.met");
+ CPPUNIT_ASSERT_EQUAL(GraphicType::GdiMetafile, aGraphic.GetType());
+}
+
+void GraphicTest::testLoadBMP()
+{
+ Graphic aGraphic = loadGraphic(u"TypeDetectionExample.bmp");
+ CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Height());
+}
+
+void GraphicTest::testLoadPSD()
+{
+ Graphic aGraphic = loadGraphic(u"TypeDetectionExample.psd");
+ CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Height());
+}
+
+void GraphicTest::testLoadTGA()
+{
+ Graphic aGraphic = loadGraphic(u"TypeDetectionExample.tga");
+ CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Height());
+}
+
+void GraphicTest::testLoadXBM()
+{
+ Graphic aGraphic = loadGraphic(u"TypeDetectionExample.xbm");
+ CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Height());
+}
+
+void GraphicTest::testLoadXPM()
+{
+ Graphic aGraphic = loadGraphic(u"TypeDetectionExample.xpm");
+ CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Height());
+}
+
+void GraphicTest::testLoadPCX()
+{
+ Graphic aGraphic = loadGraphic(u"TypeDetectionExample.pcx");
+ CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Height());
+}
+
+void GraphicTest::testLoadEPS()
+{
+ Graphic aGraphic = loadGraphic(u"TypeDetectionExample.eps");
+ CPPUNIT_ASSERT_EQUAL(GraphicType::GdiMetafile, aGraphic.GetType());
+}
+
} // namespace
CPPUNIT_TEST_SUITE_REGISTRATION(GraphicTest);
More information about the Libreoffice-commits
mailing list