From b5a888d3681cc375657f84239eca391bbb270fd5 Mon Sep 17 00:00:00 2001 From: Miguel Gomez Date: Mon, 16 Sep 2013 16:15:59 +0200 Subject: fdo#64491: Move SmartArt test from import to export Now that loading and saving SmartArt components is fully working, move the unit test from the import section to the export one, where both import and export will be tested. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Change-Id: I5e0d182ee941180ba80c2b310d85528ff75ef296 Reviewed-on: https://gerrit.libreoffice.org/6006 Reviewed-by: Miklos Vajna --- sw/qa/extras/ooxmlexport/data/smartart.docx | Bin 0 -> 20453 bytes sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 91 ++++++++++++++++++++++++++++ sw/qa/extras/ooxmlimport/data/smartart.docx | Bin 20453 -> 0 bytes sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 90 --------------------------- 4 files changed, 91 insertions(+), 90 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/smartart.docx delete mode 100644 sw/qa/extras/ooxmlimport/data/smartart.docx diff --git a/sw/qa/extras/ooxmlexport/data/smartart.docx b/sw/qa/extras/ooxmlexport/data/smartart.docx new file mode 100644 index 000000000000..7a553f425188 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/smartart.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 62398ca1b591..e2523532f484 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -118,6 +119,7 @@ public: void testFdo68787(); void testCharacterBorder(); void testStyleInheritance(); + void testSmartart(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -229,6 +231,7 @@ void Test::run() {"fdo68787.docx", &Test::testFdo68787}, {"charborder.odt", &Test::testCharacterBorder}, {"style-inheritance.docx", &Test::testStyleInheritance}, + {"smartart.docx", &Test::testSmartart}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -1378,6 +1381,94 @@ void Test::testStyleInheritance() CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), getProperty(properties, "FollowStyle")); } +void Test::testSmartart() +{ + uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY); + uno::Sequence aGrabBag(0); + xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; + CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty + + sal_Bool bTheme = sal_False; + for(int i = 0; i < aGrabBag.getLength(); ++i) + { + if (aGrabBag[i].Name == OUString("OOXTheme")) + { + bTheme = sal_True; + uno::Reference aThemeDom; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aThemeDom); // PropertyValue of proper type + CPPUNIT_ASSERT(aThemeDom.get()); // Reference not empty + } + } + CPPUNIT_ASSERT(bTheme); // Grab Bag has all the expected elements + + uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc + + uno::Reference xGroup(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xGroup->getCount()); // 3 rectangles and an arrow in the group + + uno::Reference xGroupPropertySet(getShape(1), uno::UNO_QUERY); + xGroupPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; + CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty + + sal_Bool bData = sal_False, bLayout = sal_False, bQStyle = sal_False, bColor = sal_False, bDrawing = sal_False; + for(int i = 0; i < aGrabBag.getLength(); ++i) + { + if (aGrabBag[i].Name == OUString("OOXData")) + { + bData = sal_True; + uno::Reference aDataDom; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aDataDom); // PropertyValue of proper type + CPPUNIT_ASSERT(aDataDom.get()); // Reference not empty + } + else if (aGrabBag[i].Name == OUString("OOXLayout")) + { + bLayout = sal_True; + uno::Reference aLayoutDom; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aLayoutDom); // PropertyValue of proper type + CPPUNIT_ASSERT(aLayoutDom.get()); // Reference not empty + } + else if (aGrabBag[i].Name == OUString("OOXStyle")) + { + bQStyle = sal_True; + uno::Reference aStyleDom; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aStyleDom); // PropertyValue of proper type + CPPUNIT_ASSERT(aStyleDom.get()); // Reference not empty + } + else if (aGrabBag[i].Name == OUString("OOXColor")) + { + bColor = sal_True; + uno::Reference aColorDom; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aColorDom); // PropertyValue of proper type + CPPUNIT_ASSERT(aColorDom.get()); // Reference not empty + } + else if (aGrabBag[i].Name == OUString("OOXDrawing")) + { + bDrawing = sal_True; + uno::Reference aDrawingDom; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aDrawingDom); // PropertyValue of proper type + CPPUNIT_ASSERT(aDrawingDom.get()); // Reference not empty + } + } + CPPUNIT_ASSERT(bData && bLayout && bQStyle && bColor && bDrawing); // Grab Bag has all the expected elements + + uno::Reference 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 xTextRange(xGroup->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Sample"), xTextRange->getString()); // Shape has text + + uno::Reference xParaEnumAccess(xTextRange->getText(), uno::UNO_QUERY); + uno::Reference 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 +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/ooxmlimport/data/smartart.docx b/sw/qa/extras/ooxmlimport/data/smartart.docx deleted file mode 100644 index 7a553f425188..000000000000 Binary files a/sw/qa/extras/ooxmlimport/data/smartart.docx and /dev/null differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index a76086552101..fc03f75805da 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -64,7 +64,6 @@ public: void testN652364(); void testN760764(); void testN764005(); - void testSmartart(); void testN764745(); void testN766477(); void testN758883(); @@ -164,7 +163,6 @@ void Test::run() {"n652364.docx", &Test::testN652364}, {"n760764.docx", &Test::testN760764}, {"n764005.docx", &Test::testN764005}, - {"smartart.docx", &Test::testSmartart}, {"n764745-alignment.docx", &Test::testN764745}, {"n766477.docx", &Test::testN766477}, {"n758883.docx", &Test::testN758883}, @@ -537,94 +535,6 @@ void Test::testN764005() CPPUNIT_ASSERT_EQUAL(false, bool(bValue)); } -void Test::testSmartart() -{ - uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY); - uno::Sequence aGrabBag(0); - xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; - CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty - - sal_Bool bTheme = sal_False; - for(int i = 0; i < aGrabBag.getLength(); ++i) - { - if (aGrabBag[i].Name == OUString("OOXTheme")) - { - bTheme = sal_True; - uno::Reference aThemeDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aThemeDom); // PropertyValue of proper type - CPPUNIT_ASSERT(aThemeDom.get()); // Reference not empty - } - } - CPPUNIT_ASSERT(bTheme); // Grab Bag has all the expected elements - - uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc - - uno::Reference xGroup(getShape(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xGroup->getCount()); // 3 rectangles and an arrow in the group - - uno::Reference xGroupPropertySet(getShape(1), uno::UNO_QUERY); - xGroupPropertySet->getPropertyValue(OUString::createFromAscii("InteropGrabBag")) >>= aGrabBag; - CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty - - sal_Bool bData = sal_False, bLayout = sal_False, bQStyle = sal_False, bColor = sal_False, bDrawing = sal_False; - for(int i = 0; i < aGrabBag.getLength(); ++i) - { - if (aGrabBag[i].Name == OUString::createFromAscii("OOXData")) - { - bData = sal_True; - uno::Reference aDataDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aDataDom); // PropertyValue of proper type - CPPUNIT_ASSERT(aDataDom.get()); // Reference not empty - } - else if (aGrabBag[i].Name == OUString::createFromAscii("OOXLayout")) - { - bLayout = sal_True; - uno::Reference aLayoutDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aLayoutDom); // PropertyValue of proper type - CPPUNIT_ASSERT(aLayoutDom.get()); // Reference not empty - } - else if (aGrabBag[i].Name == OUString::createFromAscii("OOXStyle")) - { - bQStyle = sal_True; - uno::Reference aStyleDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aStyleDom); // PropertyValue of proper type - CPPUNIT_ASSERT(aStyleDom.get()); // Reference not empty - } - else if (aGrabBag[i].Name == OUString::createFromAscii("OOXColor")) - { - bColor = sal_True; - uno::Reference aColorDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aColorDom); // PropertyValue of proper type - CPPUNIT_ASSERT(aColorDom.get()); // Reference not empty - } - else if (aGrabBag[i].Name == OUString::createFromAscii("OOXDrawing")) - { - bDrawing = sal_True; - uno::Reference aDrawingDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aDrawingDom); // PropertyValue of proper type - CPPUNIT_ASSERT(aDrawingDom.get()); // Reference not empty - } - } - CPPUNIT_ASSERT(bData && bLayout && bQStyle && bColor && bDrawing); // Grab Bag has all the expected elements - - uno::Reference 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 xTextRange(xGroup->getByIndex(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Sample"), xTextRange->getString()); // Shape has text - - uno::Reference xParaEnumAccess(xTextRange->getText(), uno::UNO_QUERY); - uno::Reference 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::testN764745() { /* -- cgit