[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/qa

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 19 08:38:03 UTC 2020


 vcl/qa/cppunit/GraphicTest.cxx |   42 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

New commits:
commit 574a5433417efe38e683506a24167b767fc69610
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Aug 17 07:44:57 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Aug 19 10:37:15 2020 +0200

    Add test for preserving page number when suapping
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100838
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit bda18edf18f30cabb1c6589c59afc77f38541220)
    
    Change-Id: I1a7028d1768d0098aabbbc519d1b7936ddfc4a48
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100885
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 7038ae4c6a11..a2629902241f 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -38,6 +38,7 @@ class GraphicTest : public CppUnit::TestFixture
     void testUnloadedGraphicSizeUnit();
     void testSwapping();
     void testSwappingVectorGraphic();
+    void testSwappingPageNumber();
 
     CPPUNIT_TEST_SUITE(GraphicTest);
     CPPUNIT_TEST(testUnloadedGraphic);
@@ -47,6 +48,7 @@ class GraphicTest : public CppUnit::TestFixture
     CPPUNIT_TEST(testUnloadedGraphicSizeUnit);
     CPPUNIT_TEST(testSwapping);
     CPPUNIT_TEST(testSwappingVectorGraphic);
+    CPPUNIT_TEST(testSwappingPageNumber);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -157,6 +159,7 @@ bool checkBitmap(Graphic& rGraphic)
 }
 
 char const DATA_DIRECTORY[] = "/vcl/qa/cppunit/data/";
+char const PDFEXPORT_DATA_DIRECTORY[] = "/vcl/qa/cppunit/pdfexport/data/";
 
 void GraphicTest::testUnloadedGraphic()
 {
@@ -409,6 +412,45 @@ void GraphicTest::testSwappingVectorGraphic()
     CPPUNIT_ASSERT_EQUAL(false, comphelper::DirectoryHelper::fileExists(rSwapFileURL));
 }
 
+void GraphicTest::testSwappingPageNumber()
+{
+    test::Directories aDirectories;
+    OUString aURL = aDirectories.getURLFromSrc(PDFEXPORT_DATA_DIRECTORY) + "SimpleMultiPagePDF.pdf";
+    SvFileStream aStream(aURL, StreamMode::READ);
+    GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+    Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
+
+    CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
+    CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+
+    // Load the vector graphic
+    CPPUNIT_ASSERT_EQUAL(true, bool(aGraphic.getVectorGraphicData()));
+    // Set the page index
+    aGraphic.getVectorGraphicData()->setPageIndex(1);
+
+    CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+                         aGraphic.getVectorGraphicData()->getVectorGraphicDataType());
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(17693),
+                         aGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength());
+    CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aGraphic.getVectorGraphicData()->getPageIndex());
+
+    CPPUNIT_ASSERT_EQUAL(false, aGraphic.ImplGetImpGraphic()->ImplIsSwapOut());
+
+    // Swapping out
+    CPPUNIT_ASSERT_EQUAL(true, aGraphic.ImplGetImpGraphic()->ImplSwapOut());
+    CPPUNIT_ASSERT_EQUAL(true, aGraphic.ImplGetImpGraphic()->ImplIsSwapOut());
+    CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+
+    // Let's swap in
+    CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+    CPPUNIT_ASSERT_EQUAL(true, aGraphic.makeAvailable());
+    CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
+    CPPUNIT_ASSERT_EQUAL(false, aGraphic.ImplGetImpGraphic()->ImplIsSwapOut());
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aGraphic.getVectorGraphicData()->getPageIndex());
+}
+
 } // namespace
 
 CPPUNIT_TEST_SUITE_REGISTRATION(GraphicTest);


More information about the Libreoffice-commits mailing list