diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-08-17 07:44:57 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-08-17 16:49:56 +0200 |
commit | bda18edf18f30cabb1c6589c59afc77f38541220 (patch) | |
tree | 0ecf2eea6241d689134d1d95ef82499edccc6476 /vcl/qa/cppunit | |
parent | 74e2f2178fd8a0ad29c5dbcefb22a9778a75ae82 (diff) |
Add test for preserving page number when suapping
Change-Id: I1a7028d1768d0098aabbbc519d1b7936ddfc4a48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100838
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa/cppunit')
-rw-r--r-- | vcl/qa/cppunit/GraphicTest.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx index 3d6d0a79b1a9..04a0559473ea 100644 --- a/vcl/qa/cppunit/GraphicTest.cxx +++ b/vcl/qa/cppunit/GraphicTest.cxx @@ -48,6 +48,7 @@ private: void testUnloadedGraphicSizeUnit(); void testSwapping(); void testSwappingVectorGraphic(); + void testSwappingPageNumber(); CPPUNIT_TEST_SUITE(GraphicTest); CPPUNIT_TEST(testUnloadedGraphic); @@ -57,6 +58,7 @@ private: CPPUNIT_TEST(testUnloadedGraphicSizeUnit); CPPUNIT_TEST(testSwapping); CPPUNIT_TEST(testSwappingVectorGraphic); + CPPUNIT_TEST(testSwappingPageNumber); CPPUNIT_TEST_SUITE_END(); }; @@ -174,6 +176,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() { @@ -426,6 +429,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()->isSwappedOut()); + + // Swapping out + CPPUNIT_ASSERT_EQUAL(true, aGraphic.ImplGetImpGraphic()->swapOut()); + CPPUNIT_ASSERT_EQUAL(true, aGraphic.ImplGetImpGraphic()->isSwappedOut()); + 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()->isSwappedOut()); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aGraphic.getVectorGraphicData()->getPageIndex()); +} + } // namespace CPPUNIT_TEST_SUITE_REGISTRATION(GraphicTest); |