diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-11-17 21:25:26 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-12-03 09:41:58 +0100 |
commit | 480d00625534c356dabd96c503d992f07c99d152 (patch) | |
tree | c01a737490a2879ab8f8ce9467fd6a42871e4b04 | |
parent | 8cf3181243d9a4695ef430463df34699c37462f9 (diff) |
tdf#134626: sw_uiwriter: Add unittest
Change-Id: I1a7e5844c1e830dd499e35b2a6ea2085123f6a0d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106028
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sw/qa/extras/uiwriter/data3/tdf134626.odt | bin | 0 -> 9136 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 50 |
2 files changed, 50 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data3/tdf134626.odt b/sw/qa/extras/uiwriter/data3/tdf134626.odt Binary files differnew file mode 100644 index 000000000000..157bc258799e --- /dev/null +++ b/sw/qa/extras/uiwriter/data3/tdf134626.odt diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 4f8c046356f8..baca0e6f8c0e 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -1426,6 +1426,56 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, TestTextBoxCrashAfterLineDel) xCursor->setString(OUString()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134626) +{ + load(DATA_DIRECTORY, "tdf134626.odt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + CPPUNIT_ASSERT_EQUAL(OUString("Apple"), getParagraph(1)->getString()); + + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + + SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); + xTransfer->Copy(); + Scheduler::ProcessEventsToIdle(); + TransferableDataHelper aHelper(xTransfer.get()); + + // 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(); + + // Without the fix in place, this test would have crashed here + for (sal_Int32 i = 0; i < 5; ++i) + { + SwTransferable::Paste(*pWrtShell, aHelper); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString("Apple"), getParagraph(1)->getString()); + + SwTransferable::Paste(*pWrtShell, aHelper); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString("AppleApple"), getParagraph(1)->getString()); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString("Apple"), getParagraph(1)->getString()); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(""), getParagraph(1)->getString()); + } +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf96067) { mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"); |