diff options
author | Laurent Godard <lgodard.libre@laposte.net> | 2014-08-08 17:34:30 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-08-11 06:37:02 +0000 |
commit | 454ec6e7916cf5b7c8908521527547acc66557e9 (patch) | |
tree | e3af038e6e77d8e19bdd48e65c1ea4e6006890e2 /test | |
parent | javaunohelper: enhancements in decodeUTF8 (diff) | |
download | core-454ec6e7916cf5b7c8908521527547acc66557e9.tar.gz core-454ec6e7916cf5b7c8908521527547acc66557e9.zip |
XStyleLoader2 : enhance unit test to PageStyle
and remove duplicate code
Change-Id: Ib9e3568c860fe5cd3f11374a1c61dff101e33a18
Reviewed-on: https://gerrit.libreoffice.org/10832
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/source/sheet/xstyleloader.cxx | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/test/source/sheet/xstyleloader.cxx b/test/source/sheet/xstyleloader.cxx index 41528b809002..01ed053b712b 100644 --- a/test/source/sheet/xstyleloader.cxx +++ b/test/source/sheet/xstyleloader.cxx @@ -12,7 +12,6 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> -#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/style/XStyleLoader.hpp> @@ -20,7 +19,6 @@ #include <com/sun/star/style/XStyle.hpp> - #include <rtl/ustring.hxx> #include "cppunit/extensions/HelperMacros.h" @@ -44,22 +42,7 @@ void XStyleLoader::testLoadStylesFromURL() xTargetStyleLoader->loadStylesFromURL(aFileURL, aOptions); - // check if targetDocument has myStyle - uno::Reference< container::XNameAccess > xFamilies(xFamilySupplier->getStyleFamilies(), UNO_QUERY_THROW); - uno::Reference< container::XNameContainer > xCellStyles(xFamilies->getByName("CellStyles"), UNO_QUERY_THROW); - - CPPUNIT_ASSERT_MESSAGE("Style not imported", xCellStyles->hasByName("myStyle")); - - // test the backgroundcolor is correctly imported - - uno::Reference< style::XStyle > xMyStyle (xCellStyles->getByName("myStyle"), UNO_QUERY_THROW); - uno::Reference< beans::XPropertySet > xPropSet (xMyStyle, UNO_QUERY_THROW); - - OUString aCellStyleName("CellBackColor"); - uno::Any aBackColor = xPropSet->getPropertyValue(aCellStyleName); - uno::Any expectedBackColor(sal_Int32(16724787)); - - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong CellBackColor" , expectedBackColor, aBackColor); + checkStyleProperties(xFamilySupplier); } @@ -77,7 +60,13 @@ void XStyleLoader::testLoadStylesFromDocument() xTargetStyleLoader->loadStylesFromDocument(xSourceDoc, aOptions); - // check if targetDocument has myStyle + checkStyleProperties(xFamilySupplier); + +} + +void XStyleLoader::checkStyleProperties( uno::Reference< style::XStyleFamiliesSupplier > xFamilySupplier) +{ + // check if targetDocument has myStyle uno::Reference< container::XNameAccess > xFamilies(xFamilySupplier->getStyleFamilies(), UNO_QUERY_THROW); uno::Reference< container::XNameContainer > xCellStyles(xFamilies->getByName("CellStyles"), UNO_QUERY_THROW); @@ -93,6 +82,15 @@ void XStyleLoader::testLoadStylesFromDocument() CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong CellBackColor" , expectedBackColor, aBackColor); + // test default pageStyle + + uno::Reference< container::XNameContainer > xPageStyles(xFamilies->getByName("PageStyles"), UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xPagePropSet(xPageStyles->getByName("Default"), UNO_QUERY_THROW); + + uno::Any aPageBackColor = xPagePropSet->getPropertyValue("BackColor"); + uno::Any expectedPageBackColor(sal_Int32(13434879)); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong page style BackColor" , expectedPageBackColor, aPageBackColor); } } |