summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-06-11 11:43:19 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-06-11 13:19:59 +0200
commiteea9224017d282324bdced180f8e13249da1f5bd (patch)
tree46caa5f25456336c9cbb3ae7d8ce29352d01a50b /sw/qa/extras
parent066599203ce143b3614e0fa298a05ed28ba2ca63 (diff)
uiwriter: use createSwDoc instead of loadFromDesktop for empty docs
Change-Id: Iacfda21398bfd920c5e0be62893ba723ee99d738 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117041 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx10
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx14
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx75
-rw-r--r--sw/qa/extras/uiwriter/uiwriter4.cxx2
4 files changed, 26 insertions, 75 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 0129e66630af..23b7d9bb8e96 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -2347,10 +2347,7 @@ void SwUiWriterTest::testTextSearch()
void SwUiWriterTest::testTdf69282()
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
- SwDoc* source = pTextDoc->GetDocShell()->GetDoc();
+ SwDoc* source = createSwDoc();
uno::Reference<lang::XComponent> xSourceDoc = mxComponent;
mxComponent.clear();
SwDoc* target = createSwDoc();
@@ -2408,10 +2405,7 @@ void SwUiWriterTest::testTdf69282()
void SwUiWriterTest::testTdf69282WithMirror()
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
- SwDoc* source = pTextDoc->GetDocShell()->GetDoc();
+ SwDoc* source = createSwDoc();
uno::Reference<lang::XComponent> xSourceDoc = mxComponent;
mxComponent.clear();
SwDoc* target = createSwDoc();
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 1a2f7cd693e1..7746ebaa61de 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -206,9 +206,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf101534)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineMoveInsertInDelete)
{
- loadURL("private:factory/swriter", nullptr);
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- SwWrtShell* const pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ SwDoc* const pDoc = createSwDoc();
+ SwWrtShell* const pWrtShell = pDoc->GetDocShell()->GetWrtShell();
pWrtShell->Insert(" foo");
pWrtShell->SttEndDoc(true);
@@ -242,9 +241,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineMoveInsertInDelete)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineInHiddenSection)
{
- loadURL("private:factory/swriter", nullptr);
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- SwWrtShell* const pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ SwDoc* const pDoc = createSwDoc();
+ SwWrtShell* const pWrtShell = pDoc->GetDocShell()->GetWrtShell();
pWrtShell->SplitNode();
pWrtShell->Insert("foo");
@@ -3523,9 +3521,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTrackImageDeletion)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTrackImageInsertion)
{
- loadURL("private:factory/swriter", nullptr);
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+ SwDoc* pDoc = createSwDoc();
// turn on red-lining and show changes
IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess());
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 8be4a2b208c6..0a815ec8cf9b 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -1777,10 +1777,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132744)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135014)
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
-
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
+ createSwDoc();
uno::Sequence<beans::PropertyValue> aArgs(
comphelper::InitPropertySequence({ { "KeyModifier", uno::makeAny(sal_Int32(0)) } }));
@@ -1806,11 +1803,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135014)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130629)
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
+ createSwDoc();
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
-
uno::Sequence<beans::PropertyValue> aArgs(
comphelper::InitPropertySequence({ { "KeyModifier", uno::makeAny(KEY_MOD1) } }));
@@ -1838,12 +1833,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130629)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf141613)
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
-
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
-
- SwWrtShell* pWrtSh = pTextDoc->GetDocShell()->GetWrtShell();
+ SwDoc* const pDoc = createSwDoc();
+ SwWrtShell* const pWrtSh = pDoc->GetDocShell()->GetWrtShell();
CPPUNIT_ASSERT(pWrtSh);
pWrtSh->Insert("Test");
@@ -1869,12 +1860,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf141613)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf133358)
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
-
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
-
- SwWrtShell* pWrtSh = pTextDoc->GetDocShell()->GetWrtShell();
+ SwDoc* const pDoc = createSwDoc();
+ SwWrtShell* const pWrtSh = pDoc->GetDocShell()->GetWrtShell();
CPPUNIT_ASSERT(pWrtSh);
pWrtSh->Insert("Test");
@@ -1901,10 +1888,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf133358)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf80663)
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
-
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
+ createSwDoc();
uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
{ { "Rows", uno::makeAny(sal_Int32(2)) }, { "Columns", uno::makeAny(sal_Int32(2)) } }));
@@ -1996,10 +1980,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf107893)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf121031)
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
-
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
+ createSwDoc();
uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
{ { "Rows", uno::makeAny(sal_Int32(3)) }, { "Columns", uno::makeAny(sal_Int32(3)) } }));
@@ -2073,15 +2054,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134626)
Scheduler::ProcessEventsToIdle();
TransferableDataHelper aHelper(xTransfer);
- mxComponent->dispose();
-
// Create a new document
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
-
- pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
-
- pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ SwDoc* const pDoc = createSwDoc();
+ pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
// Without the fix in place, this test would have crashed here
for (sal_Int32 i = 0; i < 5; ++i)
@@ -2110,10 +2086,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134626)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf139566)
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
-
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
+ SwDoc* pDoc = createSwDoc();
+ SwWrtShell* pWrtSh = pDoc->GetDocShell()->GetWrtShell();
uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
{ { "Rows", uno::makeAny(sal_Int32(1)) }, { "Columns", uno::makeAny(sal_Int32(1)) } }));
@@ -2121,9 +2095,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf139566)
dispatchCommand(mxComponent, ".uno:InsertTable", aArgs);
Scheduler::ProcessEventsToIdle();
- SwWrtShell* pWrtSh = pTextDoc->GetDocShell()->GetWrtShell();
- CPPUNIT_ASSERT(pWrtSh);
-
// Move the cursor outside the table
pWrtSh->Down(/*bSelect=*/false);
@@ -2158,10 +2129,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf139566)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf96067)
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
-
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
+ createSwDoc();
uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
{ { "Rows", uno::makeAny(sal_Int32(3)) }, { "Columns", uno::makeAny(sal_Int32(3)) } }));
@@ -2195,10 +2163,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf96067)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf87199)
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
-
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
+ createSwDoc();
uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
{ { "Rows", uno::makeAny(sal_Int32(2)) }, { "Columns", uno::makeAny(sal_Int32(1)) } }));
@@ -2243,10 +2208,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf87199)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132603)
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
-
+ createSwDoc();
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
uno::Sequence<beans::PropertyValue> aPropertyValues
= comphelper::InitPropertySequence({ { "Text", uno::makeAny(OUString("Comment")) } });
@@ -2278,10 +2241,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132603)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf117601)
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
-
+ createSwDoc();
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
{ { "Rows", uno::makeAny(sal_Int32(5)) }, { "Columns", uno::makeAny(sal_Int32(3)) } }));
@@ -2760,7 +2721,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf138897)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf136740)
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
+ createSwDoc();
css::uno::Reference<css::lang::XMultiServiceFactory> xFact(mxComponent,
css::uno::UNO_QUERY_THROW);
css::uno::Reference<css::beans::XPropertySet> xTextDefaults(
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx
index b2a53d2242f2..dc3871dc1389 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -2065,7 +2065,7 @@ void SwUiWriterTest4::testRhbz1810732()
void SwUiWriterTest4::testTdf142157()
{
- mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
+ createSwDoc();
const OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf142157.odt";
uno::Sequence<beans::PropertyValue> aPropertyValues(