summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit/GraphicTest.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-02-15 14:30:01 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-02-16 03:18:35 +0100
commit79b4e2b3b18611f2b18508e8cba5f068b4be29ba (patch)
tree314dbcfa86fc46524038b4986bc39f2097a3fb6d /vcl/qa/cppunit/GraphicTest.cxx
parenta0c0cd9e53a0dea115c145b3092eeafbaa06b545 (diff)
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@gmail.com>
Diffstat (limited to 'vcl/qa/cppunit/GraphicTest.cxx')
-rw-r--r--vcl/qa/cppunit/GraphicTest.cxx93
1 files changed, 93 insertions, 0 deletions
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);