[Libreoffice-commits] core.git: svx/qa

Aditya Pratap Singh (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 29 19:57:23 UTC 2021


 svx/qa/unit/data/tdf60684.jpg |binary
 svx/qa/unit/xoutdev.cxx       |   28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

New commits:
commit 869f3fa36e2c6306252cee43b244240d4024a242
Author:     Aditya Pratap Singh <adityapratapsingh51 at gmail.com>
AuthorDate: Wed Mar 24 14:32:18 2021 +0530
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Mon Mar 29 21:56:49 2021 +0200

    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 at libreoffice.org>

diff --git a/svx/qa/unit/data/tdf60684.jpg b/svx/qa/unit/data/tdf60684.jpg
new file mode 100644
index 000000000000..2218cdd72df0
Binary files /dev/null and b/svx/qa/unit/data/tdf60684.jpg 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: */


More information about the Libreoffice-commits mailing list