tdf#136728 : sw_uiwriter: Add unittest
Change-Id: I0c5f3bf454797ba7a892682087ec28d23e6f79b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103774
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sw/qa/extras/uiwriter/data3/tdf136728.odt b/sw/qa/extras/uiwriter/data3/tdf136728.odt
new file mode 100644
index 0000000..a343938
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data3/tdf136728.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 6ce22aa..315a6f9 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -73,6 +73,54 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf129382)
CPPUNIT_ASSERT_EQUAL(8, getShapes());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf136728)
{
#if !defined(_WIN32) // FIXME: For some reason, jenkins win build hangs here
load(DATA_DIRECTORY, "tdf136728.odt");
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc);
CPPUNIT_ASSERT_EQUAL(39, getPages());
dispatchCommand(mxComponent, ".uno:SelectAll", {});
SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
xTransfer->Cut();
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(1, getPages());
TransferableDataHelper aHelper(xTransfer.get());
SwTransferable::Paste(*pWrtShell, aHelper);
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(39, getPages());
dispatchCommand(mxComponent, ".uno:JumpToNextTable", {});
dispatchCommand(mxComponent, ".uno:DeleteTable", {});
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(1, getPages());
SwTransferable::Paste(*pWrtShell, aHelper);
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(39, getPages());
dispatchCommand(mxComponent, ".uno:JumpToNextTable", {});
dispatchCommand(mxComponent, ".uno:DeleteTable", {});
Scheduler::ProcessEventsToIdle();
// Without the fix in place, this test would have crashed here
CPPUNIT_ASSERT_EQUAL(1, getPages());
#endif
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134227)
{
load(DATA_DIRECTORY, "tdf134227.docx");