[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sc/qa sd/qa sw/qa

merttumer (via logerrit) logerrit at kemper.freedesktop.org
Thu May 13 11:47:54 UTC 2021


 sc/qa/unit/tiledrendering/tiledrendering.cxx   |   52 +++++++++++++++++++++
 sd/qa/unit/tiledrendering/tiledrendering.cxx   |   54 ++++++++++++++++++++++
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   60 +++++++++++++++++++++++++
 3 files changed, 166 insertions(+)

New commits:
commit 285a41709835eba970cd3528a23b47eaea42d282
Author:     merttumer <mert.tumer at collabora.com>
AuthorDate: Thu May 13 11:21:11 2021 +0300
Commit:     Mert Tumer <mert.tumer at collabora.com>
CommitDate: Thu May 13 13:47:20 2021 +0200

    Unit tests for .uno:MoveShapeHandle command
    
    Change-Id: Ia1049325bf26fbe6a3c8ac77c873d1af010d3581
    Signed-off-by: merttumer <mert.tumer at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115541
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index ffb570d3fdf6..5772a5405f04 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -118,6 +118,7 @@ public:
     void testSortAscendingDescending();
     void testAutoInputStringBlock();
     void testAutoInputExactMatch();
+    void testMoveShapeHandle();
 
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
@@ -169,6 +170,7 @@ public:
     CPPUNIT_TEST(testSortAscendingDescending);
     CPPUNIT_TEST(testAutoInputStringBlock);
     CPPUNIT_TEST(testAutoInputExactMatch);
+    CPPUNIT_TEST(testMoveShapeHandle);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -446,6 +448,7 @@ public:
     boost::property_tree::ptree m_aCommentCallbackResult;
     OString m_sInvalidateHeader;
     OString m_sInvalidateSheetGeometry;
+    OString m_ShapeSelection;
 
     ViewCallback(bool bDeleteListenerOnDestruct=true)
         : m_bOwnCursorInvalidated(false),
@@ -508,6 +511,7 @@ public:
         case LOK_CALLBACK_GRAPHIC_SELECTION:
         {
             m_bGraphicSelection = true;
+            m_ShapeSelection = OString(pPayload);
         }
         break;
         case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
@@ -668,6 +672,54 @@ void ScTiledRenderingTest::testViewLock()
     CPPUNIT_ASSERT(!aView1.m_bViewLock);
 }
 
