[Libreoffice-commits] core.git: desktop/qa sw/qa

Pranav Kant pranavk at collabora.co.uk
Tue Feb 21 07:07:00 UTC 2017


 desktop/qa/desktop_lib/test_desktop_lib.cxx    |   99 ++++++++++++++++++++++
 sw/qa/extras/tiledrendering/tiledrendering.cxx |  108 -------------------------
 2 files changed, 100 insertions(+), 107 deletions(-)

New commits:
commit 0f6e813827fed1baefe6001b6e9655b0aeedcc46
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Feb 21 11:05:47 2017 +0530

    Revert "sw lok: Move this test to sw/"
    
    This reverts commit b7640cbb4b34df2cb05c6fbe60346bca96846924.
    
    Not much idea yet but moving it to sw/ for some reason makes callback
    pertaining to last 'InsertAnnotation' uno command not firing and on
    ubsan tinderbox even the first 'InsertAnnotation' command is a noOp
    failing the tests there. Lets keep it in desktop/ for now where it was
    earlier.
    
    Conflicts:
    	desktop/qa/desktop_lib/test_desktop_lib.cxx
    
    Change-Id: I67f5bdeffa218ae2a7afe0896f7cdde5324a5f09

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 061905e..62ec69d 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -106,6 +106,7 @@ public:
     void testCommentsWriter();
     void testCommentsCalc();
     void testCommentsImpress();
+    void testCommentsCallbacksWriter();
 
     CPPUNIT_TEST_SUITE(DesktopLOKTest);
     CPPUNIT_TEST(testGetStyles);
@@ -143,6 +144,7 @@ public:
     CPPUNIT_TEST(testCommentsWriter);
     CPPUNIT_TEST(testCommentsCalc);
     CPPUNIT_TEST(testCommentsImpress);
+    CPPUNIT_TEST(testCommentsCallbacksWriter);
     CPPUNIT_TEST_SUITE_END();
 
     uno::Reference<lang::XComponent> mxComponent;
@@ -1687,6 +1689,7 @@ class ViewCallback
 public:
     bool m_bTilesInvalidated;
     Rectangle m_aOwnCursor;
+    boost::property_tree::ptree m_aCommentCallbackResult;
 
     ViewCallback()
         : m_bTilesInvalidated(false)
@@ -1720,6 +1723,14 @@ public:
             m_aOwnCursor.setHeight(aSeq[3].toInt32());
         }
         break;
+        case LOK_CALLBACK_COMMENT:
+        {
+            m_aCommentCallbackResult.clear();
+            std::stringstream aStream(pPayload);
+            boost::property_tree::read_json(aStream, m_aCommentCallbackResult);
+            m_aCommentCallbackResult = m_aCommentCallbackResult.get_child("comment");
+        }
+        break;
         }
     }
 };
