summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAditya Pratap Singh <adityapratapsingh51@gmail.com>2021-03-24 14:32:18 +0530
committerXisco Fauli <xiscofauli@libreoffice.org>2021-03-29 21:56:49 +0200
commit869f3fa36e2c6306252cee43b244240d4024a242 (patch)
treefa3659a30e34b9f1eab6cad71e21ff821dd23063
parent130db636988175f474354412d7222e0a749faf03 (diff)
tdf#60684 Add unit test
Change-Id: I9fc633a9a7c977d869297237cdd8547ca0cd9d47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113037 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--svx/qa/unit/data/tdf60684.jpgbin0 -> 35738 bytes
-rw-r--r--svx/qa/unit/xoutdev.cxx28
2 files changed, 28 insertions, 0 deletions
diff --git a/svx/qa/unit/data/tdf60684.jpg b/svx/qa/unit/data/tdf60684.jpg
new file mode 100644
index 000000000000..2218cdd72df0
--- /dev/null
+++ b/svx/qa/unit/data/tdf60684.jpg
Binary files differ
diff --git a/svx/qa/unit/xoutdev.cxx b/svx/qa/unit/xoutdev.cxx
index 4e0cc5ff0b48..35eac21cda72 100644
--- a/svx/qa/unit/xoutdev.cxx
+++ b/svx/qa/unit/xoutdev.cxx
@@ -68,4 +68,32 @@ CPPUNIT_TEST_FIXTURE(XOutdevTest, testPdfGraphicExport)
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>('-'), sFirstBytes[4]);
}
+CPPUNIT_TEST_FIXTURE(XOutdevTest, testTdf60684)
+{
+ Graphic aGraphic;
+ test::Directories aDirectories;
+ OUString aURL = aDirectories.getURLFromSrc(u"svx/qa/unit/data/tdf60684.jpg");
+ SvFileStream aStream(aURL, StreamMode::READ);
+ CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE,
+ GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aURL, aStream));
+
+ // Export it.
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ XOutFlags const eFlags = XOutFlags::DontExpandFilename | XOutFlags::DontAddExtension
+ | XOutFlags::UseNativeIfPossible;
+ OUString aTempURL = aTempFile.GetURL();
+ XOutBitmap::WriteGraphic(aGraphic, aTempURL, "png", eFlags);
+
+ SvStream* pStream = aTempFile.GetStream(StreamMode::READ);
+ CPPUNIT_ASSERT(pStream->TellEnd() > 4);
+ sal_uInt8 sFirstBytes[4];
+ pStream->ReadBytes(sFirstBytes, 4);
+
+ //Checks if the file's header matches a PNG's expected header
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>('P'), sFirstBytes[1]);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>('N'), sFirstBytes[2]);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>('G'), sFirstBytes[3]);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */