diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-05-05 19:27:58 +0200 |
---|---|---|
committer | Xisco Faulí <xiscofauli@libreoffice.org> | 2020-05-06 13:50:26 +0200 |
commit | 7410d53b1b5ae85af7a8f96153ab7ac2b6e346ab (patch) | |
tree | af195f34d72f46e43aa5f84c913df4f25c1ae230 /sw/qa | |
parent | fe1629a5c2b96c1d1ccd7e1c7a824796c02992a3 (diff) |
tdf#132603: sw: Add unittest
Change-Id: I2706ba434034aa4307619cde12f020deb40d669e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93509
Tested-by: Jenkins
Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 4d7a43aed5b6..7818a1f9cb0e 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -12,6 +12,7 @@ #include <vcl/scheduler.hxx> #include <com/sun/star/text/TextContentAnchorType.hpp> #include <comphelper/propertysequence.hxx> +#include <boost/property_tree/json_parser.hpp> namespace { @@ -604,6 +605,38 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf87199) CPPUNIT_ASSERT(xCellA1->getString().endsWith("test1")); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132603) +{ + mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + uno::Sequence<beans::PropertyValue> aPropertyValues + = comphelper::InitPropertySequence({ { "Text", uno::makeAny(OUString("Comment")) } }); + + dispatchCommand(mxComponent, ".uno:InsertAnnotation", aPropertyValues); + Scheduler::ProcessEventsToIdle(); + + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + Scheduler::ProcessEventsToIdle(); + + // Without the fix in place, it would crash here + dispatchCommand(mxComponent, ".uno:Copy", {}); + Scheduler::ProcessEventsToIdle(); + + OUString aPostits = pTextDoc->getPostIts(); + std::stringstream aStream(aPostits.toUtf8().getStr()); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + for (const boost::property_tree::ptree::value_type& rValue : aTree.get_child("comments")) + { + const boost::property_tree::ptree& rComment = rValue.second; + OString aText(rComment.get<std::string>("text").c_str()); + CPPUNIT_ASSERT_EQUAL(OString("Comment"), aText); + } +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf117601) { mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"); |