[Libreoffice-commits] core.git: include/test sc/qa test/source

Laurent Godard lgodard.libre at laposte.net
Sun Aug 10 23:37:22 PDT 2014


 include/test/sheet/xstyleloader.hxx             |    5 +++
 sc/qa/extras/testdocuments/ScStyleLoaderObj.ods |binary
 test/source/sheet/xstyleloader.cxx              |   36 +++++++++++-------------
 3 files changed, 22 insertions(+), 19 deletions(-)

New commits:
commit 454ec6e7916cf5b7c8908521527547acc66557e9
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Fri Aug 8 17:34:30 2014 +0200

    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 at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/include/test/sheet/xstyleloader.hxx b/include/test/sheet/xstyleloader.hxx
index 7986cb7..59b1b40 100644
--- a/include/test/sheet/xstyleloader.hxx
+++ b/include/test/sheet/xstyleloader.hxx
@@ -12,6 +12,8 @@
 
 #include <rtl/ustring.hxx>
 #include <com/sun/star/style/XStyleLoader2.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+
 #include <test/testdllapi.hxx>
 
 namespace apitest {
@@ -30,6 +32,9 @@ public:
     // XStyleLoader2
     void testLoadStylesFromDocument();
 
+private:
+    void checkStyleProperties(css::uno::Reference< css::style::XStyleFamiliesSupplier > xFamilySupplier);
+
 protected:
     ~XStyleLoader() {}
 
diff --git a/sc/qa/extras/testdocuments/ScStyleLoaderObj.ods b/sc/qa/extras/testdocuments/ScStyleLoaderObj.ods
index 3cfb3ba..0cc718c 100644
Binary files a/sc/qa/extras/testdocuments/ScStyleLoaderObj.ods and b/sc/qa/extras/testdocuments/ScStyleLoaderObj.ods differ
diff --git a/test/source/sheet/xstyleloader.cxx b/test/source/sheet/xstyleloader.cxx
index 41528b8..01ed053 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);
 }
 
 }


More information about the Libreoffice-commits mailing list