diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2015-02-17 15:50:08 +0100 |
---|---|---|
committer | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2015-02-22 11:59:21 +0100 |
commit | 908c060ceef81a733cf1d1912b48f5d499afdad8 (patch) | |
tree | 1500304071791c658c398c192a324507bd557d48 /svtools/qa/unit | |
parent | ab00ac3e88e0a28d0e38c5968c23014a6a8fb194 (diff) |
Test for tdf#88935
Change-Id: I625a59a632c53c77f593268b14e60ab265e5a821
Diffstat (limited to 'svtools/qa/unit')
-rw-r--r-- | svtools/qa/unit/GraphicObjectTest.cxx | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/svtools/qa/unit/GraphicObjectTest.cxx b/svtools/qa/unit/GraphicObjectTest.cxx index d4ecf29b6653..cc73b5c8f97f 100644 --- a/svtools/qa/unit/GraphicObjectTest.cxx +++ b/svtools/qa/unit/GraphicObjectTest.cxx @@ -41,6 +41,7 @@ public: void testSwap(); void testSizeBasedAutoSwap(); void testTdf88836(); + void testTdf88935(); virtual void setUp() SAL_OVERRIDE @@ -58,6 +59,7 @@ private: CPPUNIT_TEST(testSwap); CPPUNIT_TEST(testSizeBasedAutoSwap); CPPUNIT_TEST(testTdf88836); + CPPUNIT_TEST(testTdf88935); CPPUNIT_TEST_SUITE_END(); }; @@ -239,6 +241,70 @@ void GraphicObjectTest::testTdf88836() CPPUNIT_ASSERT_EQUAL(GRAPHIC_NONE, aGraphic.GetType()); } +void GraphicObjectTest::testTdf88935() +{ + // Cache size was not updated by deletion of graphic objects + + // Load a file with two images + uno::Reference< lang::XComponent > xComponent = + loadFromDesktop(getURLFromSrc("svtools/qa/unit/data/document_with_two_images.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 + const GraphicObject* pGraphObj1 = 0; + const GraphicObject* pGraphObj2 = 0; + for( sal_uLong nIndex = 0; nIndex < aNodes.Count(); ++nIndex) + { + if( aNodes[nIndex]->IsGrfNode() ) + { + SwGrfNode* pGrfNode = aNodes[nIndex]->GetGrfNode(); + if( !pGraphObj1 ) + { + pGraphObj1 = &pGrfNode->GetGrfObj(); + } + else + { + pGraphObj2 = &pGrfNode->GetGrfObj(); + } + } + } + CPPUNIT_ASSERT_MESSAGE("Missing image", pGraphObj1 != 0 && pGraphObj2 != 0); + + // Set cache size + { + GraphicManager& rGrfMgr = pGraphObj1->GetGraphicManager(); + rGrfMgr.SetMaxCacheSize((pGraphObj1->GetSizeBytes()+pGraphObj2->GetSizeBytes())*10); + } + + // Both images fit into the cache + { + pGraphObj1->GetGraphic(); + pGraphObj2->GetGraphic(); + CPPUNIT_ASSERT(!pGraphObj1->IsSwappedOut()); + CPPUNIT_ASSERT(!pGraphObj2->IsSwappedOut()); + } + + // Create and remove some copy of the first image + for( int i = 0; i < 50; ++i ) + { + GraphicObject aGraphObj3(*pGraphObj1, &pGraphObj1->GetGraphicManager()); + CPPUNIT_ASSERT(aGraphObj3.SwapOut()); + CPPUNIT_ASSERT(aGraphObj3.SwapIn()); + } + + // Both images fit into the cache + { + pGraphObj1->GetGraphic(); + pGraphObj2->GetGraphic(); + CPPUNIT_ASSERT(!pGraphObj1->IsSwappedOut()); + CPPUNIT_ASSERT(!pGraphObj2->IsSwappedOut()); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(GraphicObjectTest); } |