From 2aa9e6a778c742cbc080dbefdf471e6771688661 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Wed, 4 Feb 2026 21:39:59 +0100 Subject: [PATCH] CppunitTest_sw_macros_test: fix tests fail when running individually They fail if run with make CppunitTest_sw_macros_test CPPUNIT_TEST_NAME="SwMacrosTest::testFdo55289" make CppunitTest_sw_macros_test CPPUNIT_TEST_NAME="SwMacrosTest::testBookmarkDeleteTdf90816" make CppunitTest_sw_macros_test CPPUNIT_TEST_NAME="SwMacrosTest::testBookmarkDeleteAndJoin" Change-Id: I16d7581137a57ce4d7721e6b32ca9081724ff062 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198705 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sw/qa/core/macros-test.cxx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx index 51c30ade0012..2ad0e7d2186c 100644 --- a/sw/qa/core/macros-test.cxx +++ b/sw/qa/core/macros-test.cxx @@ -49,10 +49,9 @@ #include #include #include +#include #include -typedef rtl::Reference SwDocShellRef; - using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -177,7 +176,11 @@ void SwMacrosTest::testModernVBADelete() void SwMacrosTest::testBookmarkDeleteAndJoin() { - rtl::Reference const pDoc(new SwDoc); + loadFromURL(u"private:factory/swriter"_ustr); + + SwXTextDocument *const pTextDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc *const pDoc = pTextDoc->GetDocShell()->GetDoc(); pDoc->GetIDocumentUndoRedo().DoUndo(true); // bug is in SwUndoDelete SwNodeIndex aIdx(pDoc->GetNodes().GetEndOfContent(), -1); SwPaM aPaM(aIdx); @@ -217,7 +220,11 @@ void SwMacrosTest::testBookmarkDeleteAndJoin() void SwMacrosTest::testBookmarkDeleteTdf90816() { - rtl::Reference const pDoc(new SwDoc); + loadFromURL(u"private:factory/swriter"_ustr); + + SwXTextDocument *const pTextDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc *const pDoc = pTextDoc->GetDocShell()->GetDoc(); pDoc->GetIDocumentUndoRedo().DoUndo(true); // bug is in SwUndoDelete SwNodeIndex aIdx(pDoc->GetNodes().GetEndOfContent(), -1); SwPaM aPaM(aIdx); @@ -387,8 +394,9 @@ void SwMacrosTest::testTdf162431() void SwMacrosTest::testFdo55289() { + SwGlobals::ensure(); SwDoc* const pDoc = new SwDoc; - SwDocShellRef pDocShell = new SwDocShell(*pDoc, SfxObjectCreateMode::EMBEDDED); + rtl::Reference pDocShell = new SwDocShell(*pDoc, SfxObjectCreateMode::EMBEDDED); // this needs to run with no layout to tickle the bugs in the special // cases in SwXShape re-anchoring assert(!pDoc->getIDocumentLayoutAccess().GetCurrentLayout());