[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - desktop/qa

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Fri Oct 8 16:51:47 UTC 2021


 desktop/qa/desktop_lib/test_desktop_lib.cxx |  128 ++++++++++++++++++++++++++++
 1 file changed, 128 insertions(+)

New commits:
commit 5a94a3c53d7c4b350520fc59d5ddc6c3e8ee73fc
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Fri Sep 10 07:16:04 2021 -0400
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Oct 8 18:51:11 2021 +0200

    lok: sc: unit test drag & drop
    
    ..
    
    Change-Id: I774ece93e5c439c65df50e6a67d1447a062708b3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121898
    Tested-by: Szymon Kłos <szymon.klos at collabora.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 36408ff79fb7..e592bfd24b9d 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -160,6 +160,7 @@ public:
     void testWriterComments();
     void testSheetOperations();
     void testSheetSelections();
+    void testSheetDragDrop();
     void testContextMenuCalc();
     void testContextMenuWriter();
     void testContextMenuImpress();
@@ -225,6 +226,7 @@ public:
     CPPUNIT_TEST(testWriterComments);
     CPPUNIT_TEST(testSheetOperations);
     CPPUNIT_TEST(testSheetSelections);
+    CPPUNIT_TEST(testSheetDragDrop);
     CPPUNIT_TEST(testContextMenuCalc);
     CPPUNIT_TEST(testContextMenuWriter);
     CPPUNIT_TEST(testContextMenuImpress);
@@ -1138,6 +1140,132 @@ void DesktopLOKTest::testSheetSelections()
     }
 }
 
+void DesktopLOKTest::testSheetDragDrop()
+{
+    LibLODocument_Impl* pDocument = loadDoc("sheets.ods", LOK_DOCTYPE_SPREADSHEET);
+    pDocument->pClass->initializeForRendering(pDocument, nullptr);
+    pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+
+    int row01 = 100;
+    int col01 = 1100;
+    int col02 = 2200;
+    int col03 = 3300;
+    int col05 = 5500;
+    int col07 = 5700;
+
+    // Select row 01 from column 01 through column 05
+    pDocument->pClass->postMouseEvent(pDocument,
+                                      LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+                                      col01, row01,
+                                      1, 1, 0);
+    pDocument->pClass->postMouseEvent(pDocument,
+                                      LOK_MOUSEEVENT_MOUSEMOVE,
+                                      col02, row01,
+                                      1, 1, 0);
+    pDocument->pClass->postMouseEvent(pDocument,
+                                      LOK_MOUSEEVENT_MOUSEMOVE,
+                                      col05, row01,
+                                      1, 1, 0);
+    pDocument->pClass->postMouseEvent(pDocument,
+                                      LOK_MOUSEEVENT_MOUSEBUTTONUP,
+                                      col05, row01,
+                                      1, 1, 0);
+
+    Scheduler::ProcessEventsToIdle();
+    {
+        SfxViewShell* pViewShell = SfxViewShell::Current();
+        SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
+
+        OUString sValue;
+        css::uno::Any aValue;
+        css::util::URL aURL;
+        std::unique_ptr<SfxPoolItem> pState;
+
+        aURL.Protocol = ".uno:";
+        aURL.Complete = ".uno:Address";
+        aURL.Path = "Address";
+        aURL.Main = ".uno:Address";
+
+        pViewFrame->GetBindings().QueryState(pViewFrame->GetBindings().QuerySlotId(aURL), pState);
+        pState->QueryValue(aValue);
+        aValue >>= sValue;
+        CPPUNIT_ASSERT_EQUAL(OUString("Sheet5.A1:E1"), sValue);
+    }
+
+    // Check selection content
+    {
+        char* pMimeType = nullptr;
+        char* pContent = pDocument->pClass->getTextSelection(pDocument, nullptr, &pMimeType);
+        std::vector<long> aExpected = {1, 2, 3, 4, 5};
+        std::istringstream aContent(pContent);
+        std::string token;
+        for (size_t i = 0; i < aExpected.size(); i++)
+        {
+            aContent >> token;
+            CPPUNIT_ASSERT_EQUAL(aExpected[i], strtol(token.c_str(), nullptr, 10));
+        }
+
+        free(pMimeType);
+        free(pContent);
+    }
+
+    // drag and drop
+    pDocument->pClass->postMouseEvent(pDocument,
+                                      LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+                                      col01, row01,
+                                      1, 1, 0);
+    pDocument->pClass->postMouseEvent(pDocument,
+                                      LOK_MOUSEEVENT_MOUSEMOVE,
+                                      col02, row01,
+                                      1, 1, 0);
+    pDocument->pClass->postMouseEvent(pDocument,
+                                      LOK_MOUSEEVENT_MOUSEMOVE,
+                                      col03, row01,
+                                      1, 1, 0);
+    pDocument->pClass->postMouseEvent(pDocument,
+                                      LOK_MOUSEEVENT_MOUSEBUTTONUP,
+                                      col07, row01,
+                                      1, 1, 0);
+
+    Scheduler::ProcessEventsToIdle();
+    {
+        SfxViewShell* pViewShell = SfxViewShell::Current();
+        SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
+
+        OUString sValue;
+        css::uno::Any aValue;
+        css::util::URL aURL;
+        std::unique_ptr<SfxPoolItem> pState;
+
+        aURL.Protocol = ".uno:";
+        aURL.Complete = ".uno:Address";
+        aURL.Path = "Address";
+        aURL.Main = ".uno:Address";
+
+        pViewFrame->GetBindings().QueryState(pViewFrame->GetBindings().QuerySlotId(aURL), pState);
+        pState->QueryValue(aValue);
+        aValue >>= sValue;
+        CPPUNIT_ASSERT_EQUAL(OUString("Sheet5.D1:H1"), sValue);
+    }
+
+    // Check selection content
+    {
+        char* pMimeType = nullptr;
+        char* pContent = pDocument->pClass->getTextSelection(pDocument, nullptr, &pMimeType);
+        std::vector<long> aExpected = {1, 2, 3, 4, 5};
+        std::istringstream aContent(pContent);
+        std::string token;
+        for (size_t i = 0; i < aExpected.size(); i++)
+        {
+            aContent >> token;
+            CPPUNIT_ASSERT_EQUAL(aExpected[i], strtol(token.c_str(), nullptr, 10));
+        }
+
+        free(pMimeType);
+        free(pContent);
+    }
+}
+
 namespace {
 
     void verifyContextMenuStructure(boost::property_tree::ptree& aRoot)


More information about the Libreoffice-commits mailing list