summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-02-20 19:33:22 +0530
committerPranav Kant <pranavk@collabora.co.uk>2017-02-20 19:41:38 +0530
commit65cfa0eed38ceeb4e96c97b76772bb191129fd83 (patch)
treecfd9b0abe1f5908f75189c23051371234f299636 /desktop
parent1654980341cff652de65d3b2aed52230e781e63a (diff)
desktop: unit test to for sd ViewAnnotations command
Change-Id: Ib830ff786f12d9edc791623dead74b3eeeabad71
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/data/blank_presentation.odpbin10864 -> 11358 bytes
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx60
2 files changed, 60 insertions, 0 deletions
diff --git a/desktop/qa/data/blank_presentation.odp b/desktop/qa/data/blank_presentation.odp
index 157901f9bb6c..a7d57a48e421 100644
--- a/desktop/qa/data/blank_presentation.odp
+++ b/desktop/qa/data/blank_presentation.odp
Binary files differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 90b918e91150..061905effb31 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -105,6 +105,7 @@ public:
void testGetFontSubset();
void testCommentsWriter();
void testCommentsCalc();
+ void testCommentsImpress();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
CPPUNIT_TEST(testGetStyles);
@@ -141,6 +142,7 @@ public:
CPPUNIT_TEST(testGetFontSubset);
CPPUNIT_TEST(testCommentsWriter);
CPPUNIT_TEST(testCommentsCalc);
+ CPPUNIT_TEST(testCommentsImpress);
CPPUNIT_TEST_SUITE_END();
uno::Reference<lang::XComponent> mxComponent;
@@ -1937,6 +1939,64 @@ void DesktopLOKTest::testCommentsCalc()
comphelper::LibreOfficeKit::setActive(false);
}
+
+void DesktopLOKTest::testCommentsImpress()
+{
+ comphelper::LibreOfficeKit::setActive();
+ // Disable tiled rendering for comments
+ comphelper::LibreOfficeKit::setTiledAnnotations(false);
+
+ LibLODocument_Impl* pDocument = loadDoc("blank_presentation.odp");
+ pDocument->m_pDocumentClass->initializeForRendering(pDocument, nullptr);
+
+ // Can we get all the comments using .uno:ViewAnnotations command ?
+ boost::property_tree::ptree aTree;
+ char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewAnnotations");
+ std::stringstream aStream(pJSON);
+ free(pJSON);
+ CPPUNIT_ASSERT(!aStream.str().empty());
+ boost::property_tree::read_json(aStream, aTree);
+ // There are 2 comments in the document already
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aTree.get_child("comments").size());
+
+ // Check if all comment fields have valid data
+ int nIdx = 0;
+ for (const auto& rComment : aTree.get_child("comments"))
+ {
+ switch(nIdx)
+ {
+ case 0:
+ {
+ CPPUNIT_ASSERT(rComment.second.get<int>("id") > 0);
+ CPPUNIT_ASSERT_EQUAL(std::string("This is comment1"), rComment.second.get<std::string>("text"));
+ CPPUNIT_ASSERT_EQUAL(std::string("LOK User1"), rComment.second.get<std::string>("author"));
+ css::util::DateTime aDateTime;
+ OUString aDateTimeString = OUString::createFromAscii(rComment.second.get<std::string>("dateTime").c_str());
+ CPPUNIT_ASSERT(utl::ISO8601parseDateTime(aDateTimeString, aDateTime));
+ }
+ break;
+ case 1:
+ {
+ CPPUNIT_ASSERT(rComment.second.get<int>("id") > 0);
+ CPPUNIT_ASSERT_EQUAL(std::string("This is comment2"), rComment.second.get<std::string>("text"));
+ CPPUNIT_ASSERT_EQUAL(std::string("LOK User2"), rComment.second.get<std::string>("author"));
+ css::util::DateTime aDateTime;
+ OUString aDateTimeString = OUString::createFromAscii(rComment.second.get<std::string>("dateTime").c_str());
+ CPPUNIT_ASSERT(utl::ISO8601parseDateTime(aDateTimeString, aDateTime));
+ }
+ break;
+ }
+
+ ++nIdx;
+ }
+
+ // We checked all the comments
+ CPPUNIT_ASSERT_EQUAL(2, nIdx);
+
+ comphelper::LibreOfficeKit::setTiledAnnotations(true);
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
CPPUNIT_PLUGIN_IMPLEMENT();