summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-11-07 10:44:20 +0100
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-11-07 10:45:17 +0100
commit554902eac3361c67c6d76e0d7a237d9a16062dfe (patch)
treee1b5f9d8d9fa65fc764fb5eae5988ca62e4f0feb /sd
parent9dc3b49c891fb9fe45c24de4b7e1e88fe400afe0 (diff)
Make SdrGrafObj swapping methods private.
Plus remove some useless call of them. Change the tests accordingly. Change-Id: I47a50b5734d799ac02ee7221c95f82415afb9497
Diffstat (limited to 'sd')
-rw-r--r--sd/CppunitTest_sd_export_tests.mk4
-rw-r--r--sd/qa/unit/data/odp/document_with_an_image.odpbin101665 -> 0 bytes
-rw-r--r--sd/qa/unit/data/odp/document_with_two_images.odpbin0 -> 202183 bytes
-rw-r--r--sd/qa/unit/export-tests.cxx42
4 files changed, 33 insertions, 13 deletions
diff --git a/sd/CppunitTest_sd_export_tests.mk b/sd/CppunitTest_sd_export_tests.mk
index 68bdb3211965..a8f3dbfa067b 100644
--- a/sd/CppunitTest_sd_export_tests.mk
+++ b/sd/CppunitTest_sd_export_tests.mk
@@ -106,6 +106,10 @@ $(eval $(call gb_CppunitTest_use_components,sd_export_tests,\
xmlsecurity/util/xmlsecurity \
))
+$(eval $(call gb_CppunitTest_use_custom_headers,sd_export_tests,\
+ officecfg/registry \
+))
+
$(eval $(call gb_CppunitTest_use_configuration,sd_export_tests))
$(eval $(call gb_CppunitTest_use_unittest_configuration,sd_export_tests))
diff --git a/sd/qa/unit/data/odp/document_with_an_image.odp b/sd/qa/unit/data/odp/document_with_an_image.odp
deleted file mode 100644
index 9e0bdce3bb35..000000000000
--- a/sd/qa/unit/data/odp/document_with_an_image.odp
+++ /dev/null
Binary files differ
diff --git a/sd/qa/unit/data/odp/document_with_two_images.odp b/sd/qa/unit/data/odp/document_with_two_images.odp
new file mode 100644
index 000000000000..33fb9bb56392
--- /dev/null
+++ b/sd/qa/unit/data/odp/document_with_two_images.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 0dfc4683c729..08f854779fe4 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -6,10 +6,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-
+#include <officecfg/Office/Common.hxx>
#include "sdmodeltestbase.hxx"
#include "Outliner.hxx"
-
+#include <comphelper/processfactory.hxx>
#include <svl/stritem.hxx>
#include <editeng/editobj.hxx>
#include <editeng/outlobj.hxx>
@@ -504,21 +504,17 @@ void SdExportTest::testSwappedOutImageExport()
PPTX,
};
+ // Set cache size to a very small value to make sure one of the images is swapped out
+ boost::shared_ptr< comphelper::ConfigurationChanges > xBatch(comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), xBatch);
+ xBatch->commit();
+
for( size_t nExportFormat = 0; nExportFormat < vFormats.size(); ++nExportFormat )
{
// Load the original file with one image
- ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/document_with_an_image.odp"), ODP);
+ ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/document_with_two_images.odp"), ODP);
const OString sFailedMessage = OString("Failed on filter: ") + OString(aFileFormats[nExportFormat].pFilterName);
- // Swap out the image
- SdDrawDocument *pDoc = xDocShRef->GetDoc();
- CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pDoc != NULL );
- const SdrPage* pPage = pDoc->GetPage(1);
- CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pPage != NULL );
- SdrGrafObj* pGrafObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2));
- CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pGrafObject != NULL);
- pGrafObject->ForceSwapOut();
-
// Export the document and import again for a check
uno::Reference< lang::XComponent > xComponent(xDocShRef->GetModel(), uno::UNO_QUERY);
uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
@@ -534,7 +530,7 @@ void SdExportTest::testSwappedOutImageExport()
// Check whether graphic exported well after it was swapped out
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
- CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), xDrawPagesSupplier->getDrawPages()->getCount() == 1 );
+ CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), xDrawPagesSupplier->getDrawPages()->getCount() == 2 );
uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY);
@@ -554,6 +550,26 @@ void SdExportTest::testSwappedOutImageExport()
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), xBitmap->getSize().Width );
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381), xBitmap->getSize().Height );
}
+
+ // Second Image
+ xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW );
+ xImage.set(xDrawPage->getByIndex(1), uno::UNO_QUERY);
+ XPropSet.set( xImage, uno::UNO_QUERY_THROW );
+ // Check URL
+ {
+ OUString sURL;
+ XPropSet->getPropertyValue("GraphicURL") >>= sURL;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString("vnd.sun.star.GraphicObject:1000000000000384000002580A24B597"), sURL);
+ }
+ // Check size
+ {
+ uno::Reference<graphic::XGraphic> xGraphic;
+ XPropSet->getPropertyValue("Graphic") >>= xGraphic;
+ uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900), xBitmap->getSize().Width );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600), xBitmap->getSize().Height );
+ }
xDocShRef->DoClose();
}
}