summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-08-17 07:44:57 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-08-19 10:37:15 +0200
commit574a5433417efe38e683506a24167b767fc69610 (patch)
tree8ff828995af394872caa89b059c67249b69ded31 /vcl
parentb34e80b3a8d0b9032556d82bc2619e450802dc8c (diff)
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@gmail.com> (cherry picked from commit bda18edf18f30cabb1c6589c59afc77f38541220) Change-Id: I1a7028d1768d0098aabbbc519d1b7936ddfc4a48 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100885 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/GraphicTest.cxx42
1 files changed, 42 insertions, 0 deletions
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);