sw/qa/extras/uiwriter/uiwriter.cxx | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
New commits: commit 12bd8d8d50da871e8f6be57ce46083f84d493d8b Author: Xisco Fauli <[email protected]> AuthorDate: Thu Oct 14 19:01:33 2021 +0200 Commit: Xisco Fauli <[email protected]> CommitDate: Thu Oct 14 21:40:55 2021 +0200 tdf#138873: sw_uiwriter: Add unittest Change-Id: Iebce7142f51e5a80fc1ea5e78481efeab3709c09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123595 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 5aa4df1f0b73..dbcb8edd3e1c 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -283,6 +283,7 @@ public: void testTdf89720(); void testTdf88986(); void testTdf78150(); + void testTdf138873(); void testTdf87922(); void testTdf77014(); void testTdf92648(); @@ -403,6 +404,7 @@ public: CPPUNIT_TEST(testTdf89720); CPPUNIT_TEST(testTdf88986); CPPUNIT_TEST(testTdf78150); + CPPUNIT_TEST(testTdf138873); CPPUNIT_TEST(testTdf87922); CPPUNIT_TEST(testTdf77014); CPPUNIT_TEST(testTdf92648); @@ -4262,6 +4264,42 @@ void SwUiWriterTest::testTdf78150() CPPUNIT_ASSERT_EQUAL(OUString(""), getParagraph(1)->getString()); } +void SwUiWriterTest::testTdf138873() +{ + SwDoc* pDoc = createSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->Insert("A B C"); + + CPPUNIT_ASSERT_EQUAL(OUString("A B C"), getParagraph(1)->getString()); + + // Select B + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false); + + pWrtShell->Insert("DDD"); + + CPPUNIT_ASSERT_EQUAL(OUString("A DDD C"), getParagraph(1)->getString()); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString("A B C"), getParagraph(1)->getString()); + + // Select B and C + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 2, /*bBasicCall=*/false); + + dispatchCommand(mxComponent, ".uno:Copy", {}); + Scheduler::ProcessEventsToIdle(); + + dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + + // Without the fix in place, this test would have failed with + // - Expected: A B C + // - Actual : A CB CB + CPPUNIT_ASSERT_EQUAL(OUString("A B C"), getParagraph(1)->getString()); +} + void SwUiWriterTest::testTdf87922() { // Create an SwDrawTextInfo.
