summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2019-03-16 15:21:43 +0100
committerBjörn Michaelsen <bjoern.michaelsen@libreoffice.org>2019-03-19 08:38:34 +0100
commit3428ca9c3b98c275bbcd852e733aa42eef89bdd2 (patch)
tree5fc4d2e8c8705a6556094623a945032b24edaf19 /sw
parent09b9499de17991bbd6b808c0c7923fda6e616e79 (diff)
name apitest suites consistently while we still can
- writer test apitest suites are now called like the UNO implementation they are testing - also mark them final for good measure - move tests to module test and try to match its conventions * BaseIndex * TextDocumentIndex * TextDocumentSettings * TextPrinterSettings * TextSettings * XDocumentIndex - also remove anonymous namespace in header, as that is a bad idea - also remove now obsolete ApiBaseTest - also remove dead code in TextPrinterSettings - remove writer xtextcontent test as it duplicates the impl in module test Change-Id: I71aa5f3755d5c90726f4ff4394117fa2391495d7 Reviewed-on: https://gerrit.libreoffice.org/69374 Tested-by: Jenkins Reviewed-by: Björn Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/CppunitTest_sw_apitests.mk2
-rw-r--r--sw/qa/api/ApiTestBase.hxx57
-rw-r--r--sw/qa/api/BaseIndexTest.hxx161
-rw-r--r--sw/qa/api/DocumentIndexTest.hxx47
-rw-r--r--sw/qa/api/DocumentSettingsTest.hxx47
-rw-r--r--sw/qa/api/PrinterSettingsTest.hxx79
-rw-r--r--sw/qa/api/SettingsTest.hxx137
-rw-r--r--sw/qa/api/SwXDocumentIndex.cxx50
-rw-r--r--sw/qa/api/SwXDocumentSettings.cxx (renamed from sw/qa/api/DocumentSettings.cxx)31
-rw-r--r--sw/qa/api/XDocumentIndexTest.hxx85
-rw-r--r--sw/qa/api/XTextContentTest.hxx61
11 files changed, 47 insertions, 710 deletions
diff --git a/sw/CppunitTest_sw_apitests.mk b/sw/CppunitTest_sw_apitests.mk
index 1f850da50efc..ca2c919e0aa6 100644
--- a/sw/CppunitTest_sw_apitests.mk
+++ b/sw/CppunitTest_sw_apitests.mk
@@ -15,7 +15,7 @@ $(eval $(call gb_CppunitTest_use_external,sw_apitests,boost_headers))
$(eval $(call gb_CppunitTest_add_exception_objects,sw_apitests, \
sw/qa/api/SwXDocumentIndex \
- sw/qa/api/DocumentSettings \
+ sw/qa/api/SwXDocumentSettings \
sw/qa/api/SwXTextTable \
))
diff --git a/sw/qa/api/ApiTestBase.hxx b/sw/qa/api/ApiTestBase.hxx
deleted file mode 100644
index 4abf53eb2462..000000000000
--- a/sw/qa/api/ApiTestBase.hxx
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_SW_QA_CORE_APITESTBASE_HXX
-#define INCLUDED_SW_QA_CORE_APITESTBASE_HXX
-
-#include <com/sun/star/uno/XInterface.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/beans/XPropertySetInfo.hpp>
-#include <com/sun/star/beans/PropertyAttribute.hpp>
-
-namespace apitest
-{
-class ApiTestBase
-{
-protected:
- static bool extstsProperty(css::uno::Reference<css::beans::XPropertySet> const& rxPropertySet,
- OUString const& rPropertyName)
- {
- css::uno::Reference<css::beans::XPropertySetInfo> xPropertySetInfo(
- rxPropertySet->getPropertySetInfo());
- return xPropertySetInfo->hasPropertyByName(rPropertyName);
- }
-
- static bool
- isPropertyReadOnly(css::uno::Reference<css::beans::XPropertySet> const& rxPropertySet,
- OUString const& rPropertyName)
- {
- css::uno::Reference<css::beans::XPropertySetInfo> xPropertySetInfo(
- rxPropertySet->getPropertySetInfo());
- css::uno::Sequence<css::beans::Property> xProperties = xPropertySetInfo->getProperties();
-
- for (auto const& rProperty : xProperties)
- {
- if (rProperty.Name == rPropertyName)
- return (rProperty.Attributes & com::sun::star::beans::PropertyAttribute::READONLY)
- != 0;
- }
-
- return false;
- }
-
- virtual ~ApiTestBase() {}
-
- virtual css::uno::Reference<css::uno::XInterface> init() = 0;
-};
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/api/BaseIndexTest.hxx b/sw/qa/api/BaseIndexTest.hxx
deleted file mode 100644
index cfad380ca493..000000000000
--- a/sw/qa/api/BaseIndexTest.hxx
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_SW_QA_API_BASEINDEXTEST_HXX
-#define INCLUDED_SW_QA_API_BASEINDEXTEST_HXX
-
-#include "ApiTestBase.hxx"
-
-#include <cppunit/TestAssert.h>
-#include <test/unoapi_property_testers.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-
-#include <com/sun/star/text/XTextColumns.hpp>
-#include <com/sun/star/text/XTextSection.hpp>
-#include <com/sun/star/graphic/XGraphic.hpp>
-
-#include <vcl/BitmapTools.hxx>
-#include <vcl/graph.hxx>
-#include <vcl/pngwrite.hxx>
-#include <unotools/tempfile.hxx>
-#include <tools/stream.hxx>
-
-namespace apitest
-{
-namespace
-{
-BitmapEx createExampleBitmap()
-{
- vcl::bitmap::RawBitmap aRawBitmap(Size(4, 4), 24);
- aRawBitmap.SetPixel(0, 0, COL_LIGHTBLUE);
- aRawBitmap.SetPixel(0, 1, COL_LIGHTGREEN);
- aRawBitmap.SetPixel(1, 0, COL_LIGHTRED);
- aRawBitmap.SetPixel(1, 1, COL_LIGHTMAGENTA);
- return vcl::bitmap::CreateFromData(std::move(aRawBitmap));
-}
-
-void writerFileWithBitmap(OUString const& rURL)
-{
- BitmapEx aBitmapEx = createExampleBitmap();
- SvFileStream aFileStream(rURL, StreamMode::READ | StreamMode::WRITE);
- vcl::PNGWriter aWriter(aBitmapEx);
- aWriter.Write(aFileStream);
- aFileStream.Seek(STREAM_SEEK_TO_BEGIN);
- aFileStream.Close();
-}
-
-} // end anonymous namespace
-
-class BaseIndexTest : public ApiTestBase
-{
-public:
- void testBaseIndexProperties()
- {
- css::uno::Reference<css::beans::XPropertySet> xBaseIndex(init(), css::uno::UNO_QUERY_THROW);
- testStringProperty(xBaseIndex, "Title", "Value");
- testBooleanProperty(xBaseIndex, "IsProtected");
-
- testStringProperty(xBaseIndex, "ParaStyleHeading", "Value");
- testStringProperty(xBaseIndex, "ParaStyleLevel1", "Value");
- testStringOptionalProperty(xBaseIndex, "ParaStyleLevel2");
- testStringOptionalProperty(xBaseIndex, "ParaStyleLevel3");
- testStringOptionalProperty(xBaseIndex, "ParaStyleLevel4");
- testStringOptionalProperty(xBaseIndex, "ParaStyleLevel5");
- testStringOptionalProperty(xBaseIndex, "ParaStyleLevel6");
- testStringOptionalProperty(xBaseIndex, "ParaStyleLevel7");
- testStringOptionalProperty(xBaseIndex, "ParaStyleLevel8");
- testStringOptionalProperty(xBaseIndex, "ParaStyleLevel9");
- testStringOptionalProperty(xBaseIndex, "ParaStyleLevel10");
- testStringOptionalProperty(xBaseIndex, "ParaStyleSeparator");
-
- // [property] XTextColumns TextColumns;
- {
- OUString name = "TextColumns";
-
- css::uno::Reference<css::text::XTextColumns> xGetTextColumns;
- CPPUNIT_ASSERT(xBaseIndex->getPropertyValue(name) >>= xGetTextColumns);
-
- xGetTextColumns->setColumnCount(xGetTextColumns->getColumnCount() + 1);
- xBaseIndex->setPropertyValue(name, css::uno::makeAny(xGetTextColumns));
-
- css::uno::Reference<css::text::XTextColumns> xSetTextColumns;
- CPPUNIT_ASSERT(xBaseIndex->getPropertyValue(name) >>= xSetTextColumns);
-
- //CPPUNIT_ASSERT_EQUAL(xGetTextColumns->getColumnCount(), xSetTextColumns->getColumnCount());
- }
-
- // [property] com::sun::star::graphic::XGraphic BackGraphic;
- // [property] string BackGraphicURL;
- {
- OUString name = "BackGraphicURL";
- bool bOK = false;
- try
- {
- xBaseIndex->getPropertyValue(name);
- }
- catch (css::uno::RuntimeException const& /*ex*/)
- {
- bOK = true;
- }
- // BackGraphicURL is "set-only" attribute
- CPPUNIT_ASSERT_MESSAGE("Expected RuntimeException wasn't thrown", bOK);
-
- utl::TempFile aTempFile;
- aTempFile.EnableKillingFile();
- writerFileWithBitmap(aTempFile.GetURL());
-
- css::uno::Reference<css::graphic::XGraphic> xGraphic;
- CPPUNIT_ASSERT(xBaseIndex->getPropertyValue("BackGraphic") >>= xGraphic);
- CPPUNIT_ASSERT(!xGraphic.is());
-
- xBaseIndex->setPropertyValue(name, css::uno::makeAny(aTempFile.GetURL()));
-
- CPPUNIT_ASSERT(xBaseIndex->getPropertyValue("BackGraphic") >>= xGraphic);
- CPPUNIT_ASSERT(xGraphic.is());
- }
-
- testStringProperty(xBaseIndex, "BackGraphicFilter", "Value");
-
- // [property] com::sun::star::style::GraphicLocation BackGraphicLocation;
-
- testColorProperty(xBaseIndex, "BackColor");
- testBooleanProperty(xBaseIndex, "BackTransparent");
-
- // [optional, property] com::sun::star::container::XIndexReplace LevelFormat;
-
- testBooleanOptionalProperty(xBaseIndex, "CreateFromChapter");
-
- // [property] com::sun::star::text::XTextSection ContentSection;
- {
- OUString name = "ContentSection";
-
- css::uno::Reference<css::text::XTextSection> xGetTextSection;
- CPPUNIT_ASSERT_MESSAGE(name.toUtf8().getStr(),
- xBaseIndex->getPropertyValue(name) >>= xGetTextSection);
- CPPUNIT_ASSERT_EQUAL_MESSAGE(name.toUtf8().getStr(), OUString(""),
- xGetTextSection->getAnchor()->getString());
- }
-
- // [property] com::sun::star::text::XTextSection HeaderSection;
- {
- OUString name = "HeaderSection";
-
- css::uno::Reference<css::text::XTextSection> xGetTextSection;
- if (xBaseIndex->getPropertyValue(name).hasValue())
- CPPUNIT_ASSERT_MESSAGE(name.toUtf8().getStr(),
- xBaseIndex->getPropertyValue(name) >>= xGetTextSection);
- }
- }
-};
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/api/DocumentIndexTest.hxx b/sw/qa/api/DocumentIndexTest.hxx
deleted file mode 100644
index 67804388c47d..000000000000
--- a/sw/qa/api/DocumentIndexTest.hxx
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_SW_QA_API_DOCUMENTINDEXTEST_HXX
-#define INCLUDED_SW_QA_API_DOCUMENTINDEXTEST_HXX
-
-#include "ApiTestBase.hxx"
-
-#include <cppunit/TestAssert.h>
-#include <test/unoapi_property_testers.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-
-namespace apitest
-{
-class DocumentIndexTest : public ApiTestBase
-{
-public:
- void testDocumentIndexProperties()
- {
- css::uno::Reference<css::beans::XPropertySet> xDocumnetIndex(init(),
- css::uno::UNO_QUERY_THROW);
-
- testBooleanProperty(xDocumnetIndex, "UseAlphabeticalSeparators");
- testBooleanProperty(xDocumnetIndex, "UseKeyAsEntry");
- testBooleanProperty(xDocumnetIndex, "UseCombinedEntries");
- testBooleanProperty(xDocumnetIndex, "IsCaseSensitive");
- testBooleanProperty(xDocumnetIndex, "UsePP");
- testBooleanProperty(xDocumnetIndex, "UseDash");
- testBooleanProperty(xDocumnetIndex, "UseUpperCase");
- testStringOptionalProperty(xDocumnetIndex, "MainEntryCharacterStyleName");
- // [readonly, property] sequence <com::sun::star::text::XDocumentIndexMark> DocumentIndexMarks;
- // [property] com::sun::star::lang::Locale Locale;
- testStringProperty(xDocumnetIndex, "SortAlgorithm", "Value");
- }
-};
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/api/DocumentSettingsTest.hxx b/sw/qa/api/DocumentSettingsTest.hxx
deleted file mode 100644
index 4abd8d197d35..000000000000
--- a/sw/qa/api/DocumentSettingsTest.hxx
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_SW_QA_API_DOCUMENTSETTINGSTEST_HXX
-#define INCLUDED_SW_QA_API_DOCUMENTSETTINGSTEST_HXX
-
-#include "ApiTestBase.hxx"
-
-#include <cppunit/TestAssert.h>
-#include <test/unoapi_property_testers.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-
-namespace apitest
-{
-class DocumentSettingsTest : public ApiTestBase
-{
-public:
- void testDocumentSettingsProperties()
- {
- css::uno::Reference<css::beans::XPropertySet> xDocumentSettings(init(),
- css::uno::UNO_QUERY_THROW);
-
- testBooleanOptionalProperty(xDocumentSettings, "ChartAutoUpdate");
- testBooleanOptionalProperty(xDocumentSettings, "AddParaTableSpacing");
- testBooleanOptionalProperty(xDocumentSettings, "AddParaTableSpacingAtStart");
- testBooleanOptionalProperty(xDocumentSettings, "AlignTabStopPosition");
- testBooleanOptionalProperty(xDocumentSettings, "SaveGlobalDocumentLinks");
- testBooleanOptionalProperty(xDocumentSettings, "IsLabelDocument");
- testBooleanOptionalProperty(xDocumentSettings, "UseFormerLineSpacing");
- testBooleanOptionalProperty(xDocumentSettings, "AddParaSpacingToTableCells");
- testBooleanOptionalProperty(xDocumentSettings, "UseFormerObjectPositioning");
- testBooleanOptionalProperty(xDocumentSettings, "ConsiderTextWrapOnObjPos");
- testBooleanOptionalProperty(xDocumentSettings, "MathBaselineAlignment");
- }
-};
-} // end namespace apitest
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/api/PrinterSettingsTest.hxx b/sw/qa/api/PrinterSettingsTest.hxx
deleted file mode 100644
index 8d93564c20ea..000000000000
--- a/sw/qa/api/PrinterSettingsTest.hxx
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_SW_QA_API_PRINTERSETTINGSTEST_HXX
-#define INCLUDED_SW_QA_API_PRINTERSETTINGSTEST_HXX
-
-#include "ApiTestBase.hxx"
-
-#include <cppunit/TestAssert.h>
-#include <test/unoapi_property_testers.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/text/NotePrintMode.hpp>
-
-namespace apitest
-{
-class PrinterSettingsTest : public ApiTestBase
-{
- static void
- testPrintAnnotationMode(css::uno::Reference<css::beans::XPropertySet> const& rxPrinterSettings)
- {
- const OUString rPropertyName = "PrintAnnotationMode";
-
- // This property is not optional but it's not set in some cases
- if (!extstsProperty(rxPrinterSettings, rPropertyName))
- return;
-
- /*css::text::NotePrintMode aNotePrintMode_Get;
-
- CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
- rxPrinterSettings->getPropertyValue(rPropertyName)
- >>= aNotePrintMode_Get);
-
- css::text::NotePrintMode aNotePrintMode_Set;
- css::uno::Any aNewValue;
- aNewValue <<= css::text::NotePrintMode_ONLY;
- rxPrinterSettings->setPropertyValue(rPropertyName, aNewValue);
-
- CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
- rxPrinterSettings->getPropertyValue(rPropertyName)
- >>= aNotePrintMode_Set);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", css::text::NotePrintMode_ONLY,
- aNotePrintMode_Set);*/
- }
-
-public:
- void testPrinterSettingsProperties()
- {
- css::uno::Reference<css::beans::XPropertySet> xPrinterSettings(init(),
- css::uno::UNO_QUERY_THROW);
-
- testBooleanProperty(xPrinterSettings, "PrintGraphics");
- testBooleanProperty(xPrinterSettings, "PrintTables");
- testBooleanProperty(xPrinterSettings, "PrintDrawings");
- testBooleanProperty(xPrinterSettings, "PrintLeftPages");
- testBooleanProperty(xPrinterSettings, "PrintRightPages");
- testBooleanProperty(xPrinterSettings, "PrintControls");
- testBooleanProperty(xPrinterSettings, "PrintReversed");
- testBooleanProperty(xPrinterSettings, "PrintControls");
- testStringProperty(xPrinterSettings, "PrintFaxName", "FaxName");
- testPrintAnnotationMode(
- xPrinterSettings); // it's not set in this case but it's not optional - bug?
- testBooleanProperty(xPrinterSettings, "PrintProspect");
- testBooleanProperty(xPrinterSettings, "PrintPageBackground");
- testBooleanProperty(xPrinterSettings, "PrintBlackFonts");
- testBooleanOptionalProperty(xPrinterSettings, "PrintEmptyPages");
- }
-};
-} // end namespace apitest
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/api/SettingsTest.hxx b/sw/qa/api/SettingsTest.hxx
deleted file mode 100644
index 48e236d6160f..000000000000
--- a/sw/qa/api/SettingsTest.hxx
+++ /dev/null
@@ -1,137 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_SW_QA_API_SETTINGSTEST_HXX
-#define INCLUDED_SW_QA_API_SETTINGSTEST_HXX
-
-#include "ApiTestBase.hxx"
-
-#include <cppunit/TestAssert.h>
-#include <test/unoapi_property_testers.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
-
-namespace apitest
-{
-class SettingsTest : public ApiTestBase
-{
- // [property] string PrinterName;
- static void testPrinterName(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
- {
- const OUString rPropertyName("PrinterName");
-
- if (!extstsProperty(rxSettings, rPropertyName))
- return; // Property is sometimes not set - bug? it is not defined as optional
-
- OUString aPrinterName_Get;
-
- CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
- rxSettings->getPropertyValue(rPropertyName) >>= aPrinterName_Get);
-
- OUString aPrinterName_Set;
- css::uno::Any aNewValue;
- aNewValue <<= aPrinterName_Get;
- rxSettings->setPropertyValue(rPropertyName, aNewValue);
-
- CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
- rxSettings->getPropertyValue(rPropertyName) >>= aPrinterName_Set);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", aPrinterName_Get,
- aPrinterName_Set);
- }
-
- // [optional, property] short PrinterIndependentLayout;
- static void
- testPrinterIndependentLayout(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
- {
- const OUString rPropertyName("PrinterIndependentLayout");
-
- if (!extstsProperty(rxSettings, rPropertyName))
- return; // Property is optional
-
- sal_Int16 aValue_Get;
-
- CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
- rxSettings->getPropertyValue(rPropertyName) >>= aValue_Get);
-
- sal_Int16 aValue_New;
- aValue_New = (aValue_Get == 1 ? 3 : 1);
- rxSettings->setPropertyValue(rPropertyName, css::uno::Any(aValue_New));
-
- sal_Int16 aValue_Set;
-
- CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
- rxSettings->getPropertyValue(rPropertyName) >>= aValue_Set);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", aValue_New, aValue_Set);
- }
-
- // [optional, property] com::sun::star::i18n::XForbiddenCharacters ForbiddenCharacters;
- static void
- testForbiddenCharacters(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
- {
- const OUString rPropertyName("ForbiddenCharacters");
-
- if (!extstsProperty(rxSettings, rPropertyName))
- return; // Property is optional
-
- CPPUNIT_ASSERT_MESSAGE("Property is read-only but shouldn't be",
- !isPropertyReadOnly(rxSettings, rPropertyName));
-
- css::uno::Reference<css::i18n::XForbiddenCharacters> aValue_Get;
-
- CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
- rxSettings->getPropertyValue(rPropertyName) >>= aValue_Get);
- CPPUNIT_ASSERT_MESSAGE("Empty reference to XForbiddenCharacters", aValue_Get.is());
- }
-
-public:
- void testSettingsProperties()
- {
- css::uno::Reference<css::beans::XPropertySet> xSettings(init(), css::uno::UNO_QUERY_THROW);
-
- testForbiddenCharacters(xSettings);
- //testShortOptionalProperty(xSettings, "LinkUpdateMode");
- testPrinterName(xSettings);
- // [property] sequence< byte > PrinterSetup;
- testBooleanOptionalProperty(xSettings, "IsKernAsianPunctuation");
- //testShortOptionalProperty(xSettings, "CharacterCompressionType");
- testBooleanOptionalProperty(xSettings, "ApplyUserData");
- testBooleanOptionalProperty(xSettings, "SaveVersionOnClose");
- testBooleanOptionalProperty(xSettings, "UpdateFromTemplate");
- testBooleanOptionalProperty(xSettings, "FieldAutoUpdate");
- testStringOptionalProperty(xSettings, "CurrentDatabaseDataSource");
- testStringOptionalProperty(xSettings, "CurrentDatabaseCommand");
- testLongOptionalProperty(xSettings, "CurrentDatabaseCommandType");
- testLongOptionalProperty(xSettings, "DefaultTabStop");
- testBooleanOptionalProperty(xSettings, "IsPrintBooklet");
- testBooleanOptionalProperty(xSettings, "IsPrintBookletFront");
- testBooleanOptionalProperty(xSettings, "IsPrintBookletBack");
- testLongOptionalProperty(xSettings, "PrintQuality");
- testStringOptionalProperty(xSettings, "ColorTableURL");
- testStringOptionalProperty(xSettings, "DashTableURL");
- testStringOptionalProperty(xSettings, "LineEndTableURL");
- testStringOptionalProperty(xSettings, "HatchTableURL");
- testStringOptionalProperty(xSettings, "GradientTableURL");
- testStringOptionalProperty(xSettings, "BitmapTableURL");
- testBooleanOptionalProperty(xSettings, "AutoCalculate");
- testPrinterIndependentLayout(xSettings);
- testBooleanOptionalProperty(xSettings, "AddExternalLeading");
- testBooleanOptionalProperty(xSettings, "EmbedFonts");
- testBooleanOptionalProperty(xSettings, "EmbedSystemFonts");
- testBooleanOptionalProperty(xSettings, "EmbedOnlyUsedFonts");
- testBooleanOptionalProperty(xSettings, "EmbedLatinScriptFonts");
- testBooleanOptionalProperty(xSettings, "EmbedAsianScriptFonts");
- testBooleanOptionalProperty(xSettings, "EmbedComplexScriptFonts");
- }
-};
-} // end namespace apitest
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/api/SwXDocumentIndex.cxx b/sw/qa/api/SwXDocumentIndex.cxx
index 74530d4712f4..b04ba82875cb 100644
--- a/sw/qa/api/SwXDocumentIndex.cxx
+++ b/sw/qa/api/SwXDocumentIndex.cxx
@@ -7,14 +7,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include "BaseIndexTest.hxx"
-#include "DocumentIndexTest.hxx"
-#include "XDocumentIndexTest.hxx"
-#include "XTextContentTest.hxx"
-
#include <test/bootstrapfixture.hxx>
#include <test/lang/xserviceinfo.hxx>
#include <test/lang/xcomponent.hxx>
+#include <test/text/baseindex.hxx>
+#include <test/text/textdocumentindex.hxx>
+#include <test/text/xdocumentindex.hxx>
+#include <test/text/xtextcontent.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
@@ -26,6 +25,7 @@
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/text/XTextCursor.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/text/XDocumentIndex.hpp>
#include <comphelper/processfactory.hxx>
@@ -37,29 +37,34 @@ namespace
/**
* Test for Java API test of file com.sun.star.comp.office.SwXDocumentIndex.csv
*/
-class SwXDocumentIndexTest : public test::BootstrapFixture,
- public unotest::MacrosTest,
- public apitest::XDocumentIndexTest,
- public apitest::BaseIndexTest,
- public apitest::DocumentIndexTest,
- public apitest::XTextContentTest,
- public apitest::XServiceInfo,
- public apitest::XComponent
+class SwXDocumentIndex final : public test::BootstrapFixture,
+ public unotest::MacrosTest,
+ public apitest::XDocumentIndex,
+ public apitest::BaseIndex,
+ public apitest::TextDocumentIndex,
+ public apitest::XTextContent,
+ public apitest::XServiceInfo,
+ public apitest::XComponent
{
uno::Reference<uno::XComponentContext> mxComponentContext;
uno::Reference<text::XTextDocument> mxTextDocument;
+ uno::Reference<text::XTextRange> mxTextRange;
+ uno::Reference<text::XTextContent> mxTextContent;
public:
virtual void setUp() override;
virtual void tearDown() override;
- SwXDocumentIndexTest()
+ SwXDocumentIndex()
: apitest::XServiceInfo("SwXDocumentIndex", "com.sun.star.text.BaseIndex"){};
uno::Reference<uno::XInterface> init() override;
+ uno::Reference<text::XTextRange> getTextRange() override;
+ uno::Reference<text::XTextContent> getTextContent() override;
+ bool isAttachSupported() override { return true; }
uno::Reference<text::XTextDocument> getTextDocument() override { return mxTextDocument; }
void triggerDesktopTerminate() override {}
- CPPUNIT_TEST_SUITE(SwXDocumentIndexTest);
+ CPPUNIT_TEST_SUITE(SwXDocumentIndex);
CPPUNIT_TEST(testGetImplementationName);
CPPUNIT_TEST(testGetSupportedServiceNames);
CPPUNIT_TEST(testSupportsService);
@@ -73,7 +78,7 @@ public:
CPPUNIT_TEST_SUITE_END();
};
-void SwXDocumentIndexTest::setUp()
+void SwXDocumentIndex::setUp()
{
test::BootstrapFixture::setUp();
@@ -85,7 +90,7 @@ void SwXDocumentIndexTest::setUp()
CPPUNIT_ASSERT(mxTextDocument.is());
}
-void SwXDocumentIndexTest::tearDown()
+void SwXDocumentIndex::tearDown()
{
if (mxTextDocument.is())
mxTextDocument->dispose();
@@ -93,7 +98,7 @@ void SwXDocumentIndexTest::tearDown()
test::BootstrapFixture::tearDown();
}
-uno::Reference<uno::XInterface> SwXDocumentIndexTest::init()
+uno::Reference<uno::XInterface> SwXDocumentIndex::init()
{
uno::Reference<lang::XMultiServiceFactory> xMSF(mxTextDocument, uno::UNO_QUERY_THROW);
uno::Reference<text::XDocumentIndex> xDocumentIndex(
@@ -103,10 +108,17 @@ uno::Reference<uno::XInterface> SwXDocumentIndexTest::init()
CPPUNIT_ASSERT(xTextCursor.is());
xText->insertTextContent(xTextCursor, xDocumentIndex, false);
xTextCursor->gotoEnd(false);
+ mxTextRange = uno::Reference<text::XTextRange>(xTextCursor, uno::UNO_QUERY_THROW);
+ mxTextContent = uno::Reference<text::XTextContent>(
+ xMSF->createInstance("com.sun.star.text.DocumentIndex"), uno::UNO_QUERY_THROW);
return xDocumentIndex;
}
-CPPUNIT_TEST_SUITE_REGISTRATION(SwXDocumentIndexTest);
+uno::Reference<text::XTextRange> SwXDocumentIndex::getTextRange() { return mxTextRange; }
+
+uno::Reference<text::XTextContent> SwXDocumentIndex::getTextContent() { return mxTextContent; }
+
+CPPUNIT_TEST_SUITE_REGISTRATION(SwXDocumentIndex);
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/api/DocumentSettings.cxx b/sw/qa/api/SwXDocumentSettings.cxx
index f2b48cc675f9..7a2bce7b35e7 100644
--- a/sw/qa/api/DocumentSettings.cxx
+++ b/sw/qa/api/SwXDocumentSettings.cxx
@@ -9,6 +9,9 @@
#include <test/bootstrapfixture.hxx>
#include <test/lang/xserviceinfo.hxx>
+#include <test/text/textdocumentsettings.hxx>
+#include <test/text/textprintersettings.hxx>
+#include <test/text/textsettings.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
@@ -21,10 +24,6 @@
#include <comphelper/processfactory.hxx>
-#include "DocumentSettingsTest.hxx"
-#include "SettingsTest.hxx"
-#include "PrinterSettingsTest.hxx"
-
using namespace css;
namespace
@@ -32,12 +31,12 @@ namespace
/**
* Test for Java API test of file com.sun.star.comp.Writer.DocumentSettings.csv
*/
-class DocumentSettingsTest : public test::BootstrapFixture,
- public unotest::MacrosTest,
- public apitest::DocumentSettingsTest,
- public apitest::SettingsTest,
- public apitest::PrinterSettingsTest,
- public apitest::XServiceInfo
+class SwXDocumentSettings final : public test::BootstrapFixture,
+ public unotest::MacrosTest,
+ public apitest::TextDocumentSettings,
+ public apitest::TextSettings,
+ public apitest::TextPrinterSettings,
+ public apitest::XServiceInfo
{
private:
uno::Reference<uno::XComponentContext> mxComponentContext;
@@ -47,11 +46,11 @@ public:
virtual void setUp() override;
virtual void tearDown() override;
- DocumentSettingsTest()
+ SwXDocumentSettings()
: apitest::XServiceInfo("SwXDocumentSettings", "com.sun.star.text.DocumentSettings"){};
uno::Reference<uno::XInterface> init() override;
- CPPUNIT_TEST_SUITE(DocumentSettingsTest);
+ CPPUNIT_TEST_SUITE(SwXDocumentSettings);
CPPUNIT_TEST(testGetImplementationName);
CPPUNIT_TEST(testGetSupportedServiceNames);
CPPUNIT_TEST(testSupportsService);
@@ -61,7 +60,7 @@ public:
CPPUNIT_TEST_SUITE_END();
};
-void DocumentSettingsTest::setUp()
+void SwXDocumentSettings::setUp()
{
test::BootstrapFixture::setUp();
@@ -69,7 +68,7 @@ void DocumentSettingsTest::setUp()
mxDesktop.set(frame::Desktop::create(mxComponentContext));
}
-void DocumentSettingsTest::tearDown()
+void SwXDocumentSettings::tearDown()
{
if (mxComponent.is())
mxComponent->dispose();
@@ -77,7 +76,7 @@ void DocumentSettingsTest::tearDown()
test::BootstrapFixture::tearDown();
}
-uno::Reference<uno::XInterface> DocumentSettingsTest::init()
+uno::Reference<uno::XInterface> SwXDocumentSettings::init()
{
mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
CPPUNIT_ASSERT(mxComponent.is());
@@ -91,7 +90,7 @@ uno::Reference<uno::XInterface> DocumentSettingsTest::init()
return xDocumentSettings;
}
-CPPUNIT_TEST_SUITE_REGISTRATION(DocumentSettingsTest);
+CPPUNIT_TEST_SUITE_REGISTRATION(SwXDocumentSettings);
} // end anonymous namespace
diff --git a/sw/qa/api/XDocumentIndexTest.hxx b/sw/qa/api/XDocumentIndexTest.hxx
deleted file mode 100644
index cb3eab3ce9bf..000000000000
--- a/sw/qa/api/XDocumentIndexTest.hxx
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_SW_QA_API_XDOCUMENTINDEXTEST_HXX
-#define INCLUDED_SW_QA_API_XDOCUMENTINDEXTEST_HXX
-
-#include "ApiTestBase.hxx"
-
-#include <cppunit/TestAssert.h>
-
-#include <test/unoapi_property_testers.hxx>
-
-#include <com/sun/star/text/XTextDocument.hpp>
-#include <com/sun/star/text/XTextContent.hpp>
-#include <com/sun/star/text/XText.hpp>
-#include <com/sun/star/text/XDocumentIndex.hpp>
-
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-
-namespace apitest
-{
-/**
- * Testing <code>com.sun.star.text.XDocumentIndex</code>
- *
- * @see com.sun.star.text.XDocumentIndex
- */
-class XDocumentIndexTest : public ApiTestBase
-{
-public:
- virtual css::uno::Reference<css::text::XTextDocument> getTextDocument() = 0;
-
- /**
- * Gets the document from relation and insert a new index mark.
- * Then it stores the text content of document index before
- * update and after.<p>
- *
- * Has <b> OK </b> status if index content is changed and
- * new index contains index mark inserted. <p>
- */
- void testUpdate()
- {
- css::uno::Reference<css::text::XDocumentIndex> xDocumentIndex(init(),
- css::uno::UNO_QUERY_THROW);
-
- bool bOK = true;
- try
- {
- auto xText = getTextDocument()->getText();
- auto xTextRange = xText->getEnd();
- xTextRange->setString("IndexMark");
- css::uno::Reference<css::lang::XMultiServiceFactory> xFactory(
- 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);
- xText->insertTextContent(xTextRange, xTextContentMark, true);
- }
- catch (css::uno::Exception /*exception*/)
- {
- bOK = false;
- }
-
- CPPUNIT_ASSERT_MESSAGE("Couldn't create the document index mark", bOK);
-
- OUString sContentBefore = xDocumentIndex->getAnchor()->getString();
- xDocumentIndex->update();
- OUString sContentAfter = xDocumentIndex->getAnchor()->getString();
-
- CPPUNIT_ASSERT_MESSAGE("Before and after shouldn't be equal",
- sContentBefore != sContentAfter);
- CPPUNIT_ASSERT_MESSAGE("Content after should contain string 'IndexMark'",
- sContentAfter.indexOf("IndexMark") >= 0);
- }
-};
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/api/XTextContentTest.hxx b/sw/qa/api/XTextContentTest.hxx
deleted file mode 100644
index e8bf94fbce9c..000000000000
--- a/sw/qa/api/XTextContentTest.hxx
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_SW_QA_API_XTEXTCONTENTTEST_HXX
-#define INCLUDED_SW_QA_API_XTEXTCONTENTTEST_HXX
-
-#include "ApiTestBase.hxx"
-
-#include <cppunit/TestAssert.h>
-
-#include <test/unoapi_property_testers.hxx>
-
-#include <com/sun/star/text/XTextContent.hpp>
-#include <com/sun/star/text/XTextRange.hpp>
-
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-
-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
- * then they are used for testing. <p>
- *
- * The test is OK if the method works without error.
- */
- void testAttach()
- {
- 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()
- {
- css::uno::Reference<css::text::XTextContent> xTextContent(init(),
- css::uno::UNO_QUERY_THROW);
- CPPUNIT_ASSERT_EQUAL(OUString(""), xTextContent->getAnchor()->getString());
- }
-};
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */