summaryrefslogtreecommitdiff
path: root/sw/qa/unit
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-11-11 12:21:15 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-11-11 15:47:14 +0100
commit6d37a3e40bd08ccb1edb778088c8a627e728ccc5 (patch)
treee0e942bf17e9ebb507d9e122c515e21862d3fd9b /sw/qa/unit
parentb74d50003145f3805e3316a51c8be0222e680152 (diff)
SwModelTestBase: Check supportsService
Also simplify code a bit Change-Id: I93b277116cd21f9e7e058fdf31e0defab8247f13 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142581 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw/qa/unit')
-rw-r--r--sw/qa/unit/swmodeltestbase.cxx34
1 files changed, 25 insertions, 9 deletions
diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx
index d675c18c2617..b619b7e69779 100644
--- a/sw/qa/unit/swmodeltestbase.cxx
+++ b/sw/qa/unit/swmodeltestbase.cxx
@@ -462,8 +462,7 @@ void SwModelTestBase::setTestInteractionHandler(const char* pPassword,
void SwModelTestBase::header() {}
-void SwModelTestBase::loadURLWithComponent(OUString const& rURL, OUString const& rComponent,
- const char* pName, const char* pPassword)
+void SwModelTestBase::loadURL(OUString const& rURL, const char* pName, const char* pPassword)
{
if (mxComponent.is())
mxComponent->dispose();
@@ -500,7 +499,7 @@ void SwModelTestBase::loadURLWithComponent(OUString const& rURL, OUString const&
}
mxComponent
- = loadFromDesktop(rURL, rComponent, comphelper::containerToSequence(aFilterOptions));
+ = loadFromDesktop(rURL, OUString(), comphelper::containerToSequence(aFilterOptions));
if (pPassword)
{
@@ -517,7 +516,7 @@ void SwModelTestBase::reload(const char* pFilter, const char* pName, const char*
{
save(OUString::createFromAscii(pFilter), pName, pPassword);
- loadURLWithComponent(maTempFile.GetURL(), "com.sun.star.text.TextDocument", pName, pPassword);
+ loadURL(maTempFile.GetURL(), pName, pPassword);
}
void SwModelTestBase::save(const OUString& aFilterName, const char* pName, const char* pPassword)
@@ -612,21 +611,38 @@ void SwModelTestBase::registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx)
SwDoc* SwModelTestBase::createSwDoc(const char* pName)
{
if (!pName)
- loadURLWithComponent("private:factory/swriter", "com.sun.star.text.TextDocument", pName,
- nullptr);
+ loadURL("private:factory/swriter", pName, nullptr);
else
load(pName);
+ uno::Reference<lang::XServiceInfo> xServiceInfo(mxComponent, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextDocument"));
+
return getSwDoc();
}
SwDoc* SwModelTestBase::createSwWebDoc(const char* pName)
{
if (!pName)
- loadURLWithComponent("private:factory/swriter/web", "com.sun.star.text.TextDocument", pName,
- nullptr);
+ loadURL("private:factory/swriter/web", pName, nullptr);
+ else
+ load(pName);
+
+ uno::Reference<lang::XServiceInfo> xServiceInfo(mxComponent, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.WebDocument"));
+
+ return getSwDoc();
+}
+
+SwDoc* SwModelTestBase::createSwGlobalDoc(const char* pName)
+{
+ if (!pName)
+ loadURL("private:factory/swriter/GlobalDocument", pName, nullptr);
else
- load_web(pName);
+ load(pName);
+
+ uno::Reference<lang::XServiceInfo> xServiceInfo(mxComponent, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.GlobalDocument"));
return getSwDoc();
}