sc/qa/uitest/calc_tests7/tdf123052.py |   68 ----------------------------------
 sc/qa/unit/uicalc/uicalc.cxx          |   33 ++++++++++++++++
 2 files changed, 33 insertions(+), 68 deletions(-)

New commits:
commit 662055db385cd1f17ae1a375b2da3b3246e02517
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Feb 9 20:16:26 2021 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Feb 9 22:43:03 2021 +0100

    tdf#123052: sc: Move UItest to CppUnitTest
    
    Change-Id: If7a30aef44a722b4c0d91ecd7626a2a39fe1290a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110652
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/uitest/calc_tests7/tdf123052.py 
b/sc/qa/uitest/calc_tests7/tdf123052.py
deleted file mode 100644
index 7d1b8eaa076b..000000000000
--- a/sc/qa/uitest/calc_tests7/tdf123052.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-from uitest.framework import UITestCase
-from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
-from uitest.uihelper.common import select_pos
-from uitest.uihelper.calc import enter_text_to_cell
-from libreoffice.calc.document import get_cell_by_position
-from libreoffice.uno.propertyvalue import mkPropertyValues
-
-#Bug 123052 - [regression] Shift+Tab not working
-
-class tdf123052(UITestCase):
-    def test_tdf123052_shit_tab(self):
-        calc_doc = 
self.ui_test.load_file(get_url_for_data_file("tdf123052.ods"))
-        xCalcDoc = self.xUITest.getTopFocusWindow()
-        gridwin = xCalcDoc.getChild("grid_window")
-        document = self.ui_test.get_component()
-        #Holding the Shift key and repeated pressing the Tab key does not 
correctly cycle though the unprotected cells
-        #I'm at 7, hold TAB for cycling
-        gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
-        # Assert that the correct cell has been selected
-        gridWinState = get_state_as_dict(gridwin)
-        self.assertEqual(gridWinState["CurrentRow"], "2")
-        self.assertEqual(gridWinState["CurrentColumn"], "5")
-
-        gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
-        # Assert that the correct cell has been selected
-        gridWinState = get_state_as_dict(gridwin)
-        self.assertEqual(gridWinState["CurrentRow"], "4")
-        self.assertEqual(gridWinState["CurrentColumn"], "3")
-
-        gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
-        # Assert that the correct cell has been selected
-        gridWinState = get_state_as_dict(gridwin)
-        self.assertEqual(gridWinState["CurrentRow"], "4")
-        self.assertEqual(gridWinState["CurrentColumn"], "4")
-
-        gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
-        # Assert that the correct cell has been selected
-        gridWinState = get_state_as_dict(gridwin)
-        self.assertEqual(gridWinState["CurrentRow"], "5")
-        self.assertEqual(gridWinState["CurrentColumn"], "5")
-
-        gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
-        # Assert that the correct cell has been selected
-        gridWinState = get_state_as_dict(gridwin)
-        self.assertEqual(gridWinState["CurrentRow"], "7")
-        self.assertEqual(gridWinState["CurrentColumn"], "0")
-
-        gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
-        # Assert that the correct cell has been selected
-        gridWinState = get_state_as_dict(gridwin)
-        self.assertEqual(gridWinState["CurrentRow"], "8")
-        self.assertEqual(gridWinState["CurrentColumn"], "4")
-        #now shift + tab
-        gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": 
"SHIFT+TAB"}))
-        # Assert that the correct cell has been selected
-        gridWinState = get_state_as_dict(gridwin)
-        self.assertEqual(gridWinState["CurrentRow"], "7")
-        self.assertEqual(gridWinState["CurrentColumn"], "0")
-
-        self.ui_test.close_doc()
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/tdf123052.ods 
b/sc/qa/unit/uicalc/data/tdf123052.ods
similarity index 100%
rename from sc/qa/uitest/data/tdf123052.ods
rename to sc/qa/unit/uicalc/data/tdf123052.ods
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 8c92824fe541..7335fa01dc22 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -337,6 +337,39 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf122232)
     lcl_AssertCurrentCursorPosition(2, 6);
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf123052)
+{
+    ScModelObj* pModelObj = createDoc("tdf123052.ods");
+    ScDocument* pDoc = pModelObj->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+
+    std::vector<ScAddress> aExpectedAddresses{ ScAddress(5, 2, 0), 
ScAddress(3, 4, 0),
+                                               ScAddress(4, 4, 0), 
ScAddress(5, 5, 0),
+                                               ScAddress(0, 7, 0), 
ScAddress(4, 8, 0) };
+
+    for (const auto& rAddress : aExpectedAddresses)
+    {
+        pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB);
+        pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB);
+        Scheduler::ProcessEventsToIdle();
+
+        lcl_AssertCurrentCursorPosition(rAddress.Col(), rAddress.Row());
+    }
+
+    aExpectedAddresses.pop_back();
+
+    for (std::vector<ScAddress>::reverse_iterator it = 
aExpectedAddresses.rbegin();
+         it != aExpectedAddresses.rend(); ++it)
+    {
+        pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_SHIFT | 
awt::Key::TAB);
+        pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_SHIFT | 
awt::Key::TAB);
+        Scheduler::ProcessEventsToIdle();
+
+        // Without the fix in place, this test would have failed here
+        lcl_AssertCurrentCursorPosition((*it).Col(), (*it).Row());
+    }
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf120660)
 {
     ScModelObj* pModelObj = createDoc("tdf120660.ods");
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to