sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 66 +++++++++++++++-------------- 1 file changed, 35 insertions(+), 31 deletions(-)
New commits: commit aa6882da4b43f52ef1f92fa0bc500aec9878ed54 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Oct 24 20:17:50 2023 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Oct 25 08:11:36 2023 +0200 CppunitTest_sw_ooxmlexport10: avoid preTest() This keeps all code of a test in a single place, if we don't trigger the preTest() magic. Change-Id: I13254fd11be344f84e0a8bb8eab4b93d7c1a8825 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158400 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index fb01ab2b47ba..50dc74101a62 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -33,26 +33,12 @@ #include <unotools/fltrcfg.hxx> #include <comphelper/sequenceashashmap.hxx> #include <oox/drawingml/drawingmltypes.hxx> +#include <comphelper/scopeguard.hxx> class Test : public SwModelTestBase { public: Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {} - - virtual std::unique_ptr<Resetter> preTest(const char* filename) override - { - if (filename == std::string_view("smartart.docx") - || filename == std::string_view("strict-smartart.docx") ) - { - std::unique_ptr<Resetter> pResetter(new Resetter( - [] () { - SvtFilterOptions::Get().SetSmartArt2Shape(false); - })); - SvtFilterOptions::Get().SetSmartArt2Shape(true); - return pResetter; - } - return nullptr; - } }; DECLARE_OOXMLEXPORT_TEST(testWPGtextboxes, "testWPGtextboxes.docx") @@ -74,23 +60,32 @@ DECLARE_OOXMLEXPORT_TEST(testWPGtextboxes, "testWPGtextboxes.docx") } -DECLARE_OOXMLEXPORT_TEST(testSmartart, "smartart.docx") +CPPUNIT_TEST_FIXTURE(Test, testSmartart) { - CPPUNIT_ASSERT_EQUAL(1, getShapes()); + SvtFilterOptions::Get().SetSmartArt2Shape(true); + comphelper::ScopeGuard g([] { SvtFilterOptions::Get().SetSmartArt2Shape(false); }); - uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xGroup->getCount()); // background, 3 rectangles and an arrow in the group + auto verify = [this]() { + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + + uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xGroup->getCount()); // background, 3 rectangles and an arrow in the group - uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(2), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(Color(0x4f81bd), getProperty<Color>(xPropertySet, "FillColor")); // If fill color is right, theme import is OK + uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(2), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(0x4f81bd), getProperty<Color>(xPropertySet, "FillColor")); // If fill color is right, theme import is OK - uno::Reference<text::XTextRange> xTextRange(xGroup->getByIndex(2), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Sample"), xTextRange->getString()); // Shape has text + uno::Reference<text::XTextRange> xTextRange(xGroup->getByIndex(2), 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); - CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_CENTER), getProperty<sal_Int32>( xPropertySet, "ParaAdjust")); // Paragraph properties are imported + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextRange->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + xPropertySet.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_CENTER), getProperty<sal_Int32>( xPropertySet, "ParaAdjust")); // Paragraph properties are imported + }; + createSwDoc("smartart.docx"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testFdo69548) @@ -534,11 +529,20 @@ DECLARE_OOXMLEXPORT_TEST(testStrict, "strict.docx") CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextEmbeddedObject")); } -DECLARE_OOXMLEXPORT_TEST(testSmartartStrict, "strict-smartart.docx") +CPPUNIT_TEST_FIXTURE(Test, testSmartartStrict) { - uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); - // This was 0, SmartArt was visually missing. - CPPUNIT_ASSERT_EQUAL(sal_Int32(7), xGroup->getCount()); // background, 3 ellipses + 3 arrows + SvtFilterOptions::Get().SetSmartArt2Shape(true); + comphelper::ScopeGuard g([] { SvtFilterOptions::Get().SetSmartArt2Shape(false); }); + + auto verify = [this]() { + uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); + // This was 0, SmartArt was visually missing. + CPPUNIT_ASSERT_EQUAL(sal_Int32(7), xGroup->getCount()); // background, 3 ellipses + 3 arrows + }; + createSwDoc("strict-smartart.docx"); + verify(); + saveAndReload(mpFilter); + verify(); } DECLARE_OOXMLEXPORT_TEST(testLibreOfficeHang, "frame-wrap-auto.docx")