From b4d0b45ba6bce22501fbd623ac2ebf5da29ee356 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sat, 11 Jul 2020 21:18:34 +0200 Subject: add test for editing of annotations (using .uno:EditAnnotation) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic798ab94bb63a3ae80882e77cf1582d875e27d4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98583 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit fbecbb6872db7c40c8d632955589223a6c456475) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99882 Tested-by: Jenkins CollaboraOffice --- sd/qa/unit/tiledrendering/data/dummy.odg | Bin 0 -> 8183 bytes sd/qa/unit/tiledrendering/tiledrendering.cxx | 56 +++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 sd/qa/unit/tiledrendering/data/dummy.odg (limited to 'sd') diff --git a/sd/qa/unit/tiledrendering/data/dummy.odg b/sd/qa/unit/tiledrendering/data/dummy.odg new file mode 100644 index 000000000000..19ae49d63b36 Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/dummy.odg differ diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index b6090961ebb7..d7c2719e105a 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -110,7 +110,8 @@ public: void testTdf81754(); void testTdf105502(); void testCommentCallbacks(); - void testCommentChange(); + void testCommentChangeImpress(); + void testCommentChangeDraw(); void testMultiViewInsertDeletePage(); void testDisableUndoRepair(); void testDocumentRepair(); @@ -160,7 +161,8 @@ public: CPPUNIT_TEST(testTdf81754); CPPUNIT_TEST(testTdf105502); CPPUNIT_TEST(testCommentCallbacks); - CPPUNIT_TEST(testCommentChange); + CPPUNIT_TEST(testCommentChangeImpress); + CPPUNIT_TEST(testCommentChangeDraw); CPPUNIT_TEST(testMultiViewInsertDeletePage); CPPUNIT_TEST(testDisableUndoRepair); CPPUNIT_TEST(testDocumentRepair); @@ -1781,7 +1783,7 @@ void SdTiledRenderingTest::testCommentCallbacks() comphelper::LibreOfficeKit::setTiledAnnotations(true); } -void SdTiledRenderingTest::testCommentChange() +void SdTiledRenderingTest::testCommentChangeImpress() { uno::Sequence aArgs; @@ -1829,6 +1831,54 @@ void SdTiledRenderingTest::testCommentChange() comphelper::LibreOfficeKit::setTiledAnnotations(true); } +void SdTiledRenderingTest::testCommentChangeDraw() +{ + uno::Sequence aArgs; + + // Load the document. + // Set the tiled annotations off + comphelper::LibreOfficeKit::setTiledAnnotations(false); + + createDoc("dummy.odg", comphelper::InitPropertySequence( + { + {".uno:Author", uno::makeAny(OUString("LOK User1"))}, + })); + + ViewCallback aView1; + + // Add a new comment + aArgs = comphelper::InitPropertySequence( + { + {"Text", uno::makeAny(OUString("Comment"))}, + }); + comphelper::dispatchCommand(".uno:InsertAnnotation", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView1.m_aCommentCallbackResult.get("action")); + + int nComment1 = aView1.m_aCommentCallbackResult.get("id"); + + CPPUNIT_ASSERT(!aView1.m_aCommentCallbackResult.get("parthash").empty()); + CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView1.m_aCommentCallbackResult.get("text")); + CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 0, 0"), aView1.m_aCommentCallbackResult.get("rectangle")); + + // Edit this annotation now + aArgs = comphelper::InitPropertySequence( + { + {"Id", uno::makeAny(OUString::number(nComment1))}, + {"PositionX", uno::makeAny(sal_Int32(10))}, + {"PositionY", uno::makeAny(sal_Int32(20))} + }); + comphelper::dispatchCommand(".uno:EditAnnotation", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView1.m_aCommentCallbackResult.get("action")); + CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView1.m_aCommentCallbackResult.get("text")); + CPPUNIT_ASSERT_EQUAL(std::string("10, 20, 0, 0"), aView1.m_aCommentCallbackResult.get("rectangle")); + + comphelper::LibreOfficeKit::setTiledAnnotations(true); +} + void SdTiledRenderingTest::testMultiViewInsertDeletePage() { // Load the document. -- cgit