summaryrefslogtreecommitdiff
path: root/sw/qa/api
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2019-03-14 00:31:19 +0100
committerBjörn Michaelsen <bjoern.michaelsen@libreoffice.org>2019-03-17 18:07:38 +0100
commit5a342653a288f7cf496acb7c3d5d81c459615de9 (patch)
tree75f5b268b14a59950586e3dab64af0245819ed2c /sw/qa/api
parent5d1bc45e807dded3041eadeb5483ed67c0b028f0 (diff)
remove this nonsense of init() returning a map, and then ...
- make the DocumentIndex and the DocumentSettings test against XServiceInfo and XComponent, if applicable - fix SwXDocumentSettings implementation name to meet expectations, almost [API CHANGE] - leave out tests on Desktop->terminate() for now though Change-Id: I1e1ab69dd6f6aa67f2cb9291a5665f3f94ff4a38 Reviewed-on: https://gerrit.libreoffice.org/69339 Tested-by: Jenkins Reviewed-by: Björn Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw/qa/api')
-rw-r--r--sw/qa/api/ApiTestBase.hxx4
-rw-r--r--sw/qa/api/BaseIndexTest.hxx5
-rw-r--r--sw/qa/api/DocumentIndexTest.hxx4
-rw-r--r--sw/qa/api/DocumentSettings.cxx23
-rw-r--r--sw/qa/api/DocumentSettingsTest.hxx6
-rw-r--r--sw/qa/api/PrinterSettingsTest.hxx4
-rw-r--r--sw/qa/api/SettingsTest.hxx5
-rw-r--r--sw/qa/api/SwXDocumentIndex.cxx68
-rw-r--r--sw/qa/api/SwXTextTable.cxx3
-rw-r--r--sw/qa/api/XDocumentIndexTest.hxx28
-rw-r--r--sw/qa/api/XTextContentTest.hxx20
11 files changed, 64 insertions, 106 deletions
diff --git a/sw/qa/api/ApiTestBase.hxx b/sw/qa/api/ApiTestBase.hxx
index fc25bc3122be..4abf53eb2462 100644
--- a/sw/qa/api/ApiTestBase.hxx
+++ b/sw/qa/api/ApiTestBase.hxx
@@ -15,8 +15,6 @@
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
-#include <unordered_map>
-
namespace apitest
{
class ApiTestBase
@@ -50,7 +48,7 @@ protected:
virtual ~ApiTestBase() {}
- virtual std::unordered_map<OUString, css::uno::Reference<css::uno::XInterface>> init() = 0;
+ virtual css::uno::Reference<css::uno::XInterface> init() = 0;
};
}
diff --git a/sw/qa/api/BaseIndexTest.hxx b/sw/qa/api/BaseIndexTest.hxx
index 997f91aa948f..cfad380ca493 100644
--- a/sw/qa/api/BaseIndexTest.hxx
+++ b/sw/qa/api/BaseIndexTest.hxx
@@ -58,10 +58,7 @@ class BaseIndexTest : public ApiTestBase
public:
void testBaseIndexProperties()
{
- auto map = init();
-
- css::uno::Reference<css::beans::XPropertySet> xBaseIndex(map["text::BaseIndex"],
- css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::beans::XPropertySet> xBaseIndex(init(), css::uno::UNO_QUERY_THROW);
testStringProperty(xBaseIndex, "Title", "Value");
testBooleanProperty(xBaseIndex, "IsProtected");
diff --git a/sw/qa/api/DocumentIndexTest.hxx b/sw/qa/api/DocumentIndexTest.hxx
index 0757c1dd492f..67804388c47d 100644
--- a/sw/qa/api/DocumentIndexTest.hxx
+++ b/sw/qa/api/DocumentIndexTest.hxx
@@ -24,9 +24,7 @@ class DocumentIndexTest : public ApiTestBase
public:
void testDocumentIndexProperties()
{
- auto map = init();
-
- css::uno::Reference<css::beans::XPropertySet> xDocumnetIndex(map["text::DocumentIndex"],
+ css::uno::Reference<css::beans::XPropertySet> xDocumnetIndex(init(),
css::uno::UNO_QUERY_THROW);
testBooleanProperty(xDocumnetIndex, "UseAlphabeticalSeparators");
diff --git a/sw/qa/api/DocumentSettings.cxx b/sw/qa/api/DocumentSettings.cxx
index 901730d0d65d..f2b48cc675f9 100644
--- a/sw/qa/api/DocumentSettings.cxx
+++ b/sw/qa/api/DocumentSettings.cxx
@@ -8,6 +8,7 @@
*/
#include <test/bootstrapfixture.hxx>
+#include <test/lang/xserviceinfo.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
@@ -35,7 +36,8 @@ class DocumentSettingsTest : public test::BootstrapFixture,
public unotest::MacrosTest,
public apitest::DocumentSettingsTest,
public apitest::SettingsTest,
- public apitest::PrinterSettingsTest
+ public apitest::PrinterSettingsTest,
+ public apitest::XServiceInfo
{
private:
uno::Reference<uno::XComponentContext> mxComponentContext;
@@ -45,9 +47,14 @@ public:
virtual void setUp() override;
virtual void tearDown() override;
- std::unordered_map<OUString, uno::Reference<uno::XInterface>> init() override;
+ DocumentSettingsTest()
+ : apitest::XServiceInfo("SwXDocumentSettings", "com.sun.star.text.DocumentSettings"){};
+ uno::Reference<uno::XInterface> init() override;
CPPUNIT_TEST_SUITE(DocumentSettingsTest);
+ CPPUNIT_TEST(testGetImplementationName);
+ CPPUNIT_TEST(testGetSupportedServiceNames);
+ CPPUNIT_TEST(testSupportsService);
CPPUNIT_TEST(testDocumentSettingsProperties);
CPPUNIT_TEST(testSettingsProperties);
CPPUNIT_TEST(testPrinterSettingsProperties);
@@ -70,10 +77,8 @@ void DocumentSettingsTest::tearDown()
test::BootstrapFixture::tearDown();
}
-std::unordered_map<OUString, uno::Reference<uno::XInterface>> DocumentSettingsTest::init()
+uno::Reference<uno::XInterface> DocumentSettingsTest::init()
{
- std::unordered_map<OUString, uno::Reference<uno::XInterface>> map;
-
mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
CPPUNIT_ASSERT(mxComponent.is());
@@ -83,13 +88,7 @@ std::unordered_map<OUString, uno::Reference<uno::XInterface>> DocumentSettingsTe
uno::Reference<uno::XInterface> xDocumentSettings(
xFactory->createInstance("com.sun.star.text.DocumentSettings"), uno::UNO_QUERY_THROW);
- // DocumentSettings
- map["text::DocumentSettings"] = xDocumentSettings;
- // Settings
- map["document::Settings"] = xDocumentSettings;
- // Printer Settings
- map["text::PrinterSettings"] = xDocumentSettings;
- return map;
+ return xDocumentSettings;
}
CPPUNIT_TEST_SUITE_REGISTRATION(DocumentSettingsTest);
diff --git a/sw/qa/api/DocumentSettingsTest.hxx b/sw/qa/api/DocumentSettingsTest.hxx
index 35508e0d74a6..4abd8d197d35 100644
--- a/sw/qa/api/DocumentSettingsTest.hxx
+++ b/sw/qa/api/DocumentSettingsTest.hxx
@@ -24,10 +24,8 @@ class DocumentSettingsTest : public ApiTestBase
public:
void testDocumentSettingsProperties()
{
- auto map = init();
-
- css::uno::Reference<css::beans::XPropertySet> xDocumentSettings(
- map["text::DocumentSettings"], css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::beans::XPropertySet> xDocumentSettings(init(),
+ css::uno::UNO_QUERY_THROW);
testBooleanOptionalProperty(xDocumentSettings, "ChartAutoUpdate");
testBooleanOptionalProperty(xDocumentSettings, "AddParaTableSpacing");
diff --git a/sw/qa/api/PrinterSettingsTest.hxx b/sw/qa/api/PrinterSettingsTest.hxx
index 7e8e157af0b2..8d93564c20ea 100644
--- a/sw/qa/api/PrinterSettingsTest.hxx
+++ b/sw/qa/api/PrinterSettingsTest.hxx
@@ -52,9 +52,7 @@ class PrinterSettingsTest : public ApiTestBase
public:
void testPrinterSettingsProperties()
{
- auto map = init();
-
- css::uno::Reference<css::beans::XPropertySet> xPrinterSettings(map["text::PrinterSettings"],
+ css::uno::Reference<css::beans::XPropertySet> xPrinterSettings(init(),
css::uno::UNO_QUERY_THROW);
testBooleanProperty(xPrinterSettings, "PrintGraphics");
diff --git a/sw/qa/api/SettingsTest.hxx b/sw/qa/api/SettingsTest.hxx
index 73cfcfddecf2..48e236d6160f 100644
--- a/sw/qa/api/SettingsTest.hxx
+++ b/sw/qa/api/SettingsTest.hxx
@@ -93,10 +93,7 @@ class SettingsTest : public ApiTestBase
public:
void testSettingsProperties()
{
- auto map = init();
-
- css::uno::Reference<css::beans::XPropertySet> xSettings(map["document::Settings"],
- css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::beans::XPropertySet> xSettings(init(), css::uno::UNO_QUERY_THROW);
testForbiddenCharacters(xSettings);
//testShortOptionalProperty(xSettings, "LinkUpdateMode");
diff --git a/sw/qa/api/SwXDocumentIndex.cxx b/sw/qa/api/SwXDocumentIndex.cxx
index ea082b9051e2..74530d4712f4 100644
--- a/sw/qa/api/SwXDocumentIndex.cxx
+++ b/sw/qa/api/SwXDocumentIndex.cxx
@@ -13,6 +13,8 @@
#include "XTextContentTest.hxx"
#include <test/bootstrapfixture.hxx>
+#include <test/lang/xserviceinfo.hxx>
+#include <test/lang/xcomponent.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
@@ -40,24 +42,34 @@ class SwXDocumentIndexTest : public test::BootstrapFixture,
public apitest::XDocumentIndexTest,
public apitest::BaseIndexTest,
public apitest::DocumentIndexTest,
- public apitest::XTextContentTest
+ public apitest::XTextContentTest,
+ public apitest::XServiceInfo,
+ public apitest::XComponent
{
uno::Reference<uno::XComponentContext> mxComponentContext;
- uno::Reference<lang::XComponent> mxComponent;
+ uno::Reference<text::XTextDocument> mxTextDocument;
public:
virtual void setUp() override;
virtual void tearDown() override;
- std::unordered_map<OUString, uno::Reference<uno::XInterface>> init() override;
+ SwXDocumentIndexTest()
+ : apitest::XServiceInfo("SwXDocumentIndex", "com.sun.star.text.BaseIndex"){};
+ uno::Reference<uno::XInterface> init() override;
+ uno::Reference<text::XTextDocument> getTextDocument() override { return mxTextDocument; }
+ void triggerDesktopTerminate() override {}
CPPUNIT_TEST_SUITE(SwXDocumentIndexTest);
- CPPUNIT_TEST(testGetServiceName);
+ CPPUNIT_TEST(testGetImplementationName);
+ CPPUNIT_TEST(testGetSupportedServiceNames);
+ CPPUNIT_TEST(testSupportsService);
CPPUNIT_TEST(testUpdate);
CPPUNIT_TEST(testBaseIndexProperties);
CPPUNIT_TEST(testDocumentIndexProperties);
CPPUNIT_TEST(testAttach);
CPPUNIT_TEST(testGetAnchor);
+ CPPUNIT_TEST(testAddEventListener);
+ CPPUNIT_TEST(testRemoveEventListener);
CPPUNIT_TEST_SUITE_END();
};
@@ -67,53 +79,31 @@ void SwXDocumentIndexTest::setUp()
mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory()));
mxDesktop.set(frame::Desktop::create(mxComponentContext));
+ mxTextDocument = uno::Reference<text::XTextDocument>(
+ loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"),
+ uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(mxTextDocument.is());
}
void SwXDocumentIndexTest::tearDown()
{
- if (mxComponent.is())
- mxComponent->dispose();
+ if (mxTextDocument.is())
+ mxTextDocument->dispose();
test::BootstrapFixture::tearDown();
}
-std::unordered_map<OUString, uno::Reference<uno::XInterface>> SwXDocumentIndexTest::init()
+uno::Reference<uno::XInterface> SwXDocumentIndexTest::init()
{
- std::unordered_map<OUString, uno::Reference<uno::XInterface>> map;
-
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
- CPPUNIT_ASSERT(mxComponent.is());
-
- uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY_THROW);
- uno::Reference<lang::XMultiServiceFactory> xFactory(xTextDocument, uno::UNO_QUERY_THROW);
-
+ uno::Reference<lang::XMultiServiceFactory> xMSF(mxTextDocument, uno::UNO_QUERY_THROW);
uno::Reference<text::XDocumentIndex> xDocumentIndex(
- xFactory->createInstance("com.sun.star.text.DocumentIndex"), uno::UNO_QUERY_THROW);
-
- uno::Reference<text::XTextContent> xTextContent(xDocumentIndex, uno::UNO_QUERY_THROW);
-
- uno::Reference<text::XText> xText = xTextDocument->getText();
- uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor();
+ xMSF->createInstance("com.sun.star.text.DocumentIndex"), uno::UNO_QUERY_THROW);
+ auto xText = getTextDocument()->getText();
+ auto xTextCursor = xText->createTextCursor();
CPPUNIT_ASSERT(xTextCursor.is());
- xText->insertTextContent(xTextCursor, xTextContent, false);
+ xText->insertTextContent(xTextCursor, xDocumentIndex, false);
xTextCursor->gotoEnd(false);
-
- uno::Reference<text::XDocumentIndex> xDocumentIndexInstance(
- xFactory->createInstance("com.sun.star.text.DocumentIndex"), uno::UNO_QUERY_THROW);
-
- // XDocumentIndexTest
- map["text::XDocumentIndex"] = xDocumentIndex;
- map["text::XTextDocument"] = xTextDocument;
- // BaseIndexTest
- map["text::BaseIndex"] = xDocumentIndex;
- // DocumentIndex
- map["text::DocumentIndex"] = xDocumentIndex;
- // XTextContentTest
- map["text::XTextRange"] = xTextCursor;
- map["text::XTextContent"] = xDocumentIndex;
- map["text::XTextContent#Instance"] = xDocumentIndexInstance;
-
- return map;
+ return xDocumentIndex;
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwXDocumentIndexTest);
diff --git a/sw/qa/api/SwXTextTable.cxx b/sw/qa/api/SwXTextTable.cxx
index e35de37c0024..bc4e0271ccf4 100644
--- a/sw/qa/api/SwXTextTable.cxx
+++ b/sw/qa/api/SwXTextTable.cxx
@@ -7,14 +7,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include "XTextContentTest.hxx"
-
#include <test/bootstrapfixture.hxx>
#include <test/lang/xcomponent.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
-//#include <com/sun/star/frame/DispatchHelper.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
diff --git a/sw/qa/api/XDocumentIndexTest.hxx b/sw/qa/api/XDocumentIndexTest.hxx
index c181a10ac76f..cb3eab3ce9bf 100644
--- a/sw/qa/api/XDocumentIndexTest.hxx
+++ b/sw/qa/api/XDocumentIndexTest.hxx
@@ -33,19 +33,7 @@ namespace apitest
class XDocumentIndexTest : public ApiTestBase
{
public:
- /**
- * Has <b>OK</b> status if the returned service name
- * is equal to 'com.sun.star.text.DocumentIndex'.
- */
- void testGetServiceName()
- {
- auto inputMap = init();
-
- css::uno::Reference<css::text::XDocumentIndex> xDocumentIndex(
- inputMap["text::XDocumentIndex"], css::uno::UNO_QUERY_THROW);
- CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.text.DocumentIndex"),
- xDocumentIndex->getServiceName());
- }
+ virtual css::uno::Reference<css::text::XTextDocument> getTextDocument() = 0;
/**
* Gets the document from relation and insert a new index mark.
@@ -57,21 +45,17 @@ public:
*/
void testUpdate()
{
- auto inputMap = init();
-
- css::uno::Reference<css::text::XDocumentIndex> xDocumentIndex(
- inputMap["text::XDocumentIndex"], css::uno::UNO_QUERY_THROW);
- css::uno::Reference<css::text::XTextDocument> xTextDocument(inputMap["text::XTextDocument"],
- css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::text::XDocumentIndex> xDocumentIndex(init(),
+ css::uno::UNO_QUERY_THROW);
bool bOK = true;
try
{
- css::uno::Reference<css::text::XText> xText = xTextDocument->getText();
- css::uno::Reference<css::text::XTextRange> xTextRange = xText->getEnd();
+ auto xText = getTextDocument()->getText();
+ auto xTextRange = xText->getEnd();
xTextRange->setString("IndexMark");
css::uno::Reference<css::lang::XMultiServiceFactory> xFactory(
- xTextDocument, css::uno::UNO_QUERY_THROW);
+ getTextDocument(), css::uno::UNO_QUERY_THROW);
css::uno::Reference<css::text::XTextContent> xTextContentMark(
xFactory->createInstance("com.sun.star.text.DocumentIndexMark"),
css::uno::UNO_QUERY_THROW);
diff --git a/sw/qa/api/XTextContentTest.hxx b/sw/qa/api/XTextContentTest.hxx
index f3227a5c2204..e8bf94fbce9c 100644
--- a/sw/qa/api/XTextContentTest.hxx
+++ b/sw/qa/api/XTextContentTest.hxx
@@ -26,6 +26,7 @@ namespace apitest
class XTextContentTest : public ApiTestBase
{
public:
+ virtual css::uno::Reference<css::text::XTextDocument> getTextDocument() = 0;
/**
* Tries to attach the text content to the test range
* gotten with getAnchor(). If relations are found
@@ -35,19 +36,20 @@ public:
*/
void testAttach()
{
- auto map = init();
- css::uno::Reference<css::text::XTextContent> xTextContent(
- map["text::XTextContent#Instance"], css::uno::UNO_QUERY_THROW);
- css::uno::Reference<css::text::XTextRange> xTextRange(map["text::XTextRange"],
- css::uno::UNO_QUERY_THROW);
-
- xTextContent->attach(xTextRange);
+ css::uno::Reference<css::text::XTextContent> xTextContent(init(),
+ css::uno::UNO_QUERY_THROW);
+ auto xTextCursor = getTextDocument()->getText()->createTextCursor();
+ xTextCursor->gotoEnd(false);
+ css::uno::Reference<css::lang::XMultiServiceFactory> xMSF(getTextDocument(),
+ css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::text::XDocumentIndex> xDocumentIndex(
+ xMSF->createInstance("com.sun.star.text.DocumentIndex"), css::uno::UNO_QUERY_THROW);
+ xDocumentIndex->attach(xTextCursor);
}
void testGetAnchor()
{
- auto map = init();
- css::uno::Reference<css::text::XTextContent> xTextContent(map["text::XTextContent"],
+ css::uno::Reference<css::text::XTextContent> xTextContent(init(),
css::uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(OUString(""), xTextContent->getAnchor()->getString());
}