summaryrefslogtreecommitdiff
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-07-12 10:36:12 +0200
commitfbecbb6872db7c40c8d632955589223a6c456475 (patch)
tree8da3200e8b135e8493b14002421fe7d6e619f074 /desktop
parente350318840cd4e4910079ec2bd0b95db54b48d42 (diff)
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>
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 a75e5ea805cf..4eeb728599b7 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -50,6 +50,7 @@
#include <cairo.h>
#include <config_features.h>
#include <config_mpl.h>
+#include <tools/json_writer.hxx>
#include <lib/init.hxx>
#include <svx/svxids.hrc>
@@ -159,6 +160,7 @@ public:
void testCommentsCalc();
void testCommentsImpress();
void testCommentsCallbacksWriter();
+ void testCommentsAddEditDeleteDraw();
void testRunMacro();
void testExtractParameter();
void testGetSignatureState_NonSigned();
@@ -218,6 +220,7 @@ public:
CPPUNIT_TEST(testCommentsCalc);
CPPUNIT_TEST(testCommentsImpress);
CPPUNIT_TEST(testCommentsCallbacksWriter);
+ CPPUNIT_TEST(testCommentsAddEditDeleteDraw);
CPPUNIT_TEST(testRunMacro);
CPPUNIT_TEST(testExtractParameter);
CPPUNIT_TEST(testGetSignatureState_Signed);
@@ -2286,6 +2289,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;