diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-10-17 14:24:50 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-10-17 16:24:36 +0200 |
commit | 92de5455e3df5d160a756371fa1323e2348454b3 (patch) | |
tree | 1de88fbbfe43196315c6f55142d0535f8dd2ae06 | |
parent | bb0ee20e05343ea839a126ac2bfdb2d709660296 (diff) |
tdf#135733: sw_uiwriter: Add unittest
Change-Id: I58d81fd247b09dca902e2f32f6406912069ab2fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104462
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sw/qa/extras/uiwriter/data3/tdf135733.odt | bin | 0 -> 11211 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 51 |
2 files changed, 51 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data3/tdf135733.odt b/sw/qa/extras/uiwriter/data3/tdf135733.odt Binary files differnew file mode 100644 index 000000000000..58293a07942d --- /dev/null +++ b/sw/qa/extras/uiwriter/data3/tdf135733.odt diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index eb42824287d9..4480160ec169 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -400,6 +400,57 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132187) CPPUNIT_ASSERT_EQUAL(1, getPages()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135733) +{ + load(DATA_DIRECTORY, "tdf135733.odt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(1, getPages()); + CPPUNIT_ASSERT_EQUAL(2, getShapes()); + + SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + + //Move the cursor inside the table + pWrtShell->Down(/*bSelect=*/false); + pWrtShell->Down(/*bSelect=*/false); + + //Select first column + pWrtShell->Down(/*bSelect=*/true); + pWrtShell->Down(/*bSelect=*/true); + pWrtShell->Down(/*bSelect=*/true); + + rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell); + xTransfer->Cut(); + + pWrtShell->SttPg(/*bSelect=*/false); + + TransferableDataHelper aHelper(xTransfer.get()); + SwTransferable::Paste(*pWrtShell, aHelper); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(1, getPages()); + CPPUNIT_ASSERT_EQUAL(2, getShapes()); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(1, getPages()); + CPPUNIT_ASSERT_EQUAL(0, getShapes()); + + // without the fix, it crashes + dispatchCommand(mxComponent, ".uno:Undo", {}); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(1, getPages()); + CPPUNIT_ASSERT_EQUAL(2, getShapes()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf128739) { load(DATA_DIRECTORY, "tdf128739.docx"); |