sw/qa/extras/uiwriter/data3/tdf134626.odt |binary sw/qa/extras/uiwriter/uiwriter3.cxx | 50 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)
New commits: commit 480d00625534c356dabd96c503d992f07c99d152 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Nov 17 21:25:26 2020 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Dec 3 09:41:58 2020 +0100 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 <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/uiwriter/data3/tdf134626.odt b/sw/qa/extras/uiwriter/data3/tdf134626.odt new file mode 100644 index 000000000000..157bc258799e Binary files /dev/null and b/sw/qa/extras/uiwriter/data3/tdf134626.odt differ 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"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits