diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-04-01 14:47:13 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-04-10 08:34:13 +0200 |
commit | e4eb416c3ef81d098ed61caabd2077cbbb2418bc (patch) | |
tree | 5aa13b196431f02a1b4fc0d1049f7ba2eb0ba74c /svtools/qa | |
parent | ea3d755ac949c1b6dada5c341e018f8c23f5d395 (diff) |
remove swapping and link from GraphicObject and Graphic
Change-Id: If81127e0589b504909801bcbf392d2dec3a3efc1
Reviewed-on: https://gerrit.libreoffice.org/52244
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svtools/qa')
-rw-r--r-- | svtools/qa/unit/GraphicObjectTest.cxx | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/svtools/qa/unit/GraphicObjectTest.cxx b/svtools/qa/unit/GraphicObjectTest.cxx index 6d748b8d180d..3f6c69b7e051 100644 --- a/svtools/qa/unit/GraphicObjectTest.cxx +++ b/svtools/qa/unit/GraphicObjectTest.cxx @@ -37,10 +37,7 @@ class GraphicObjectTest: public test::BootstrapFixture, public unotest::MacrosTe { public: - void testSwap(); void testTdf88836(); - void testPdf(); - virtual void setUp() override { @@ -50,98 +47,11 @@ public: } private: - DECL_LINK(getLinkStream, const GraphicObject*, SvStream*); - -private: CPPUNIT_TEST_SUITE(GraphicObjectTest); - CPPUNIT_TEST(testSwap); CPPUNIT_TEST(testTdf88836); - CPPUNIT_TEST(testPdf); CPPUNIT_TEST_SUITE_END(); }; -static const char aGraphicFile[] = "/svtools/qa/unit/data/graphic.png"; -static const sal_uLong nGraphicSizeBytes = 4800; - -const Graphic lcl_loadGraphic(const rtl::OUString &rUrl) -{ - const Image aImage(rUrl); - return Graphic(aImage.GetBitmapEx()); -} - -IMPL_LINK_NOARG(GraphicObjectTest, getLinkStream, const GraphicObject*, SvStream*) -{ - return GRFMGR_AUTOSWAPSTREAM_LINK; -} - -void GraphicObjectTest::testSwap() -{ - // simple non-linked case - { - GraphicObject aGraphObj(lcl_loadGraphic(m_directories.getURLFromSrc(aGraphicFile))); - CPPUNIT_ASSERT(!aGraphObj.HasSwapStreamHdl()); - CPPUNIT_ASSERT(!aGraphObj.IsSwappedOut()); - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj.GetGraphic().GetSizeBytes()); - // swap out - CPPUNIT_ASSERT(aGraphObj.SwapOut()); - CPPUNIT_ASSERT(aGraphObj.IsSwappedOut()); - // swap in - CPPUNIT_ASSERT(aGraphObj.SwapIn()); - CPPUNIT_ASSERT(!aGraphObj.IsSwappedOut()); - // the data are still there - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj.GetGraphic().GetSizeBytes()); - } - - // linked case - { - GraphicObject aGraphObj(lcl_loadGraphic(m_directories.getURLFromSrc(aGraphicFile))); - aGraphObj.SetSwapStreamHdl(LINK(this, GraphicObjectTest, getLinkStream)); - - CPPUNIT_ASSERT(aGraphObj.HasSwapStreamHdl()); - CPPUNIT_ASSERT(!aGraphObj.IsSwappedOut()); - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj.GetGraphic().GetSizeBytes()); - // swap out - CPPUNIT_ASSERT(aGraphObj.SwapOut()); - CPPUNIT_ASSERT(aGraphObj.IsSwappedOut()); - // swap in - CPPUNIT_ASSERT(aGraphObj.SwapIn()); - CPPUNIT_ASSERT(!aGraphObj.IsSwappedOut()); - // the data are still there - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj.GetGraphic().GetSizeBytes()); - } - - // combination of two GraphicObjects - { - GraphicObject aGraphObj(lcl_loadGraphic(m_directories.getURLFromSrc(aGraphicFile))); - - GraphicObject aGraphObj2(aGraphObj); - aGraphObj2.SetSwapStreamHdl(LINK(this, GraphicObjectTest, getLinkStream)); - - CPPUNIT_ASSERT(!aGraphObj.IsSwappedOut()); - CPPUNIT_ASSERT(!aGraphObj2.IsSwappedOut()); - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj.GetGraphic().GetSizeBytes()); - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj2.GetGraphic().GetSizeBytes()); - - // GraphicObjects never share the same Graphic. A new one is created as one step during - // registration of the GraphicObject at GraphicManager. - - // swap out - CPPUNIT_ASSERT(aGraphObj.SwapOut()); - CPPUNIT_ASSERT(aGraphObj.IsSwappedOut()); - CPPUNIT_ASSERT(!aGraphObj2.IsSwappedOut()); - CPPUNIT_ASSERT(aGraphObj2.SwapOut()); - CPPUNIT_ASSERT(aGraphObj2.IsSwappedOut()); - // swap in - CPPUNIT_ASSERT(aGraphObj2.SwapIn()); - CPPUNIT_ASSERT(!aGraphObj2.IsSwappedOut()); - CPPUNIT_ASSERT(aGraphObj.IsSwappedOut()); - CPPUNIT_ASSERT(aGraphObj.SwapIn()); - CPPUNIT_ASSERT(!aGraphObj.IsSwappedOut()); - // the data are still there - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj.GetGraphic().GetSizeBytes()); - CPPUNIT_ASSERT_EQUAL(nGraphicSizeBytes, aGraphObj2.GetGraphic().GetSizeBytes()); - } -} void GraphicObjectTest::testTdf88836() { @@ -152,40 +62,6 @@ void GraphicObjectTest::testTdf88836() CPPUNIT_ASSERT_EQUAL(int(GraphicType::NONE), int(aGraphic.GetType())); } -void GraphicObjectTest::testPdf() -{ -#if HAVE_FEATURE_PDFIUM - uno::Reference<lang::XComponent> xComponent = loadFromDesktop(m_directories.getURLFromSrc("svtools/qa/unit/data/pdf.odt"), "com.sun.star.text.TextDocument"); - SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument*>(xComponent.get()); - CPPUNIT_ASSERT(pTxtDoc); - SwDoc* pDoc = pTxtDoc->GetDocShell()->GetDoc(); - CPPUNIT_ASSERT(pDoc); - SwNodes& aNodes = pDoc->GetNodes(); - - // Find images - GraphicObject* pGraphicObject = nullptr; - for( sal_uLong nIndex = 0; nIndex < aNodes.Count(); ++nIndex) - { - if( aNodes[nIndex]->IsGrfNode() ) - { - SwGrfNode* pGrfNode = aNodes[nIndex]->GetGrfNode(); - CPPUNIT_ASSERT(pGrfNode); - pGraphicObject = const_cast<GraphicObject*>(&pGrfNode->GetGrfObj()); - break; - } - } - CPPUNIT_ASSERT_MESSAGE("Missing image", pGraphicObject); - - CPPUNIT_ASSERT(pGraphicObject->GetGraphic().getPdfData().hasElements()); - CPPUNIT_ASSERT(pGraphicObject->SwapOut()); - CPPUNIT_ASSERT(pGraphicObject->SwapIn()); - // This failed, swap out + swap in lost the PDF data. - CPPUNIT_ASSERT(pGraphicObject->GetGraphic().getPdfData().hasElements()); - - xComponent->dispose(); -#endif -} - CPPUNIT_TEST_SUITE_REGISTRATION(GraphicObjectTest); } |