@@ -1997,6 +2008,94 @@ void DesktopLOKTest::testCommentsImpress()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testCommentsCallbacksWriter()
+{
+    comphelper::LibreOfficeKit::setActive();
+    // Comments callback are emitted only if tiled annotations are off
+    comphelper::LibreOfficeKit::setTiledAnnotations(false);
+    ViewCallback aView1;
+    ViewCallback aView2;
+    LibLODocument_Impl* pDocument = loadDoc("comments.odt");
+    pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+    pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView1);
+    pDocument->m_pDocumentClass->createView(pDocument);
+    pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+    pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView2);
+
+    // Add a new comment
+    OString aCommandArgs("{ \"Text\": { \"type\": \"string\", \"value\": \"Additional comment\" }, \"Author\": { \"type\": \"string\", \"value\": \"LOK User1\" } }");
+    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"));
+    CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView2.m_aCommentCallbackResult.get<std::string>("action"));
+    int nCommentId1 = aView1.m_aCommentCallbackResult.get<int>("id");
+
+    // Reply to a comment just added
+    aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\": \"" + OString::number(nCommentId1) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Reply comment\" } }";
+    pDocument->pClass->postUnoCommand(pDocument, ".uno:ReplyComment", aCommandArgs.getStr(), false);
+    Scheduler::ProcessEventsToIdle();
+
+    // We received a LOK_CALLBACK_COMMENT callback with comment 'Add' action and linked to its parent comment
+    CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView1.m_aCommentCallbackResult.get<std::string>("action"));
+    CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView2.m_aCommentCallbackResult.get<std::string>("action"));
+    CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("parent"));
+    CPPUNIT_ASSERT_EQUAL(nCommentId1, aView2.m_aCommentCallbackResult.get<int>("parent"));
+    CPPUNIT_ASSERT_EQUAL(std::string("Reply comment"), aView1.m_aCommentCallbackResult.get<std::string>("text"));
+    CPPUNIT_ASSERT_EQUAL(std::string("Reply comment"), aView2.m_aCommentCallbackResult.get<std::string>("text"));
+    int nCommentId2 = aView1.m_aCommentCallbackResult.get<int>("id");
+
+    // Edit the previously added comment
+    aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\": \"" + OString::number(nCommentId2) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Edited comment\" } }";
+    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(std::string("Modify"), aView2.m_aCommentCallbackResult.get<std::string>("action"));
+    // parent is unchanged still
+    CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("parent"));
+    CPPUNIT_ASSERT_EQUAL(nCommentId1, aView2.m_aCommentCallbackResult.get<int>("parent"));
+    CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView1.m_aCommentCallbackResult.get<std::string>("text"));
+    CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView2.m_aCommentCallbackResult.get<std::string>("text"));
+
+    // Delete the reply comment just added
+    aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\":  \"" + OString::number(nCommentId2) + "\" } }";
+    pDocument->pClass->postUnoCommand(pDocument, ".uno:DeleteComment", 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(std::string("Remove"), aView2.m_aCommentCallbackResult.get<std::string>("action"));
+    CPPUNIT_ASSERT_EQUAL(nCommentId2, aView1.m_aCommentCallbackResult.get<int>("id"));
+    CPPUNIT_ASSERT_EQUAL(nCommentId2, aView2.m_aCommentCallbackResult.get<int>("id"));
+
+    // Reply to nCommentId1 again
+    aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\": \"" + OString::number(nCommentId1) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Reply comment again\" } }";
+    pDocument->pClass->postUnoCommand(pDocument, ".uno:ReplyComment", aCommandArgs.getStr(), false);
+    Scheduler::ProcessEventsToIdle();
+
+    // We received a LOK_CALLBACK_COMMENT callback with comment 'Add' action and linked to its parent comment
+    CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView1.m_aCommentCallbackResult.get<std::string>("action"));
+    CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView2.m_aCommentCallbackResult.get<std::string>("action"));
+    CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("parent"));
+    CPPUNIT_ASSERT_EQUAL(nCommentId1, aView2.m_aCommentCallbackResult.get<int>("parent"));
+    CPPUNIT_ASSERT_EQUAL(std::string("Reply comment again"), aView1.m_aCommentCallbackResult.get<std::string>("text"));
+    CPPUNIT_ASSERT_EQUAL(std::string("Reply comment again"), aView2.m_aCommentCallbackResult.get<std::string>("text"));
+
+    // .uno:ViewAnnotations returns total of 5 comments
+    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);
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), aTree.get_child("comments").size());
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 9b25ba7..0a55c6c 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -81,7 +81,7 @@ public:
     void testPaintCallbacks();
     void testUndoRepairResult();
     void testRedoRepairResult();
-    void testCommentsCallbacks();
+
 
     CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -126,7 +126,6 @@ public:
     CPPUNIT_TEST(testPaintCallbacks);
     CPPUNIT_TEST(testUndoRepairResult);
     CPPUNIT_TEST(testRedoRepairResult);
-    CPPUNIT_TEST(testCommentsCallbacks);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -652,7 +651,6 @@ public:
     bool m_bViewLock;
     /// Set if any callback was invoked.
     bool m_bCalled;
-    boost::property_tree::ptree m_aCommentCallbackResult;
 
     ViewCallback()
         : m_bOwnCursorInvalidated(false),
@@ -759,14 +757,6 @@ public:
             m_bViewLock = aTree.get_child("rectangle").get_value<std::string>() != "EMPTY";
         }
         break;
-        case LOK_CALLBACK_COMMENT:
-        {
-            m_aCommentCallbackResult.clear();
-            std::stringstream aStream(pPayload);
-            boost::property_tree::read_json(aStream, m_aCommentCallbackResult);
-            m_aCommentCallbackResult = m_aCommentCallbackResult.get_child("comment");
-        }
-        break;
         }
     }
 };
