summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-11-01 10:53:21 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-11-01 14:56:54 +0100
commit4bf4e9600c5e723db299817e549b6d3f7b6572f1 (patch)
treeff5239d95a65410a4b9f1c8e4644909f4247d70c /writerfilter
parentc44760ee609e23b830b3e91d930518ce3289a4a0 (diff)
CppunitTest_writerfilter_dmapper: inherit from UnoApiTest
Change-Id: I342085e3c0e31794e0ec08f3b26ccf17caa8d2d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142097 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/CppunitTest_writerfilter_dmapper.mk1
-rw-r--r--writerfilter/qa/cppunittests/dmapper/CellColorHandler.cxx37
-rw-r--r--writerfilter/qa/cppunittests/dmapper/DomainMapper.cxx52
-rw-r--r--writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx42
-rw-r--r--writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx97
-rw-r--r--writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx134
-rw-r--r--writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx65
-rw-r--r--writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx74
-rw-r--r--writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx37
9 files changed, 146 insertions, 393 deletions
diff --git a/writerfilter/CppunitTest_writerfilter_dmapper.mk b/writerfilter/CppunitTest_writerfilter_dmapper.mk
index de1a8cea9f48..e2fd8ffc9367 100644
--- a/writerfilter/CppunitTest_writerfilter_dmapper.mk
+++ b/writerfilter/CppunitTest_writerfilter_dmapper.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_CppunitTest_use_libraries,writerfilter_dmapper, \
cppu \
oox \
sal \
+ subsequenttest \
test \
unotest \
vcl \
diff --git a/writerfilter/qa/cppunittests/dmapper/CellColorHandler.cxx b/writerfilter/qa/cppunittests/dmapper/CellColorHandler.cxx
index 4449e9a20e3f..15e2a78c08d0 100644
--- a/writerfilter/qa/cppunittests/dmapper/CellColorHandler.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/CellColorHandler.cxx
@@ -7,8 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
+#include <test/unoapi_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
@@ -20,39 +19,19 @@ using namespace ::com::sun::star;
namespace
{
/// Tests for writerfilter/source/dmapper/CellColorHandler.cxx.
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public UnoApiTest
{
-private:
- uno::Reference<lang::XComponent> mxComponent;
-
public:
- void setUp() override;
- void tearDown() override;
- uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+ Test()
+ : UnoApiTest("/writerfilter/qa/cppunittests/dmapper/data/")
+ {
+ }
};
-void Test::setUp()
-{
- test::BootstrapFixture::setUp();
-
- mxDesktop.set(frame::Desktop::create(mxComponentContext));
-}
-
-void Test::tearDown()
-{
- if (mxComponent.is())
- mxComponent->dispose();
-
- test::BootstrapFixture::tearDown();
-}
-
-constexpr OUStringLiteral DATA_DIRECTORY = u"/writerfilter/qa/cppunittests/dmapper/data/";
-
CPPUNIT_TEST_FIXTURE(Test, test129205)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf129205.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"tdf129205.docx");
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapper.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapper.cxx
index 639c8e9e0303..43b6076b3ace 100644
--- a/writerfilter/qa/cppunittests/dmapper/DomainMapper.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/DomainMapper.cxx
@@ -7,8 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
+#include <test/unoapi_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
@@ -22,42 +21,22 @@ using namespace ::com::sun::star;
namespace
{
/// Tests for writerfilter/source/dmapper/DomainMapper.cxx.
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public UnoApiTest
{
-private:
- uno::Reference<lang::XComponent> mxComponent;
-
public:
- void setUp() override;
- void tearDown() override;
- uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+ Test()
+ : UnoApiTest("/writerfilter/qa/cppunittests/dmapper/data/")
+ {
+ }
};
-void Test::setUp()
-{
- test::BootstrapFixture::setUp();
-
- mxDesktop.set(frame::Desktop::create(mxComponentContext));
-}
-
-void Test::tearDown()
-{
- if (mxComponent.is())
- mxComponent->dispose();
-
- test::BootstrapFixture::tearDown();
-}
-
-constexpr OUStringLiteral DATA_DIRECTORY = u"/writerfilter/qa/cppunittests/dmapper/data/";
-
CPPUNIT_TEST_FIXTURE(Test, testLargeParaTopMargin)
{
// Given a document with a paragraph with a large "before" spacing.
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "large-para-top-margin.docx";
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"large-para-top-margin.docx");
// When checking the first paragraph.
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
@@ -79,13 +58,10 @@ CPPUNIT_TEST_FIXTURE(Test, testLargeParaTopMargin)
CPPUNIT_TEST_FIXTURE(Test, testSdtRunInPara)
{
// Given a document with a block SDT, and inside that some content + a run SDT:
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "sdt-run-in-para.docx";
-
- // When loading that document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"sdt-run-in-para.docx");
// Then make sure the content inside the block SDT but outside the run SDT is not lost:
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
@@ -100,14 +76,10 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtRunInPara)
CPPUNIT_TEST_FIXTURE(Test, testSdtDropdownNoDisplayText)
{
// Given a document with <w:listItem w:value="..."/> (no display text):
- OUString aURL
- = m_directories.getURLFromSrc(DATA_DIRECTORY) + "sdt-dropdown-no-display-text.docx";
-
- // When loading that document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"sdt-dropdown-no-display-text.docx");
// Then make sure we create a dropdown content control, not a rich text one:
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParagraphsAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParagraphs = xParagraphsAccess->createEnumeration();
diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx
index 1accc77a1f5a..4a85e421990a 100644
--- a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx
@@ -7,8 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
+#include <test/unoapi_test.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/Desktop.hpp>
@@ -22,39 +21,19 @@ using namespace ::com::sun::star;
namespace
{
/// Tests for writerfilter/source/dmapper/DomainMapperTableHandler.cxx.
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public UnoApiTest
{
-private:
- uno::Reference<lang::XComponent> mxComponent;
-
public:
- void setUp() override;
- void tearDown() override;
- uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+ Test()
+ : UnoApiTest("/writerfilter/qa/cppunittests/dmapper/data/")
+ {
+ }
};
-void Test::setUp()
-{
- test::BootstrapFixture::setUp();
-
- mxDesktop.set(frame::Desktop::create(mxComponentContext));
-}
-
-void Test::tearDown()
-{
- if (mxComponent.is())
- mxComponent->dispose();
-
- test::BootstrapFixture::tearDown();
-}
-
-constexpr OUStringLiteral DATA_DIRECTORY = u"/writerfilter/qa/cppunittests/dmapper/data/";
-
CPPUNIT_TEST_FIXTURE(Test, test1cellInsidevRightborder)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "1cell-insidev-rightborder.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<text::XTextTablesSupplier> xTextDocument(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"1cell-insidev-rightborder.docx");
+ uno::Reference<text::XTextTablesSupplier> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTextDocument->getTextTables(), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
@@ -69,9 +48,8 @@ CPPUNIT_TEST_FIXTURE(Test, test1cellInsidevRightborder)
CPPUNIT_TEST_FIXTURE(Test, testNestedFloatingTable)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "nested-floating-table.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"nested-floating-table.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xFrame(xDrawPage->getByIndex(0), uno::UNO_QUERY);
bool bIsFollowingTextFlow = false;
diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
index 8da9b65f6e9c..bded91d519c8 100644
--- a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
@@ -7,8 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
+#include <test/unoapi_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
@@ -29,43 +28,23 @@ using namespace ::com::sun::star;
namespace
{
/// Tests for writerfilter/source/dmapper/DomainMapper_Impl.cxx.
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public UnoApiTest
{
-private:
- uno::Reference<lang::XComponent> mxComponent;
-
public:
- void setUp() override;
- void tearDown() override;
- uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+ Test()
+ : UnoApiTest("/writerfilter/qa/cppunittests/dmapper/data/")
+ {
+ }
};
-void Test::setUp()
-{
- test::BootstrapFixture::setUp();
-
- mxDesktop.set(frame::Desktop::create(mxComponentContext));
-}
-
-void Test::tearDown()
-{
- if (mxComponent.is())
- mxComponent->dispose();
-
- test::BootstrapFixture::tearDown();
-}
-
-constexpr OUStringLiteral DATA_DIRECTORY = u"/writerfilter/qa/cppunittests/dmapper/data/";
-
CPPUNIT_TEST_FIXTURE(Test, testPageBreakFooterTable)
{
// Load a document which refers to a footer which ends with a table, and there is a page break
// in the body text right after the footer reference.
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "page-break-footer-table.docx";
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"page-break-footer-table.docx");
// Check the last paragraph.
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
@@ -86,11 +65,10 @@ CPPUNIT_TEST_FIXTURE(Test, testPageBreakFooterTable)
CPPUNIT_TEST_FIXTURE(Test, testNumberingRestartStyleParent)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "num-restart-style-parent.docx";
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"num-restart-style-parent.docx");
// The paragraphs are A 1 2 B 1 2.
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
@@ -116,10 +94,9 @@ CPPUNIT_TEST_FIXTURE(Test, testNumberingRestartStyleParent)
CPPUNIT_TEST_FIXTURE(Test, testFrameDirection)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "frame-direction.docx";
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"frame-direction.docx");
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xFrame0(xDrawPage->getByIndex(0), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xFrame1(xDrawPage->getByIndex(1), uno::UNO_QUERY);
@@ -135,9 +112,8 @@ CPPUNIT_TEST_FIXTURE(Test, testFrameDirection)
CPPUNIT_TEST_FIXTURE(Test, testAltChunk)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "alt-chunk.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"alt-chunk.docx");
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
@@ -170,9 +146,8 @@ CPPUNIT_TEST_FIXTURE(Test, testFieldIfInsideIf)
{
// Load a document with a field in a table cell: it contains an IF field with various nested
// fields.
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "field-if-inside-if.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<text::XTextTablesSupplier> xTextDocument(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"field-if-inside-if.docx");
+ uno::Reference<text::XTextTablesSupplier> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTextDocument->getTextTables(), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
@@ -197,11 +172,10 @@ CPPUNIT_TEST_FIXTURE(Test, testFieldIfInsideIf)
CPPUNIT_TEST_FIXTURE(Test, testCreateDatePreserve)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "create-date-preserve.docx";
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"create-date-preserve.docx");
// Trigger idle layout.
Scheduler::ProcessEventsToIdle();
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
@@ -219,13 +193,10 @@ CPPUNIT_TEST_FIXTURE(Test, testCreateDatePreserve)
CPPUNIT_TEST_FIXTURE(Test, testChartZOrder)
{
// Given a document with a chart and a shape on it:
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "chart-zorder.docx";
-
- // When loading the document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"chart-zorder.docx");
// Then make sure the shape is on top of the chart:
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<lang::XServiceInfo> xChart(xDrawPage->getByIndex(0), uno::UNO_QUERY);
// Without the accompanying fix in place, this test would have failed, as the chart was on top
@@ -236,13 +207,10 @@ CPPUNIT_TEST_FIXTURE(Test, testChartZOrder)
CPPUNIT_TEST_FIXTURE(Test, testPTab)
{
// Given a document that has a <w:ptab> to render a linebreak:
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "ptab.docx";
-
- // When opening that file:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"ptab.docx");
// Then make sure that the Writer doc model contains that linebreak:
- uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(getComponent(),
+ uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xStyleFamilies
= xStyleFamiliesSupplier->getStyleFamilies();
@@ -261,14 +229,14 @@ CPPUNIT_TEST_FIXTURE(Test, testPTab)
CPPUNIT_TEST_FIXTURE(Test, testPasteOle)
{
// Given an empty document:
- getComponent() = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
+ mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
// When pasting RTF into that document:
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XText> xText = xTextDocument->getText();
uno::Reference<document::XDocumentInsertable> xCursor(
xText->createTextCursorByRange(xText->getStart()), uno::UNO_QUERY);
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "paste-ole.rtf";
+ OUString aURL = createFileURL(u"paste-ole.rtf");
xCursor->insertDocumentFromURL(aURL, {});
// Then make sure that all the 3 paragraphs of the paste data (empty para, OLE obj, text) are
@@ -288,13 +256,10 @@ CPPUNIT_TEST_FIXTURE(Test, testPasteOle)
CPPUNIT_TEST_FIXTURE(Test, testClearingBreak)
{
// Given a document with a clearing break:
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "clearing-break.docx";
-
- // When loading that file:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"clearing-break.docx");
// Then make sure that the clear property of the break is not ignored:
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XText> xText = xTextDocument->getText();
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xText, uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParagraphs = xParaEnumAccess->createEnumeration();
@@ -323,14 +288,10 @@ CPPUNIT_TEST_FIXTURE(Test, testContentControlDateDataBinding)
{
// Given a document with date content control and data binding, data binding date is 2012,
// in-document date is 2022:
- OUString aURL
- = m_directories.getURLFromSrc(DATA_DIRECTORY) + "content-control-date-data-binding.docx";
-
- // When loading that file:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"content-control-date-data-binding.docx");
// Then make sure that the date is from the data binding, not from document.xml:
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XText> xText = xTextDocument->getText();
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xText, uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParagraphs = xParaEnumAccess->createEnumeration();
diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
index 402d6fbf355e..525866b85d0f 100644
--- a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
@@ -7,8 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
+#include <test/unoapi_test.hxx>
#include <com/sun/star/awt/Point.hpp>
#include <com/sun/star/awt/Size.hpp>
@@ -30,39 +29,19 @@ using namespace ::com::sun::star;
namespace
{
/// Tests for writerfilter/source/dmapper/GraphicImport.cxx.
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public UnoApiTest
{
-private:
- uno::Reference<lang::XComponent> mxComponent;
-
public:
- void setUp() override;
- void tearDown() override;
- uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+ Test()
+ : UnoApiTest("/writerfilter/qa/cppunittests/dmapper/data/")
+ {
+ }
};
-void Test::setUp()
-{
- test::BootstrapFixture::setUp();
-
- mxDesktop.set(frame::Desktop::create(mxComponentContext));
-}
-
-void Test::tearDown()
-{
- if (mxComponent.is())
- mxComponent->dispose();
-
- test::BootstrapFixture::tearDown();
-}
-
-constexpr OUStringLiteral DATA_DIRECTORY = u"/writerfilter/qa/cppunittests/dmapper/data/";
-
CPPUNIT_TEST_FIXTURE(Test, testTdf143455SmartArtPosition)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf143455_SmartArtPosition.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"tdf143455_SmartArtPosition.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
// Without fix in place the group, which represents the SmartArt, was placed at the initializing
@@ -79,11 +58,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf143455SmartArtPosition)
CPPUNIT_TEST_FIXTURE(Test, testTdf143208wrapTight)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf143208_wrapTight.docx";
+ loadFromURL(u"tdf143208_wrapTight.docx");
// The document has a shape with indentation and contour wrap "wrapTight". Error was, that
// the corresponding shape property 'ContourOutside=true' was not set.
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
bool bContourOutside = false;
@@ -93,12 +71,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf143208wrapTight)
CPPUNIT_TEST_FIXTURE(Test, testTdf142305StrokeGlowMargin)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf142305StrokeGlowMargin.docx";
+ loadFromURL(u"tdf142305StrokeGlowMargin.docx");
// The document has an arc with fat stroke and glow. Its bounding rectangle differs much
// from the snap rectangle. Error was, that the margins were not set in a way, that the shape
// would render similar to Word.
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
sal_Int32 nTopMargin = 0;
@@ -115,9 +92,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf142305StrokeGlowMargin)
CPPUNIT_TEST_FIXTURE(Test, testTdf142305SquareWrapMargin)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf142305SquareWrapMargin.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<frame::XModel> xModel(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"tdf142305SquareWrapMargin.docx");
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
xModel->getCurrentController(), uno::UNO_QUERY_THROW);
uno::Reference<text::XTextViewCursor> xViewCursor(xTextViewCursorSupplier->getViewCursor());
@@ -133,9 +109,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf142305SquareWrapMargin)
CPPUNIT_TEST_FIXTURE(Test, testTdf142304GroupPosition)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf142304GroupPosition.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"tdf142304GroupPosition.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
sal_Int32 nVertPosition = 0;
@@ -151,9 +126,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf142304GroupPosition)
CPPUNIT_TEST_FIXTURE(Test, testTdf141540ChildRotation)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf141540ChildRotation.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"tdf141540ChildRotation.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<container::XIndexAccess> xGroup(xDrawPage->getByIndex(0), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xRotatedShape(xGroup->getByIndex(1), uno::UNO_QUERY);
@@ -168,9 +142,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf141540ChildRotation)
CPPUNIT_TEST_FIXTURE(Test, testTdf141540GroupRotation)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf141540GroupRotation.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"tdf141540GroupRotation.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
sal_Int32 nShearAngle = 9000; // init with invalid value
@@ -184,9 +157,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf141540GroupRotation)
CPPUNIT_TEST_FIXTURE(Test, testTdf141540GroupLinePosSize)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf141540GroupLinePosSize.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"tdf141540GroupLinePosSize.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
// Test line
@@ -214,9 +186,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf141540GroupLinePosSize)
CPPUNIT_TEST_FIXTURE(Test, testGroupShapeRotation)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "group-shape-rotation.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"group-shape-rotation.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
sal_Int32 nVertPosition = 0;
@@ -231,9 +202,8 @@ CPPUNIT_TEST_FIXTURE(Test, testGroupShapeRotation)
CPPUNIT_TEST_FIXTURE(Test, testDrawShapeInlineEffect)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "draw-shape-inline-effect.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"draw-shape-inline-effect.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
sal_Int32 nBottomMargin = 0;
@@ -250,9 +220,8 @@ CPPUNIT_TEST_FIXTURE(Test, testInlineAnchoredZOrder)
{
// Load a document which has two shapes: an inline one and an anchored one. The inline has no
// explicit ZOrder, the anchored one has, and it's set to a value so it's visible.
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "inline-anchored-zorder.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"inline-anchored-zorder.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<container::XNamed> xOval(xDrawPage->getByIndex(1), uno::UNO_QUERY);
// Without the accompanying fix in place, this test would have failed with:
@@ -266,10 +235,8 @@ CPPUNIT_TEST_FIXTURE(Test, testInlineInShapeAnchoredZOrder)
{
// This document has a textbox shape and then an inline shape inside that.
// The ZOrder of the inline shape is larger than the hosting textbox, so the image is visible.
- OUString aURL
- = m_directories.getURLFromSrc(DATA_DIRECTORY) + "inline-inshape-anchored-zorder.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"inline-inshape-anchored-zorder.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<container::XNamed> xOval(xDrawPage->getByIndex(1), uno::UNO_QUERY);
// Without the accompanying fix in place, this test would have failed with:
@@ -281,9 +248,8 @@ CPPUNIT_TEST_FIXTURE(Test, testInlineInShapeAnchoredZOrder)
CPPUNIT_TEST_FIXTURE(Test, testRelfromhInsidemargin)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "relfromh-insidemargin.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"relfromh-insidemargin.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
sal_Int16 nRelation = 0;
@@ -300,9 +266,8 @@ CPPUNIT_TEST_FIXTURE(Test, testRelfromhInsidemargin)
CPPUNIT_TEST_FIXTURE(Test, testWrapPolyCrop)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "wrap-poly-crop.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"wrap-poly-crop.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
drawing::PointSequenceSequence aContour;
@@ -330,9 +295,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTextboxTextline)
{
// Load a document with a shape with a textbox.
// The shape's vertical relation is <wp:positionV relativeFrom="line">.
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "textbox-textline.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"textbox-textline.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
sal_Int16 nActualRelation{};
@@ -348,9 +312,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTextboxTextline)
CPPUNIT_TEST_FIXTURE(Test, testTextboxTextlineTop)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "textbox-textline-top.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"textbox-textline-top.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
sal_Int16 nActualRelation{};
@@ -371,14 +334,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTextboxTextlineTop)
CPPUNIT_TEST_FIXTURE(Test, testLayoutInCellWrapnoneColumn)
{
// Given a file with a table, then a shape anchored inside the cell:
- OUString aURL
- = m_directories.getURLFromSrc(DATA_DIRECTORY) + "layout-in-cell-wrapnone-column.docx";
-
- // When loading that document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"layout-in-cell-wrapnone-column.docx");
// Then make sure the shape can leave the cell:
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY);
uno::Reference<container::XNamed> xNamedShape(xShape, uno::UNO_QUERY);
@@ -393,13 +352,10 @@ CPPUNIT_TEST_FIXTURE(Test, testLayoutInCellWrapnoneColumn)
CPPUNIT_TEST_FIXTURE(Test, testLayoutInCellOfHraphics)
{
// Given a file with a table, then a shape anchored inside the cell:
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "layout-in-cell-2.docx";
-
- // When loading that document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"layout-in-cell-2.docx");
// Then make sure the cell obeys the layoutInCell:
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY);
uno::Reference<container::XNamed> xNamedShape(xShape, uno::UNO_QUERY);
@@ -420,10 +376,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf149840SmartArtBackground)
pChange->commit();
}
- OUString aURL
- = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf149840_SmartArtBackground.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"tdf149840_SmartArtBackground.docx");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<container::XIndexAccess> xGroup(xDrawPage->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xGroup->getCount());
diff --git a/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx b/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx
index cc651d224736..b6f917f58345 100644
--- a/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx
@@ -7,8 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
+#include <test/unoapi_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
@@ -23,39 +22,19 @@ using namespace ::com::sun::star;
namespace
{
/// Tests for writerfilter/source/dmapper/PropertyMap.cxx.
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public UnoApiTest
{
-private:
- uno::Reference<lang::XComponent> mxComponent;
-
public:
- void setUp() override;
- void tearDown() override;
- uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+ Test()
+ : UnoApiTest("/writerfilter/qa/cppunittests/dmapper/data/")
+ {
+ }
};
-void Test::setUp()
-{
- test::BootstrapFixture::setUp();
-
- mxDesktop.set(frame::Desktop::create(mxComponentContext));
-}
-
-void Test::tearDown()
-{
- if (mxComponent.is())
- mxComponent->dispose();
-
- test::BootstrapFixture::tearDown();
-}
-
-constexpr OUStringLiteral DATA_DIRECTORY = u"/writerfilter/qa/cppunittests/dmapper/data/";
-
CPPUNIT_TEST_FIXTURE(Test, testFloatingTableHeader)
{
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "floating-table-header.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<frame::XModel> xModel(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"floating-table-header.docx");
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
xModel->getCurrentController(), uno::UNO_QUERY);
uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(),
@@ -72,9 +51,8 @@ CPPUNIT_TEST_FIXTURE(Test, testFollowPageTopMargin)
{
// Load a document with 2 pages: first page has larger top margin, second page has smaller top
// margin.
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "follow-page-top-margin.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(getComponent(),
+ loadFromURL(u"follow-page-top-margin.docx");
+ uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xStyleFamilies
= xStyleFamiliesSupplier->getStyleFamilies();
@@ -94,14 +72,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTableNegativeVerticalPos)
{
// Given a document with a table which has a negative vertical position (moves up to overlap
// with the header):
- OUString aURL
- = m_directories.getURLFromSrc(DATA_DIRECTORY) + "table-negative-vertical-pos.docx";
-
- // When loading that document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"table-negative-vertical-pos.docx");
// Then make sure we don't import that as a plain table, which can't have a negative top margin:
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1
@@ -113,14 +87,11 @@ CPPUNIT_TEST_FIXTURE(Test, testTableNegativeVerticalPos)
CPPUNIT_TEST_FIXTURE(Test, testNegativePageBorder)
{
// Given a document with a top margin and a border which has more spacing than the margin:
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "negative-page-border.docx";
-
- // When loading that document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"negative-page-border.docx");
// Then make sure that the border distance is negative, so it can appear at the correct
// position:
- uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(getComponent(),
+ uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xStyleFamilies
= xStyleFamiliesSupplier->getStyleFamilies();
@@ -142,15 +113,11 @@ CPPUNIT_TEST_FIXTURE(Test, testNegativePageBorder)
CPPUNIT_TEST_FIXTURE(Test, testNegativePageBorderNoMargin)
{
// Given a document with no top margin and a border which has spacing:
- OUString aURL
- = m_directories.getURLFromSrc(DATA_DIRECTORY) + "negative-page-border-no-margin.docx";
-
- // When loading that document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"negative-page-border-no-margin.docx");
// Then make sure that the border distance is negative, so it can appear at the correct
// position:
- uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(getComponent(),
+ uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xStyleFamilies
= xStyleFamiliesSupplier->getStyleFamilies();
diff --git a/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx b/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx
index 5b62fdf55122..98211317c6ce 100644
--- a/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx
@@ -7,8 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
+#include <test/unoapi_test.hxx>
#include <comphelper/sequenceashashmap.hxx>
@@ -22,44 +21,22 @@ using namespace com::sun::star;
namespace
{
/// Tests for writerfilter/source/dmapper/SdtHelper.cxx.
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public UnoApiTest
{
-private:
- uno::Reference<lang::XComponent> mxComponent;
-
public:
- void setUp() override;
- void tearDown() override;
- uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+ Test()
+ : UnoApiTest("/writerfilter/qa/cppunittests/dmapper/data/")
+ {
+ }
};
-void Test::setUp()
-{
- test::BootstrapFixture::setUp();
-
- mxDesktop.set(frame::Desktop::create(mxComponentContext));
-}
-
-void Test::tearDown()
-{
- if (mxComponent.is())
- mxComponent->dispose();
-
- test::BootstrapFixture::tearDown();
-}
-
-constexpr OUStringLiteral DATA_DIRECTORY = u"/writerfilter/qa/cppunittests/dmapper/data/";
-
CPPUNIT_TEST_FIXTURE(Test, testSdtRunRichText)
{
// Given a document with a rich text inline/run SDT:
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "sdt-run-rich-text.docx";
-
- // When loading the document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"sdt-run-rich-text.docx");
// Then make sure that formatting of the text inside the SDT is not lost:
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
@@ -100,13 +77,10 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtRunRichText)
CPPUNIT_TEST_FIXTURE(Test, testSdtRunPlainText)
{
// Given a document with a plain text inline/run SDT:
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "sdt-run-plain-text.docx";
-
- // When loading the document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"sdt-run-plain-text.docx");
// Then make sure that the text inside the SDT is not rich:
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
@@ -130,13 +104,10 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtRunPlainText)
CPPUNIT_TEST_FIXTURE(Test, testSdtRunCheckbox)
{
// Given a document with a checkbox inline/run SDT:
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "sdt-run-checkbox.docx";
-
- // When loading the document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"sdt-run-checkbox.docx");
// Then make sure that the doc model has a clickable checkbox content control:
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
@@ -176,13 +147,10 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtRunCheckbox)
CPPUNIT_TEST_FIXTURE(Test, testSdtRunDropdown)
{
// Given a document with a dropdown inline/run SDT:
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "sdt-run-dropdown.docx";
-
- // When loading the document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"sdt-run-dropdown.docx");
// Then make sure that the doc model has a clickable dropdown content control:
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParagraphsAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParagraphs = xParagraphsAccess->createEnumeration();
@@ -224,13 +192,10 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtRunDropdown)
CPPUNIT_TEST_FIXTURE(Test, testSdtRunComboBox)
{
// Given a document with a combo box inline/run SDT:
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "sdt-run-combobox.docx";
-
- // When loading the document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"sdt-run-combobox.docx");
// Then make sure that the doc model has a clickable combo box content control:
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParagraphsAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParagraphs = xParagraphsAccess->createEnumeration();
@@ -254,13 +219,10 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtRunComboBox)
CPPUNIT_TEST_FIXTURE(Test, testSdtRunPicture)
{
// Given a document with a dropdown inline/run SDT:
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "sdt-run-picture.docx";
-
- // When loading the document:
- getComponent() = loadFromDesktop(aURL);
+ loadFromURL(u"sdt-run-picture.docx");
// Then make sure that the doc model has a clickable picture content control:
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParagraphsAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParagraphs = xParagraphsAccess->createEnumeration();
diff --git a/writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx b/writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx
index 45a689b6b084..78373e1044f6 100644
--- a/writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/TextEffectsHandler.cxx
@@ -7,8 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
+#include <test/unoapi_test.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/Desktop.hpp>
@@ -19,40 +18,20 @@ using namespace ::com::sun::star;
namespace
{
/// Tests for writerfilter/source/dmapper/TextEffectsHandler.cxx.
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public UnoApiTest
{
-private:
- uno::Reference<lang::XComponent> mxComponent;
-
public:
- void setUp() override;
- void tearDown() override;
- uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+ Test()
+ : UnoApiTest("/writerfilter/qa/cppunittests/dmapper/data/")
+ {
+ }
};
-void Test::setUp()
-{
- test::BootstrapFixture::setUp();
-
- mxDesktop.set(frame::Desktop::create(mxComponentContext));
-}
-
-void Test::tearDown()
-{
- if (mxComponent.is())
- mxComponent->dispose();
-
- test::BootstrapFixture::tearDown();
-}
-
-constexpr OUStringLiteral DATA_DIRECTORY = u"/writerfilter/qa/cppunittests/dmapper/data/";
-
CPPUNIT_TEST_FIXTURE(Test, testSemiTransparentText)
{
// Load a document with a single paragraph: second text portion has semi-transparent text.
- OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "semi-transparent-text.docx";
- getComponent() = loadFromDesktop(aURL);
- uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ loadFromURL(u"semi-transparent-text.docx");
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();