diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-12-22 16:15:20 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-12-23 17:56:39 +0100 |
commit | 87749abd33effafca577cdd01580f57c79fb836a (patch) | |
tree | ac302c260e9b92b8280221366637723f0a95aba1 | |
parent | tdf#135061 sw_redlinehide: fix copy into delete redline following table (diff) | |
download | core-87749abd33effafca577cdd01580f57c79fb836a.tar.gz core-87749abd33effafca577cdd01580f57c79fb836a.zip |
tdf#135061: sw_uiwriter3: Add unittest
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127326
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
(cherry picked from commit 22f3f806abc0ef3ef02cd6733bdb3f950085dd17)
Change-Id: Ied2ae576810a9f66e51883375959d372af59abe4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127356
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | sw/qa/extras/uiwriter/data2/tdf135061.odt | bin | 0 -> 10767 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 36 | ||||
-rw-r--r-- | sw/qa/inc/swmodeltestbase.hxx | 8 |
3 files changed, 44 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data2/tdf135061.odt b/sw/qa/extras/uiwriter/data2/tdf135061.odt Binary files differnew file mode 100644 index 000000000000..19b3afa31e47 --- /dev/null +++ b/sw/qa/extras/uiwriter/data2/tdf135061.odt diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index e7566f1e7586..f19980387677 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -612,6 +612,42 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf139922) getParagraph(2)->getString()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf135061) +{ + createDoc("tdf135061.odt"); + + 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(4, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + Scheduler::ProcessEventsToIdle(); + + lcl_dispatchCommand(mxComponent, ".uno:Copy", {}); + Scheduler::ProcessEventsToIdle(); + + for (sal_Int32 i = 0; i < 5; ++i) + { + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + } + + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(20, getShapes()); + + for (sal_Int32 i = 0; i < 5; ++i) + { + // Without the fix in place, this test would have crashed here + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + } + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf132236) { load(DATA_DIRECTORY, "tdf132236.odt"); diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx index 8d4b25f1cf32..207198f0d703 100644 --- a/sw/qa/inc/swmodeltestbase.hxx +++ b/sw/qa/inc/swmodeltestbase.hxx @@ -895,6 +895,14 @@ protected: return xCursor->getPage(); } + /// Get shape count. + int getShapes() const + { + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage(); + return xDraws->getCount(); + } + /** * Given that some problem doesn't affect the result in the importer, we * test the resulting file directly, by opening the zip file, parsing an |