diff options
author | Andres Gomez <agomez@igalia.com> | 2013-10-04 19:11:21 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-10-16 12:23:34 +0200 |
commit | b3362fc9cb410599ac54fc3badfad75354c98d84 (patch) | |
tree | 8ce98b71cb8bfdda91d6e4dc355a2af3fe08d5b7 | |
parent | 09edaa05cd605372ac2d2da0e010fde79f56efc8 (diff) |
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
-rw-r--r-- | sw/CppunitTest_sw_ooxmlimport.mk | 3 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 19 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/smartart.docx | bin | 0 -> 20453 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 36 |
4 files changed, 42 insertions, 16 deletions
diff --git a/sw/CppunitTest_sw_ooxmlimport.mk b/sw/CppunitTest_sw_ooxmlimport.mk index 583189368e56..696b6ab96b0c 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 523063564341..962f09b86258 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 Binary files differnew file mode 100644 index 000000000000..7a553f425188 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/smartart.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index d80188156447..7fe9b40ab06c 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() { |