diff options
author | merttumer <mert.tumer@collabora.com> | 2021-05-13 11:21:11 +0300 |
---|---|---|
committer | Mert Tumer <mert.tumer@collabora.com> | 2021-06-04 10:39:05 +0200 |
commit | 67277595902dd22c68d9db1f7cf94f53447b237a (patch) | |
tree | 5ef739c836a97deb1c3ba5fe3f83370b0783e7b1 /sc/qa/unit | |
parent | 19b9da3e1f67611a3ec34cd5a8af508db4c05a4e (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>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116297
Tested-by: Jenkins
Diffstat (limited to 'sc/qa/unit')
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 092dcf8cb863..08cc5d724dcd 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -116,6 +116,7 @@ public: void testSortAscendingDescending(); void testAutoInputStringBlock(); void testAutoInputExactMatch(); + void testMoveShapeHandle(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); @@ -167,6 +168,7 @@ public: CPPUNIT_TEST(testSortAscendingDescending); CPPUNIT_TEST(testAutoInputStringBlock); CPPUNIT_TEST(testAutoInputExactMatch); + CPPUNIT_TEST(testMoveShapeHandle); CPPUNIT_TEST_SUITE_END(); private: @@ -444,6 +446,7 @@ public: boost::property_tree::ptree m_aCommentCallbackResult; OString m_sInvalidateHeader; OString m_sInvalidateSheetGeometry; + OString m_ShapeSelection; ViewCallback(bool bDeleteListenerOnDestruct=true) : m_bOwnCursorInvalidated(false), @@ -506,6 +509,7 @@ public: case LOK_CALLBACK_GRAPHIC_SELECTION: { m_bGraphicSelection = true; + m_ShapeSelection = OString(pPayload); } break; case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION: @@ -666,6 +670,54 @@ void ScTiledRenderingTest::testViewLock() CPPUNIT_ASSERT(!aView1.m_bViewLock); } +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(); |