diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-05-05 12:38:40 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-05-05 13:47:52 +0200 |
commit | b10417eb1e5a4a6959e7fc1cdd9819e5b09d39a4 (patch) | |
tree | 877b39b3c64a903899137a31ae23c7b4c2ecdfcf | |
parent | 86b48c757906c3ef647f3d5e2579ac1fef1bf55b (diff) |
tdf#151974: sw_uiwriter3: Add unittest
Change-Id: Ieb22d53a262a378539bf1bc576826f83797267f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151420
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sw/qa/extras/uiwriter/data/tdf151974.odt | bin | 0 -> 10556 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 45 |
2 files changed, 45 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf151974.odt b/sw/qa/extras/uiwriter/data/tdf151974.odt Binary files differnew file mode 100644 index 000000000000..b3f4a76e46a9 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf151974.odt diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 4b515444e0d3..9580cd93c67f 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -39,6 +39,51 @@ public: } }; +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf151974) +{ + createSwDoc("tdf151974.odt"); + + CPPUNIT_ASSERT_EQUAL(int(8), getParagraphs()); + + auto pLayout = parseLayoutDump(); + for (size_t i = 1; i < 9; ++i) + { + OString sPath("/root/page[1]/body/txt[" + OString::number(i) + + "]/SwParaPortion/SwLineLayout"); + assertXPathChildren(pLayout, sPath, 1); + } + + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Copy", {}); + dispatchCommand(mxComponent, ".uno:GoDown", {}); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RETURN); + Scheduler::ProcessEventsToIdle(); + + // Paste special as RTF + uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( + { { "SelectedFormat", uno::Any(static_cast<sal_uInt32>(SotClipboardFormatId::RTF)) } }); + + dispatchCommand(mxComponent, ".uno:ClipboardFormatItems", aPropertyValues); + + CPPUNIT_ASSERT_EQUAL(int(16), getParagraphs()); + + dumpLayout(mxComponent); + pLayout = parseLayoutDump(); + for (size_t i = 1; i < 16; ++i) + { + OString sPath("/root/page[1]/body/txt[" + OString::number(i) + + "]/SwParaPortion/SwLineLayout"); + + // Without the fix in place, this test would have failed with + // - Expected: 1 + // - Actual : 2 + // - In <>, XPath '/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout' number of child-nodes is incorrect + assertXPathChildren(pLayout, sPath, 1); + } +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf145731) { createSwDoc("tdf145731.odt"); |