summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerttumer <mert.tumer@collabora.com>2021-05-13 11:21:11 +0300
committerMert Tumer <mert.tumer@collabora.com>2021-05-13 13:47:20 +0200
commit285a41709835eba970cd3528a23b47eaea42d282 (patch)
treec8c90ba620c0c6b981e10266abb24f12251b6d46
parent6bb72e467bc062f27e5b83fec52e00103011f34d (diff)
Unit tests for .uno:MoveShapeHandle command
Change-Id: Ia1049325bf26fbe6a3c8ac77c873d1af010d3581 Signed-off-by: merttumer <mert.tumer@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115541 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx52
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx54
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx60
3 files changed, 166 insertions, 0 deletions
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();