sc/qa/unit/uicalc/uicalc.cxx |   36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

New commits:
commit 359651c3f4c4615b2fdc859fa6d63989dd5396b1
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Tue Jul 18 15:22:08 2023 -0400
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Mon Aug 14 16:24:58 2023 +0200

    tdf#155799: sc: qa: add unit test "testMouseMergeRef"
    
    Change-Id: I2e46a014a3a66fe41b06a07a68c75e52ae5530f6
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155005
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155632

diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index ff8e84a03bff..d5973976441d 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -2068,6 +2068,42 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testKeyboardMergeRef)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testMouseMergeRef)
+{
+    mxComponent = loadFromDesktop("private:factory/scalc");
+    SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(mxComponent);
+    CPPUNIT_ASSERT(pFoundShell);
+    ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
+    CPPUNIT_ASSERT(pDocSh);
+    ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
+    CPPUNIT_ASSERT(pModelObj);
+    ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
+    CPPUNIT_ASSERT(pViewShell);
+
+    goToCell("A1:A5");
+    dispatchCommand(mxComponent, ".uno:ToggleMergeCells", {});
+    goToCell("A6:A10");
+    dispatchCommand(mxComponent, ".uno:ToggleMergeCells", {});
+
+    insertStringToCell(*pModelObj, "B1", "=", false);
+
+    Point aA1 = pViewShell->GetViewData().GetPrintTwipsPos(0, 0);
+    Point aA6 = pViewShell->GetViewData().GetPrintTwipsPos(0, 5);
+    Point aA7 = pViewShell->GetViewData().GetPrintTwipsPos(0, 6);
+
+    pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aA1.X() + 5, 
aA1.Y() + 5, 1, MOUSE_LEFT, 0);
+    pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEMOVE, aA6.X() + 5, aA6.Y() + 
5, 1, MOUSE_LEFT, 0);
+    pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aA7.X() + 5, 
aA7.Y() + 5, 1, MOUSE_LEFT, 0);
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT(pViewShell->IsRefInputMode());
+    {
+        const OUString* pInput = pViewShell->GetEditString();
+        CPPUNIT_ASSERT(pInput);
+        CPPUNIT_ASSERT_EQUAL(OUString("=A1:A10"), *pInput);
+    }
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to