summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-02-17 16:40:54 +0530
committerAndras Timar <andras.timar@collabora.com>2017-02-28 11:06:56 +0100
commit0eaba3a575154ac6035049ba16c101e0ff43e0fd (patch)
tree3cc8b07778134358ba2f2a6ec92b90015379c171 /desktop
parente9c98f896ad95301bf62aa518e117e0a509d0b68 (diff)
sc lok: Unit tests for Comments API
Change-Id: I896c8b25cab6d80d374d273eb3945716bc0694d6 Reviewed-on: https://gerrit.libreoffice.org/34365 Reviewed-by: pranavk <pranavk@collabora.co.uk> Tested-by: pranavk <pranavk@collabora.co.uk> (cherry picked from commit 0d839366acfd932b8ae1b31b72c5eca4e102834d)
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/data/sheets.odsbin8898 -> 9669 bytes
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx57
2 files changed, 56 insertions, 1 deletions
diff --git a/desktop/qa/data/sheets.ods b/desktop/qa/data/sheets.ods
index 0acf86541ba9..3f43fa3a3d78 100644
--- a/desktop/qa/data/sheets.ods
+++ b/desktop/qa/data/sheets.ods
Binary files differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 20cde3313ef5..a2c5262e1c1b 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -109,6 +109,7 @@ public:
void testWriterCommentInsertCursor();
void testGetFontSubset();
void testCommentsWriter();
+ void testCommentsCalc();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
CPPUNIT_TEST(testGetStyles);
@@ -145,6 +146,7 @@ public:
CPPUNIT_TEST(testWriterCommentInsertCursor);
CPPUNIT_TEST(testGetFontSubset);
CPPUNIT_TEST(testCommentsWriter);
+ CPPUNIT_TEST(testCommentsCalc);
CPPUNIT_TEST_SUITE_END();
uno::Reference<lang::XComponent> mxComponent;
@@ -1905,7 +1907,7 @@ void DesktopLOKTest::testCommentsWriter()
int nComment2Id = 0;
// Check if all comment fields have valid data
- for (boost::property_tree::ptree::value_type& rComment : aTree.get_child("comments"))
+ for (const auto& rComment : aTree.get_child("comments"))
{
CPPUNIT_ASSERT(rComment.second.get<int>("id") > 0);
CPPUNIT_ASSERT(!rComment.second.get<std::string>("author").empty());
@@ -1928,6 +1930,59 @@ void DesktopLOKTest::testCommentsWriter()
}
}
+ comphelper::LibreOfficeKit::setTiledAnnotations(true);
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
+
+void DesktopLOKTest::testCommentsCalc()
+{
+ comphelper::LibreOfficeKit::setActive();
+ // Disable tiled rendering for comments
+ comphelper::LibreOfficeKit::setTiledAnnotations(false);
+
+ LibLODocument_Impl* pDocument = loadDoc("sheets.ods");
+ 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_EQUAL(std::string("Sheet5.G15"), rComment.second.get<std::string>("id"));
+ CPPUNIT_ASSERT_EQUAL(std::string("Comment1"), rComment.second.get<std::string>("text"));
+ CPPUNIT_ASSERT_EQUAL(std::string("7650, 3570, 1274, 254"), rComment.second.get<std::string>("cellPos"));
+ }
+ break;
+ case 1:
+ {
+ CPPUNIT_ASSERT_EQUAL(std::string("Sheet5.H18"), rComment.second.get<std::string>("id"));
+ CPPUNIT_ASSERT_EQUAL(std::string("Comment2"), rComment.second.get<std::string>("text"));
+ CPPUNIT_ASSERT_EQUAL(std::string("8925, 4335, 1274, 254"), rComment.second.get<std::string>("cellPos"));
+ }
+ break;
+ }
+
+ ++nIdx;
+ }
+
+ // We checked all the comments
+ CPPUNIT_ASSERT_EQUAL(2, nIdx);
+
+ comphelper::LibreOfficeKit::setTiledAnnotations(true);
comphelper::LibreOfficeKit::setActive(false);
}