+static void lcl_extractHandleParameters(const OString& selection, int& id, int& x, int& y)
+{
+    OString extraInfo = selection.copy(selection.indexOf("{"));
+    std::stringstream aStream(extraInfo.getStr());
+    boost::property_tree::ptree aTree;
+    boost::property_tree::read_json(aStream, aTree);
+    boost::property_tree::ptree
+        handle0 = aTree
+            .get_child("handles")
+            .get_child("kinds")
+            .get_child("rectangle")
+            .get_child("1")
+            .begin()->second;
+    id = handle0.get_child("id").get_value<int>();
+    x = handle0.get_child("point").get_child("x").get_value<int>();
+    y = handle0.get_child("point").get_child("y").get_value<int>();
+}
+
+void ScTiledRenderingTest::testMoveShapeHandle()
+{
+    comphelper::LibreOfficeKit::setActive();
+    ScModelObj* pModelObj = createDoc("shape.ods");
+    ViewCallback aView1;
+    pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, /*x=*/ 1,/*y=*/ 1,/*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+    pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, /*x=*/ 1, /*y=*/ 1, /*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT(!aView1.m_ShapeSelection.isEmpty());
+    {
+        int id, x, y;
+        lcl_extractHandleParameters(aView1.m_ShapeSelection, id, x ,y);
+        int oldX = x;
+        int oldY = y;
+        uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+        {
+            {"HandleNum", uno::makeAny(id)},
+            {"NewPosX", uno::makeAny(x+1)},
+            {"NewPosY", uno::makeAny(y+1)}
+        }));
+        comphelper::dispatchCommand(".uno:MoveShapeHandle", aPropertyValues);
+        Scheduler::ProcessEventsToIdle();
+        CPPUNIT_ASSERT(!aView1.m_ShapeSelection.isEmpty());
+        lcl_extractHandleParameters(aView1.m_ShapeSelection, id, x ,y);
+        CPPUNIT_ASSERT_EQUAL(x-1, oldX);
+        CPPUNIT_ASSERT_EQUAL(y-1, oldY);
+    }
+}
+
 void ScTiledRenderingTest::testColRowResize()
 {
     comphelper::LibreOfficeKit::setActive();
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 109cc29edc87..ac1380ad2165 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -130,6 +130,7 @@ public:
     void testInsertDeletePageInvalidation();
     void testSpellOnlineRenderParameter();
     void testSlideDuplicateUndo();
+    void testMoveShapeHandle();
 
     CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
     CPPUNIT_TEST(testCreateDestroy);
@@ -185,6 +186,7 @@ public:
     CPPUNIT_TEST(testInsertDeletePageInvalidation);
     CPPUNIT_TEST(testSpellOnlineRenderParameter);
     CPPUNIT_TEST(testSlideDuplicateUndo);
+    CPPUNIT_TEST(testMoveShapeHandle);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -866,6 +868,7 @@ public:
     std::map<int, bool> m_aViewCursorVisibilities;
     bool m_bViewSelectionSet;
     boost::property_tree::ptree m_aCommentCallbackResult;
+    OString m_ShapeSelection;
 
     ViewCallback()
         : m_bGraphicSelectionInvalidated(false),
@@ -917,6 +920,7 @@ public:
         case LOK_CALLBACK_GRAPHIC_SELECTION:
         {
             m_bGraphicSelectionInvalidated = true;
+            m_ShapeSelection = OString(pPayload);
         }
         break;
         case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
@@ -2611,6 +2615,56 @@ void SdTiledRenderingTest::testSlideDuplicateUndo()
     CPPUNIT_ASSERT(!pView0->GetTextEditPageView());
 }
 
+static void lcl_extractHandleParameters(const OString& selection, int& id, int& x, int& y)
+{
+    OString extraInfo = selection.copy(selection.indexOf("{"));
+    std::stringstream aStream(extraInfo.getStr());
+    boost::property_tree::ptree aTree;
+    boost::property_tree::read_json(aStream, aTree);
+    boost::property_tree::ptree
+        handle0 = aTree
+            .get_child("handles")
+            .get_child("kinds")
+            .get_child("rectangle")
+            .get_child("1")
+            .begin()->second;
+    id = handle0.get_child("id").get_value<int>();
+    x = handle0.get_child("point").get_child("x").get_value<int>();
+    y = handle0.get_child("point").get_child("y").get_value<int>();
+}
+
+void SdTiledRenderingTest::testMoveShapeHandle()
+{
+    SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
+    ViewCallback aView1;
+    sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+    SdPage* pPage = pViewShell->GetActualPage();
+    SdrObject* pObject = pPage->GetObj(0);
+    SdrView* pView = pViewShell->GetView();
+    pView->MarkObj(pObject, pView->GetSdrPageView());
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT(!aView1.m_ShapeSelection.isEmpty());
+    {
+        int id, x, y;
+        lcl_extractHandleParameters(aView1.m_ShapeSelection, id, x ,y);
+        int oldX = x;
+        int oldY = y;
+        uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+        {
+            {"HandleNum", uno::makeAny(id)},
+            {"NewPosX", uno::makeAny(x+1)},
+            {"NewPosY", uno::makeAny(y+1)}
+        }));
+        comphelper::dispatchCommand(".uno:MoveShapeHandle", aPropertyValues);
+        Scheduler::ProcessEventsToIdle();
+        CPPUNIT_ASSERT(!aView1.m_ShapeSelection.isEmpty());
+        lcl_extractHandleParameters(aView1.m_ShapeSelection, id, x ,y);
+        CPPUNIT_ASSERT_EQUAL(x-1, oldX);
+        CPPUNIT_ASSERT_EQUAL(y-1, oldY);
+    }
+
+}
 CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 4b9e133c3a52..3a79210430b0 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -138,6 +138,7 @@ public:
     void testBulletDeleteInvalidation();
     void testBulletNoNumInvalidation();
     void testBulletMultiDeleteInvalidation();
+    void testMoveShapeHandle();
 
     CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -212,6 +213,7 @@ public:
     CPPUNIT_TEST(testBulletDeleteInvalidation);
     CPPUNIT_TEST(testBulletNoNumInvalidation);
     CPPUNIT_TEST(testBulletMultiDeleteInvalidation);
+    CPPUNIT_TEST(testMoveShapeHandle);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -236,6 +238,7 @@ private:
     OString m_sHyperlinkText;
     OString m_sHyperlinkLink;
     OString m_aFormFieldButton;
+    OString m_ShapeSelection;
 };
 
 SwTiledRenderingTest::SwTiledRenderingTest()
@@ -388,7 +391,13 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
         m_aFormFieldButton = OString(pPayload);
     }
     break;
+    case LOK_CALLBACK_GRAPHIC_SELECTION:
+    {
+        m_ShapeSelection = OString(pPayload);
+    }
+    break;
     }
+
 }
 
 void SwTiledRenderingTest::testRegisterCallback()
@@ -2724,6 +2733,57 @@ void SwTiledRenderingTest::testDropDownFormFieldButtonNoSelection()
     }
 }
 
+static void lcl_extractHandleParameters(const OString& selection, int& id, int& x, int& y)
+{
+    OString extraInfo = selection.copy(selection.indexOf("{"));
+    std::stringstream aStream(extraInfo.getStr());
+    boost::property_tree::ptree aTree;
+    boost::property_tree::read_json(aStream, aTree);
+    boost::property_tree::ptree
+        handle0 = aTree
+            .get_child("handles")
+            .get_child("kinds")
+            .get_child("rectangle")
+            .get_child("1")
+            .begin()->second;
+    id = handle0.get_child("id").get_value<int>();
+    x = handle0.get_child("point").get_child("x").get_value<int>();
+    y = handle0.get_child("point").get_child("y").get_value<int>();
+}
+
+void SwTiledRenderingTest::testMoveShapeHandle()
+{
+    comphelper::LibreOfficeKit::setActive();
+    SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
+
+    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+    SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+    SdrObject* pObject = pPage->GetObj(0);
+    pWrtShell->SelectObj(Point(), 0, pObject);
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT(!m_ShapeSelection.isEmpty());
+    {
+        int id, x, y;
+        lcl_extractHandleParameters(m_ShapeSelection, id, x ,y);
+        int oldX = x;
+        int oldY = y;
+        uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+        {
+            {"HandleNum", uno::makeAny(id)},
+            {"NewPosX", uno::makeAny(x+1)},
+            {"NewPosY", uno::makeAny(y+1)}
+        }));
+        comphelper::dispatchCommand(".uno:MoveShapeHandle", aPropertyValues);
+        Scheduler::ProcessEventsToIdle();
+        CPPUNIT_ASSERT(!m_ShapeSelection.isEmpty());
+        lcl_extractHandleParameters(m_ShapeSelection, id, x ,y);
+        CPPUNIT_ASSERT_EQUAL(x-1, oldX);
+        CPPUNIT_ASSERT_EQUAL(y-1, oldY);
+    }
+}
+
 void SwTiledRenderingTest::testDropDownFormFieldButtonNoItem()
 {
     comphelper::LibreOfficeKit::setActive();


More information about the Libreoffice-commits mailing list