sw/qa/extras/uiwriter/data2/tdf131684.docx |binary sw/qa/extras/uiwriter/uiwriter2.cxx | 51 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+)
New commits: commit 2d9d7a843342102d1cc917ac3bde13e7b2b718d7 Author: Xisco Fauli <[email protected]> AuthorDate: Tue Apr 14 20:45:49 2020 +0200 Commit: Thorsten Behrens <[email protected]> CommitDate: Sat May 30 02:09:53 2020 +0200 tdf#131684: Add unittest Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92226 Tested-by: Jenkins Reviewed-by: Xisco FaulĂ <[email protected]> (cherry picked from commit 3ee27693301b50cdebd6a47e35b6621f0ac50cfe) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95022 Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit 03fe7a259e71d1c3f5190652649f9d4a6f75b4b7) Change-Id: Ic59d922700b4046a1ec94be5365b46dc8a021a00 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95131 Tested-by: Thorsten Behrens <[email protected]> Reviewed-by: Thorsten Behrens <[email protected]> diff --git a/sw/qa/extras/uiwriter/data2/tdf131684.docx b/sw/qa/extras/uiwriter/data2/tdf131684.docx new file mode 100644 index 000000000000..7d3397dfba60 Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/tdf131684.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 0105b3005f76..902395a74a2a 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -9,6 +9,7 @@ #include <swmodeltestbase.hxx> #include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/frame/DispatchHelper.hpp> #include <swdtflvr.hxx> #include <wrtsh.hxx> #include <redline.hxx> @@ -26,14 +27,64 @@ public: void testRedlineMoveInsertInDelete(); void testRedlineInHiddenSection(); void testTdf101534(); + void testTdf131684(); CPPUNIT_TEST_SUITE(SwUiWriterTest2); CPPUNIT_TEST(testRedlineMoveInsertInDelete); CPPUNIT_TEST(testRedlineInHiddenSection); CPPUNIT_TEST(testTdf101534); + CPPUNIT_TEST(testTdf131684); CPPUNIT_TEST_SUITE_END(); }; +static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, + const OUString& rCommand, + const uno::Sequence<beans::PropertyValue>& rPropertyValues) +{ + uno::Reference<frame::XController> xController + = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); + CPPUNIT_ASSERT(xController.is()); + uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xFrame.is()); + + uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); + uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext)); + CPPUNIT_ASSERT(xDispatchHelper.is()); + + xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues); +} + +void SwUiWriterTest2::testTdf131684() +{ + load(DATA_DIRECTORY, "tdf131684.docx"); + + 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()); + + //Use selectAll 3 times in a row + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + + lcl_dispatchCommand(mxComponent, ".uno:Cut", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + + // without the fix, it crashes + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); +} + void SwUiWriterTest2::testTdf101534() { // Copy the first paragraph of the document. _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
