summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-03-31 17:27:01 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-04-10 08:33:55 +0200
commitea3d755ac949c1b6dada5c341e018f8c23f5d395 (patch)
tree086b3573d3e2f64fd918df4996d1f00ad9aa863b /svtools
parent94185507ed11bf6e2e2e9fa47c247680ae1edb36 (diff)
vcl: detach usage and remove GraphicManager and GraphicCache
Also remove some GraphicObjectTest because they call into GraphicManager which now doesn't exist anymore. Change-Id: Ia434736d8611df629af3e897c878a7fb8bbe4706 Reviewed-on: https://gerrit.libreoffice.org/52243 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/qa/unit/GraphicObjectTest.cxx157
1 files changed, 0 insertions, 157 deletions
diff --git a/svtools/qa/unit/GraphicObjectTest.cxx b/svtools/qa/unit/GraphicObjectTest.cxx
index ee119e46c793..6d748b8d180d 100644
--- a/svtools/qa/unit/GraphicObjectTest.cxx
+++ b/svtools/qa/unit/GraphicObjectTest.cxx
@@ -38,9 +38,7 @@ class GraphicObjectTest: public test::BootstrapFixture, public unotest::MacrosTe
public:
void testSwap();
- void testSizeBasedAutoSwap();
void testTdf88836();
- void testTdf88935();
void testPdf();
@@ -57,9 +55,7 @@ private:
private:
CPPUNIT_TEST_SUITE(GraphicObjectTest);
CPPUNIT_TEST(testSwap);
- CPPUNIT_TEST(testSizeBasedAutoSwap);
CPPUNIT_TEST(testTdf88836);
- CPPUNIT_TEST(testTdf88935);
CPPUNIT_TEST(testPdf);
CPPUNIT_TEST_SUITE_END();
};
@@ -147,92 +143,6 @@ void GraphicObjectTest::testSwap()
}
}
-void GraphicObjectTest::testSizeBasedAutoSwap()
-{
- // Set cache size to a very small value to check what happens
- {
- std::shared_ptr< comphelper::ConfigurationChanges > aBatch(comphelper::ConfigurationChanges::create());
- officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), aBatch);
- aBatch->commit();
- }
-
- uno::Reference< lang::XComponent > xComponent =
- loadFromDesktop(m_directories.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* pGrafObj1 = nullptr;
- const GraphicObject* pGrafObj2 = nullptr;
- for( sal_uLong nIndex = 0; nIndex < aNodes.Count(); ++nIndex)
- {
- if( aNodes[nIndex]->IsGrfNode() )
- {
- SwGrfNode* pGrfNode = aNodes[nIndex]->GetGrfNode();
- CPPUNIT_ASSERT(pGrfNode);
- if( !pGrafObj1 )
- {
- pGrafObj1 = &pGrfNode->GetGrfObj();
- }
- else
- {
- pGrafObj2 = &pGrfNode->GetGrfObj();
- }
- }
- }
- CPPUNIT_ASSERT_MESSAGE("Missing image", pGrafObj1 != nullptr && pGrafObj2 != nullptr);
-
- {
- // First image should be swapped out
- CPPUNIT_ASSERT(pGrafObj1->IsSwappedOut());
- CPPUNIT_ASSERT_EQUAL(sal_uLong(697230), pGrafObj1->GetSizeBytes());
-
- // Still swapped out: size is cached
- CPPUNIT_ASSERT(pGrafObj1->IsSwappedOut());
- }
-
- {
- // Second image should be in the memory
- // Size based swap out is triggered by swap in, so the last swapped in image should be
- // in the memory despite of size limit is reached.
- CPPUNIT_ASSERT(!pGrafObj2->IsSwappedOut());
- CPPUNIT_ASSERT_EQUAL(sal_uLong(1620000), pGrafObj2->GetSizeBytes());
- }
-
- // Swap in first image -> second image will be swapped out
- {
- pGrafObj1->GetGraphic(); // GetGraphic calls swap in on a const object
- CPPUNIT_ASSERT(!pGrafObj1->IsSwappedOut());
- CPPUNIT_ASSERT(pGrafObj2->IsSwappedOut());
- }
-
- // Swap in second image -> first image will be swapped out
- {
- pGrafObj2->GetGraphic(); // GetGraphic calls swap in on a const object
- CPPUNIT_ASSERT(!pGrafObj2->IsSwappedOut());
- CPPUNIT_ASSERT(pGrafObj1->IsSwappedOut());
- }
-
- // Use bigger cache
- {
- GraphicManager& rGrfMgr = pGrafObj1->GetGraphicManager();
- rGrfMgr.SetMaxCacheSize((pGrafObj1->GetSizeBytes()+pGrafObj2->GetSizeBytes())*10);
- }
- // Swap in both images -> both should be swapped in
- {
- pGrafObj1->GetGraphic();
- pGrafObj2->GetGraphic();
- CPPUNIT_ASSERT(!pGrafObj1->IsSwappedOut());
- CPPUNIT_ASSERT(!pGrafObj2->IsSwappedOut());
- }
-
- xComponent->dispose();
-}
-
void GraphicObjectTest::testTdf88836()
{
// Construction with empty bitmap -> type should be GraphicType::NONE
@@ -242,73 +152,6 @@ void GraphicObjectTest::testTdf88836()
CPPUNIT_ASSERT_EQUAL(int(GraphicType::NONE), int(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(m_directories.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 = nullptr;
- const GraphicObject* pGraphObj2 = nullptr;
- for( sal_uLong nIndex = 0; nIndex < aNodes.Count(); ++nIndex)
- {
- if( aNodes[nIndex]->IsGrfNode() )
- {
- SwGrfNode* pGrfNode = aNodes[nIndex]->GetGrfNode();
- CPPUNIT_ASSERT(pGrfNode);
- if( !pGraphObj1 )
- {
- pGraphObj1 = &pGrfNode->GetGrfObj();
- }
- else
- {
- pGraphObj2 = &pGrfNode->GetGrfObj();
- }
- }
- }
- CPPUNIT_ASSERT_MESSAGE("Missing image", pGraphObj1 != nullptr && pGraphObj2 != nullptr);
-
- // 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);
- 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());
- }
-
- xComponent->dispose();
-}
-
void GraphicObjectTest::testPdf()
{
#if HAVE_FEATURE_PDFIUM