[Libreoffice-commits] core.git: sw/CppunitTest_sw_ooxmlimport.mk sw/qa

Andres Gomez agomez at igalia.com
Wed Oct 16 03:23:57 PDT 2013


 sw/CppunitTest_sw_ooxmlimport.mk            |    3 ++
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx    |   19 +++-----------
 sw/qa/extras/ooxmlimport/data/smartart.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx    |   36 ++++++++++++++++++++++++++--
 4 files changed, 42 insertions(+), 16 deletions(-)

New commits:
commit b3362fc9cb410599ac54fc3badfad75354c98d84
Author: Andres Gomez <agomez at igalia.com>
Date:   Fri Oct 4 19:11:21 2013 +0300

    sw: Smart-Art related UTs updated to new option
    
    The "ooxmlexport" unit test for Smart-Art has been updated to just
    check for the new rendered bitmap that substitutes the generated basic
    shapes.
    
    The "ooxmlimport" has been updated with a new "testSmartart" unit
    tests which checks that the importing has been done to just basic
    shapes.
    
    For this, the "run" method has been customized so we can set the
    proper filter option.
    
    Slightly modified the expected results in the "testChartProp" unit
    test since linking it to additional libraries has modified the
    dimmensions of the imported chart in few units.
    
    Made the "ooxmlimport" C++ unit tests in the "sw" module to depend on
    the "drawinglayer" and "svx" components and the "utl" library.
    
    Conflicts:
    	sw/qa/extras/ooxmlimport/ooxmlimport.cxx
    
    Change-Id: I0900a50cfee07999511d071bc9932477ad9430c5

diff --git a/sw/CppunitTest_sw_ooxmlimport.mk b/sw/CppunitTest_sw_ooxmlimport.mk
index 5831893..696b6ab 100644
--- a/sw/CppunitTest_sw_ooxmlimport.mk
+++ b/sw/CppunitTest_sw_ooxmlimport.mk
@@ -22,6 +22,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ooxmlimport, \
     sal \
     test \
     unotest \
+    utl \
     sw \
     vcl \
 	$(gb_UWINAPI) \
@@ -52,6 +53,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_ooxmlimport,\
     chart2/source/chartcore \
     comphelper/util/comphelp \
     configmgr/source/configmgr \
+    drawinglayer/drawinglayer \
     embeddedobj/util/embobj \
     fileaccess/source/fileacc \
     filter/source/config/cache/filterconfig1 \
@@ -71,6 +73,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_ooxmlimport,\
     svl/source/fsstor/fsstorage \
     svl/util/svl \
     svtools/util/svt \
+    svx/util/svx \
     toolkit/util/tk \
     ucb/source/core/ucb1 \
     ucb/source/ucp/file/ucpfile1 \
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 5230635..962f09b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1468,7 +1468,7 @@ void Test::testSmartart()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc
 
     uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xGroup->getCount()); // 3 rectangles and an arrow in the group
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xGroup->getCount()); // 1 rendered bitmap from the original shapes
 
     uno::Reference<beans::XPropertySet> xGroupPropertySet(getShape(1), uno::UNO_QUERY);
     xGroupPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag;
@@ -1515,19 +1515,10 @@ void Test::testSmartart()
     }
     CPPUNIT_ASSERT(bData && bLayout && bQStyle && bColor && bDrawing); // Grab Bag has all the expected elements
 
-    uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(1), uno::UNO_QUERY);
-    sal_Int32 nValue(0);
-    xPropertySet->getPropertyValue("FillColor") >>= nValue;
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f81bd), nValue); // If fill color is right, theme import is OK
-
-    uno::Reference<text::XTextRange> xTextRange(xGroup->getByIndex(1), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(OUString("Sample"), xTextRange->getString()); // Shape has text
-
-    uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextRange->getText(), uno::UNO_QUERY);
-    uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
-    xPropertySet.set(xParaEnum->nextElement(), uno::UNO_QUERY);
-    xPropertySet->getPropertyValue("ParaAdjust") >>= nValue;
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_CENTER), nValue); // Paragraph properties are imported
+    uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(0), uno::UNO_QUERY);
+    OUString nValue;
+    xPropertySet->getPropertyValue("Name") >>= nValue;
+    CPPUNIT_ASSERT_EQUAL(OUString("RenderedShapes"), nValue); // Rendered bitmap has the proper name
 }
 
 void Test::testFdo69636()
diff --git a/sw/qa/extras/ooxmlimport/data/smartart.docx b/sw/qa/extras/ooxmlimport/data/smartart.docx
new file mode 100644
index 0000000..7a553f4
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/smartart.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index d801881..7fe9b40a 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -40,6 +40,7 @@
 #include <com/sun/star/xml/dom/XDocument.hpp>
 
 #include <vcl/svapp.hxx>
+#include <unotools/fltrcfg.hxx>
 
 #include <swmodeltestbase.hxx>
 #include <bordertest.hxx>
@@ -140,6 +141,7 @@ public:
     void testBnc779620();
     void testFdo43093();
     void testMultiColumnSeparator();
+    void testSmartart();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(WNT)
@@ -244,12 +246,17 @@ void Test::run()
         {"bnc779620.docx", &Test::testBnc779620},
         {"fdo43093.docx", &Test::testFdo43093},
         {"multi-column-separator-with-line.docx", &Test::testMultiColumnSeparator},
+        {"smartart.docx", &Test::testSmartart},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
     {
         MethodEntry<Test>& rEntry = aMethods[i];
+        if (OString(rEntry.pName) == "smartart.docx")
+            SvtFilterOptions::Get().SetSmartArt2Shape(sal_True);
         load("/sw/qa/extras/ooxmlimport/data/",  rEntry.pName);
+        if (OString(rEntry.pName) == "smartart.docx")
+            SvtFilterOptions::Get().SetSmartArt2Shape(sal_False);
         (this->*rEntry.pMethod)();
         finish();
     }
@@ -1594,8 +1601,8 @@ void Test::testChartProp()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
 
     uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(15236), getProperty<sal_Int32>(xPropertySet, "Width"));
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(8886), getProperty<sal_Int32>(xPropertySet, "Height"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(15240), getProperty<sal_Int32>(xPropertySet, "Width"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(8890), getProperty<sal_Int32>(xPropertySet, "Height"));
 }
 
 void Test::testBnc779620()
@@ -1639,6 +1646,31 @@ void Test::testFdo43093()
     CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLLDir);
 }
 
+void Test::testSmartart()
+{
+    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc
+
+    uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xGroup->getCount()); // 3 rectangles and an arrow in the group
+
+    uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(1), uno::UNO_QUERY);
+    sal_Int32 nValue(0);
+    xPropertySet->getPropertyValue("FillColor") >>= nValue;
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f81bd), nValue); // If fill color is right, theme import is OK
+
+    uno::Reference<text::XTextRange> xTextRange(xGroup->getByIndex(1), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("Sample"), xTextRange->getString()); // Shape has text
+
+    uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextRange->getText(), uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+    xPropertySet.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+    xPropertySet->getPropertyValue("ParaAdjust") >>= nValue;
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_CENTER), nValue); // Paragraph properties are imported
+}
 
 void Test::testMultiColumnSeparator()
 {


More information about the Libreoffice-commits mailing list