summaryrefslogtreecommitdiff
path: root/desktop/qa/desktop_lib/test_desktop_lib.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/qa/desktop_lib/test_desktop_lib.cxx')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d71532919ade..5485da30cb67 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -98,6 +98,7 @@ public:
void testNotificationCompression();
void testRedlineWriter();
void testTrackChanges();
+ void testRedlineCalc();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
CPPUNIT_TEST(testModifiedStatus);
@@ -127,6 +128,7 @@ public:
CPPUNIT_TEST(testNotificationCompression);
CPPUNIT_TEST(testRedlineWriter);
CPPUNIT_TEST(testTrackChanges);
+ CPPUNIT_TEST(testRedlineCalc);
CPPUNIT_TEST_SUITE_END();
uno::Reference<lang::XComponent> mxComponent;
@@ -1210,6 +1212,35 @@ void DesktopLOKTest::testRedlineWriter()
comphelper::LibreOfficeKit::setActive(false);
}
+void DesktopLOKTest::testRedlineCalc()
+{
+ // Load a Writer document, enable change recording and press a key.
+ comphelper::LibreOfficeKit::setActive();
+ LibLODocument_Impl* pDocument = loadDoc("sheets.ods");
+ uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
+ xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true));
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0);
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 't', 0);
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 0, KEY_RETURN);
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 0, KEY_RETURN);
+
+ // Get redline info.
+ boost::property_tree::ptree aTree;
+ char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:AcceptTrackedChanges");
+ std::stringstream aStream(pJSON);
+ free(pJSON);
+ CPPUNIT_ASSERT(!aStream.str().empty());
+ boost::property_tree::read_json(aStream, aTree);
+ // Make sure that pressing a key creates exactly one redline.
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aTree.get_child("redlines").size());
+
+ for (boost::property_tree::ptree::value_type& rRedline : aTree.get_child("redlines"))
+ // This failed with boost::property_tree::ptree_bad_path, as there were no description field.
+ CPPUNIT_ASSERT_EQUAL(std::string("Cell B4 changed from '5' to 't'"), rRedline.second.get<std::string>("description"));
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
CPPUNIT_PLUGIN_IMPLEMENT();