sw/CppunitTest_sw_macros_test.mk |1
sw/qa/core/macros-test.cxx | 144 ++-
2 files changed, 25 insertions(+), 120 deletions(-)
New commits:
commit 7c49e352ec8a5840943cadf6382db8fd812b7250
Author: Xisco Fauli
AuthorDate: Tue Oct 25 12:39:50 2022 +0200
Commit: Xisco Fauli
CommitDate: Tue Oct 25 14:00:07 2022 +0200
CppunitTest_sw_macros_test: inherit from UnoApiTest
Change-Id: I2ce2c55bd718d153f038736e5474d6ead4f8c5c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141806
Tested-by: Jenkins
Reviewed-by: Xisco Fauli
diff --git a/sw/CppunitTest_sw_macros_test.mk b/sw/CppunitTest_sw_macros_test.mk
index 805242613b58..74887fa70ea3 100644
--- a/sw/CppunitTest_sw_macros_test.mk
+++ b/sw/CppunitTest_sw_macros_test.mk
@@ -38,6 +38,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_macros_test, \
sw \
sfx \
sot \
+subsequenttest \
svl \
svt \
svx \
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 23a489517b11..0dd756cb97eb 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -11,8 +11,7 @@
#include
-#include
-#include
+#include
#include
#include
@@ -27,7 +26,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -59,16 +57,11 @@ using namespace ::com::sun::star::uno;
/* Implementation of Macros test */
-class SwMacrosTest : public test::BootstrapFixture, public unotest::MacrosTest
+class SwMacrosTest : public UnoApiTest
{
public:
SwMacrosTest();
-void createFileURL(std::u16string_view aFile, OUString& rFilePath);
-
-virtual void setUp() override;
-virtual void tearDown() override;
-
void testVba();
void testBookmarkDeleteAndJoin();
void testBookmarkDeleteTdf90816();
@@ -88,21 +81,8 @@ public:
CPPUNIT_TEST(testFdo87530);
CPPUNIT_TEST(testFindReplace);
CPPUNIT_TEST_SUITE_END();
-
-private:
-uno::Reference m_xWriterComponent;
-OUString m_aBaseString;
};
-void SwMacrosTest::createFileURL(std::u16string_view aFile, OUString&
rFilePath)
-{
-auto i = aFile.find_last_of('.');
-CPPUNIT_ASSERT_MESSAGE("Missing Extension", i != std::string_view::npos);
-std::u16string_view aFileExtension = aFile.substr(i+1);
-
-rFilePath = m_directories.getSrcRootURL() + m_aBaseString + "/" +
aFileExtension + "/" + aFile;
-}
-
void SwMacrosTest::testVba()
{
TestMacroInfo testInfo[] = {
@@ -149,23 +129,16 @@ void SwMacrosTest::testVba()
};
for ( size_t i=0; i xComponent =
loadFromDesktop(aFileName, "com.sun.star.text.TextDocument");
-OUString sUrl = testInfo[i].sMacroUrl;
-Any aRet;
-Sequence< sal_Int16 > aOutParamIndex;
-Sequence< Any > aOutParam;
-Sequence< uno::Any > aParams;
-
-SfxObjectShell* pFoundShell =
SfxObjectShell::GetShellFromComponent(xComponent);
-
-CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
-CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE,
SfxObjectShell::CallXScript(xComponent, sUrl, aParams, aRet,
aOutParamIndex,aOutParam));
+OUString sFileName("docm/" + testInfo[i].sFileBaseName);
+loadFromURL(sFileName);
+
+uno::Any aRet = executeMacro(testInfo[i].sMacroUrl);
OUString aStringRes;
CPPUNIT_ASSERT(aRet >>= aStringRes);
CPPUNIT_ASSERT_EQUAL(OUString("OK"), aStringRes);
-pFoundShell->DoClose();
+
+mxComponent->dispose();
+mxComponent.clear();
}
}
@@ -241,12 +214,9 @@ void SwMacrosTest::testBookmarkDeleteTdf90816()
void SwMacrosTest::testControlShapeGrouping()
{
-OUString aFileName;
-createFileURL(u"testControlShapeGrouping.odt", aFileName);
-Reference< css::lang::XComponent > xComponent(
-loadFromDesktop(aFileName, "com.sun.star.text.TextDocument"));
+loadFromURL(u"odt/testControlShapeGrouping.odt");
-uno::Reference const xModel(xComponent, UNO_QUERY);
+uno::Reference const xModel(mxComponent, UNO_QUERY);
CPPUNIT_ASSERT(xModel.is());
uno::Reference xFactory(xModel, UNO_QUERY);
uno::Reference const xDPS(xModel, UNO_QUERY);
@@ -340,10 +310,6 @@ void SwMacrosTest::testControlShapeGrouping()
CPPUNIT_ASSERT_EQUAL(xTS->getControl(), xTimeControlModel);
}
#endif
-
-// close
-Reference xDocCloseable(xComponent, UNO_QUERY_THROW);
-xDocCloseable->close(false);
}
void SwMacrosTest::testFdo55289()
@@ -381,26 +347,13 @@ void SwMacrosTest::testFdo55289()
void SwMacrosTest::testFdo68983()
{
-OUString aFileName;
-createFileURL(u"fdo68983.odt", aFileName);
-Reference< css::lang::XComponent > xComponent =
-loadFromDesktop(aFileName, "com.sun.star.text.TextDocument");
-Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW);
-
-utl::TempFileNamed aTempFile;
-aTempFile.EnableKillingFile();
-Sequence desc(