@@ -1679,102 +1669,6 @@ void SwTiledRenderingTest::testRedoRepairResult()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
-void SwTiledRenderingTest::testCommentsCallbacks()
-{
-    comphelper::LibreOfficeKit::setActive();
-    // Comments callback are emitted only if tiled annotations are off
-    comphelper::LibreOfficeKit::setTiledAnnotations(false);
-
-    SwXTextDocument* pXTextDocument = createDoc();
-    ViewCallback aView1;
-    SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
-    int nView1 = SfxLokHelper::getView();
-
-    // Crete a second view
-    SfxLokHelper::createView();
-    pXTextDocument->initializeForTiledRendering({});
-    ViewCallback aView2;
-    SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
-
-    SfxLokHelper::setView(nView1);
-
-    // Add a new comment
-    uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
-    {
-        {"Text", uno::makeAny(OUString("Comment"))},
-        {"Author", uno::makeAny(OUString("LOK User1"))},
-    }));
-    comphelper::dispatchCommand(".uno:InsertAnnotation", aPropertyValues);
-    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"));
-    CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView2.m_aCommentCallbackResult.get<std::string>("action"));
-    int nCommentId1 = aView1.m_aCommentCallbackResult.get<int>("id");
-
-    // Reply to a comment just added
-    aPropertyValues = comphelper::InitPropertySequence(
-    {
-        {"Id", uno::makeAny(OUString::number(nCommentId1))},
-        {"Text", uno::makeAny(OUString("Reply comment"))},
-    });
-    comphelper::dispatchCommand(".uno:ReplyComment", aPropertyValues);
-    Scheduler::ProcessEventsToIdle();
-
-    // We received a LOK_CALLBACK_COMMENT callback with comment 'Add' action and linked to its parent comment
-    CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView1.m_aCommentCallbackResult.get<std::string>("action"));
-    CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView2.m_aCommentCallbackResult.get<std::string>("action"));
-    CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("parent"));
-    CPPUNIT_ASSERT_EQUAL(nCommentId1, aView2.m_aCommentCallbackResult.get<int>("parent"));
-    CPPUNIT_ASSERT_EQUAL(std::string("Reply comment"), aView1.m_aCommentCallbackResult.get<std::string>("text"));
-    CPPUNIT_ASSERT_EQUAL(std::string("Reply comment"), aView2.m_aCommentCallbackResult.get<std::string>("text"));
-    int nCommentId2 = aView1.m_aCommentCallbackResult.get<int>("id");
-
-    // Edit the previously added comment
-    aPropertyValues = comphelper::InitPropertySequence(
-    {
-        {"Id", uno::makeAny(OUString::number(nCommentId2))},
-        {"Text", uno::makeAny(OUString("Edited comment"))},
-    });
-    comphelper::dispatchCommand(".uno:EditAnnotation", aPropertyValues);
-    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(std::string("Modify"), aView2.m_aCommentCallbackResult.get<std::string>("action"));
-    // parent is unchanged still
-    CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("parent"));
-    CPPUNIT_ASSERT_EQUAL(nCommentId1, aView2.m_aCommentCallbackResult.get<int>("parent"));
-    CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView1.m_aCommentCallbackResult.get<std::string>("text"));
-    CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView2.m_aCommentCallbackResult.get<std::string>("text"));
-
-    // Delete the reply comment just added
-    aPropertyValues = comphelper::InitPropertySequence(
-    {
-        {"Id", uno::makeAny(OUString::number(nCommentId2))},
-    });
-    comphelper::dispatchCommand(".uno:DeleteComment", aPropertyValues);
-    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(std::string("Remove"), aView2.m_aCommentCallbackResult.get<std::string>("action"));
-    CPPUNIT_ASSERT_EQUAL(nCommentId2, aView1.m_aCommentCallbackResult.get<int>("id"));
-    CPPUNIT_ASSERT_EQUAL(nCommentId2, aView2.m_aCommentCallbackResult.get<int>("id"));
-
-    // .uno:ViewAnnotations returns total of 1 comment
-    OUString aPostIts = pXTextDocument->getPostIts();
-    std::stringstream aStream(aPostIts.toUtf8().getStr());
-    boost::property_tree::ptree aTree;
-    boost::property_tree::read_json(aStream, aTree);
-    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aTree.get_child("comments").size());
-
-    mxComponent->dispose();
-    mxComponent.clear();
-    comphelper::LibreOfficeKit::setTiledAnnotations(true);
-    comphelper::LibreOfficeKit::setActive(false);
-}
-
 CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list