summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-02-20 19:33:22 +0530
committerAndras Timar <andras.timar@collabora.com>2017-02-28 11:16:24 +0100
commit8a541f4a27526cf6277c86ca6634b5a6e38f4622 (patch)
tree3fcabbae596bf4be3e38afd84b9d2987a6069271 /desktop
parent6f050c4591400acbf860e99ae70da7a18fab5103 (diff)
desktop: unit test to for sd ViewAnnotations command
Change-Id: Ib830ff786f12d9edc791623dead74b3eeeabad71 (cherry picked from commit 65cfa0eed38ceeb4e96c97b76772bb191129fd83)
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 a2c5262e1c1b..896c90d27840 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -110,6 +110,7 @@ public:
void testGetFontSubset();
void testCommentsWriter();
void testCommentsCalc();
+ void testCommentsImpress();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
CPPUNIT_TEST(testGetStyles);
@@ -147,6 +148,7 @@ public:
CPPUNIT_TEST(testGetFontSubset);
CPPUNIT_TEST(testCommentsWriter);
CPPUNIT_TEST(testCommentsCalc);
+ CPPUNIT_TEST(testCommentsImpress);
CPPUNIT_TEST_SUITE_END();
uno::Reference<lang::XComponent> mxComponent;
@@ -1986,6 +1988,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();