summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-06-05 13:03:04 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-06-05 15:32:37 +0200
commitb0d49beb1b9b875e82c98439587fcf37b56050b4 (patch)
tree71399d1529374a5ce26ede44ec7fee0d6166632e /sc
parent8149e903db501511193761eebca1640407ad52dc (diff)
tdf#132026: sc: move UItest to CppUnittest
Change-Id: I4a8b40c1618421a0c1775d0585c53d90196f0937 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152608 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/uitest/calc_tests8/tdf132026.py44
-rw-r--r--sc/qa/unit/uicalc/data/tdf132026.ods (renamed from sc/qa/uitest/data/tdf132026.ods)bin10130 -> 10130 bytes
-rw-r--r--sc/qa/unit/uicalc/uicalc.cxx48
3 files changed, 48 insertions, 44 deletions
diff --git a/sc/qa/uitest/calc_tests8/tdf132026.py b/sc/qa/uitest/calc_tests8/tdf132026.py
deleted file mode 100644
index abd3a86e720b..000000000000
--- a/sc/qa/uitest/calc_tests8/tdf132026.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
-#
-# This file is part of the LibreOffice project.
-#
-# 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_url_for_data_file
-from libreoffice.calc.document import get_cell_by_position
-from libreoffice.uno.propertyvalue import mkPropertyValues
-
-class tdf132026(UITestCase):
-
- def test_tdf132026(self):
- with self.ui_test.load_file(get_url_for_data_file("tdf132026.ods")) as calc_doc:
- MainWindow = self.xUITest.getTopFocusWindow()
- grid_window = MainWindow.getChild("grid_window")
-
- chars=["=","+","-"]
- directions=["UP","DOWN","LEFT","RIGHT"]
-
- # format general, should select cell
- for c in chars:
- sign=-1 if c=="-" else 1
- for i,direction in enumerate(directions):
- grid_window.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
- grid_window.executeAction("TYPE", mkPropertyValues({"TEXT": c}))
- grid_window.executeAction("TYPE", mkPropertyValues({"KEYCODE": direction}))
- grid_window.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
- self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 1).getString(), str(sign*(i+1)))
-
- # format text, shouldn't select cell
- for c in chars:
- for direction in directions:
- grid_window.executeAction("SELECT", mkPropertyValues({"CELL": "E2"}))
- grid_window.executeAction("TYPE", mkPropertyValues({"TEXT": c}))
- grid_window.executeAction("TYPE", mkPropertyValues({"KEYCODE": direction}))
- grid_window.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
- self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 1).getString(), c)
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/tdf132026.ods b/sc/qa/unit/uicalc/data/tdf132026.ods
index 03c6c654fdc5..03c6c654fdc5 100644
--- a/sc/qa/uitest/data/tdf132026.ods
+++ b/sc/qa/unit/uicalc/data/tdf132026.ods
Binary files differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 820f44ad4604..89bdeeb1fa6d 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -715,6 +715,54 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf124820)
aFont.GetStrikeout());
}
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf132026)
+{
+ createScDoc("tdf132026.ods");
+ ScDocument* pDoc = getScDoc();
+ std::vector<std::u16string_view> aChars{ u"=", u"+", u"-" };
+ std::vector<sal_uInt16> aDirections{ KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT };
+
+ ScModelObj* pModelObj = comphelper::getFromUnoTunnel<ScModelObj>(mxComponent);
+ for (auto aChar = aChars.begin(); aChar != aChars.end(); ++aChar)
+ {
+ for (size_t i = 0; i < aDirections.size(); ++i)
+ {
+ goToCell("B2");
+ typeString(*aChar);
+
+ sal_uInt16 nDir = aDirections[i];
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, nDir);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, nDir);
+ Scheduler::ProcessEventsToIdle();
+
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+ Scheduler::ProcessEventsToIdle();
+
+ sal_Int16 nSign = (*aChar == u"-") ? -1 : 1;
+ sal_Int16 nExpected = nSign * (i + 1);
+ OUString sExpectedResult = OUString::number(nExpected);
+ CPPUNIT_ASSERT_EQUAL(sExpectedResult, pDoc->GetString(ScAddress(1, 1, 0)));
+
+ goToCell("E2");
+ typeString(*aChar);
+
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, nDir);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, nDir);
+ Scheduler::ProcessEventsToIdle();
+
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+ Scheduler::ProcessEventsToIdle();
+
+ // Without the fix in place, this test would have failed with
+ // - Expected: =
+ // - Actual : =E1
+ CPPUNIT_ASSERT_EQUAL(OUString(*aChar), pDoc->GetString(ScAddress(4, 1, 0)));
+ }
+ }
+}
+
CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf152037)
{
createScDoc("tdf152037.xlsx");