summaryrefslogtreecommitdiffstats
path: root/desktop
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-07-11 21:18:34 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-08-10 23:07:59 +0200
commitb4d0b45ba6bce22501fbd623ac2ebf5da29ee356 (patch)
tree807633e6a7e102ff947d6a908c5c3afbb88b573f /desktop
parentfix JsonWriter::reallocBuffer (diff)
downloadcore-b4d0b45ba6bce22501fbd623ac2ebf5da29ee356.tar.gz
core-b4d0b45ba6bce22501fbd623ac2ebf5da29ee356.zip
add test for editing of annotations (using .uno:EditAnnotation)
Change-Id: Ic798ab94bb63a3ae80882e77cf1582d875e27d4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98583 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit fbecbb6872db7c40c8d632955589223a6c456475) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99882 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/data/BlankDrawDocument.odgbin0 -> 8183 bytes
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx68
2 files changed, 68 insertions, 0 deletions
diff --git a/desktop/qa/data/BlankDrawDocument.odg b/desktop/qa/data/BlankDrawDocument.odg
new file mode 100644
index 000000000000..19ae49d63b36
--- /dev/null
+++ b/desktop/qa/data/BlankDrawDocument.odg
Binary files differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 864041b71d49..7acb50499ae9 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -55,6 +55,7 @@
#include <ostream>
#include <config_features.h>
#include <config_mpl.h>
+#include <tools/json_writer.hxx>
#include <lib/init.hxx>
#include <svx/svxids.hrc>
@@ -206,6 +207,7 @@ public:
void testCommentsCalc();
void testCommentsImpress();
void testCommentsCallbacksWriter();
+ void testCommentsAddEditDeleteDraw();
void testRunMacro();
void testExtractParameter();
void testGetSignatureState_NonSigned();
@@ -265,6 +267,7 @@ public:
CPPUNIT_TEST(testCommentsCalc);
CPPUNIT_TEST(testCommentsImpress);
CPPUNIT_TEST(testCommentsCallbacksWriter);
+ CPPUNIT_TEST(testCommentsAddEditDeleteDraw);
CPPUNIT_TEST(testRunMacro);
CPPUNIT_TEST(testExtractParameter);
CPPUNIT_TEST(testGetSignatureState_Signed);
@@ -2346,6 +2349,71 @@ void DesktopLOKTest::testCommentsCallbacksWriter()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), aTree.get_child("comments").size());
}
+namespace
+{
+
+void addParameter(tools::JsonWriter& rJson, const char* sName, OString const & type, OString const & value)
+{
+ auto testNode = rJson.startNode(sName);
+ rJson.put("type", type);
+ rJson.put("value", value);
+}
+
+}
+
+void DesktopLOKTest::testCommentsAddEditDeleteDraw()
+{
+ // Comments callback are emitted only if tiled annotations are off
+ comphelper::LibreOfficeKit::setTiledAnnotations(false);
+ LibLODocument_Impl* pDocument = loadDoc("BlankDrawDocument.odg");
+ pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+ ViewCallback aView1(pDocument);
+
+ // Add a new comment
+ OString aCommandArgs;
+ {
+ tools::JsonWriter aJson;
+ addParameter(aJson, "Text", "string", "Comment");
+ addParameter(aJson, "Author", "string", "LOK User1");
+ aCommandArgs = aJson.extractAsOString();
+ }
+
+ pDocument->pClass->postUnoCommand(pDocument, ".uno:InsertAnnotation", aCommandArgs.getStr(), false);
+ Scheduler::ProcessEventsToIdle();
+
+ // We received a LOK_CALLBACK_COMMENT callback with comment 'Add' action
+ CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView1.m_aCommentCallbackResult.get<std::string>("action"));
+ int nCommentId1 = aView1.m_aCommentCallbackResult.get<int>("id");
+
+ // Edit the previously added comment
+ {
+ tools::JsonWriter aJson;
+ addParameter(aJson, "Id", "string", OString::number(nCommentId1));
+ addParameter(aJson, "Text", "string", "Edited comment");
+ aCommandArgs = aJson.extractAsOString();
+ }
+
+ pDocument->pClass->postUnoCommand(pDocument, ".uno:EditAnnotation", aCommandArgs.getStr(), false);
+ Scheduler::ProcessEventsToIdle();
+
+ // We received a LOK_CALLBACK_COMMENT callback with comment 'Modify' action
+ CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView1.m_aCommentCallbackResult.get<std::string>("action"));
+ CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("id"));
+
+ // Delete Comment
+ {
+ tools::JsonWriter aJson;
+ addParameter(aJson, "Id", "string", OString::number(nCommentId1));
+ aCommandArgs = aJson.extractAsOString();
+ }
+ pDocument->pClass->postUnoCommand(pDocument, ".uno:DeleteAnnotation", aCommandArgs.getStr(), false);
+ Scheduler::ProcessEventsToIdle();
+
+ // We received a LOK_CALLBACK_COMMENT callback with comment 'Remove' action
+ CPPUNIT_ASSERT_EQUAL(std::string("Remove"), aView1.m_aCommentCallbackResult.get<std::string>("action"));
+ CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("id"));
+}
+
void DesktopLOKTest::testRunMacro()
{
LibLibreOffice_Impl aOffice;