From b0d49beb1b9b875e82c98439587fcf37b56050b4 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Mon, 5 Jun 2023 13:03:04 +0200 Subject: 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 --- sc/qa/uitest/calc_tests8/tdf132026.py | 44 ------------------------------- sc/qa/uitest/data/tdf132026.ods | Bin 10130 -> 0 bytes sc/qa/unit/uicalc/data/tdf132026.ods | Bin 0 -> 10130 bytes sc/qa/unit/uicalc/uicalc.cxx | 48 ++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 44 deletions(-) delete mode 100644 sc/qa/uitest/calc_tests8/tdf132026.py delete mode 100644 sc/qa/uitest/data/tdf132026.ods create mode 100644 sc/qa/unit/uicalc/data/tdf132026.ods (limited to 'sc') 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/uitest/data/tdf132026.ods deleted file mode 100644 index 03c6c654fdc5..000000000000 Binary files a/sc/qa/uitest/data/tdf132026.ods and /dev/null differ diff --git a/sc/qa/unit/uicalc/data/tdf132026.ods b/sc/qa/unit/uicalc/data/tdf132026.ods new file mode 100644 index 000000000000..03c6c654fdc5 Binary files /dev/null and b/sc/qa/unit/uicalc/data/tdf132026.ods 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 aChars{ u"=", u"+", u"-" }; + std::vector aDirections{ KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT }; + + ScModelObj* pModelObj = comphelper::getFromUnoTunnel(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"); -- cgit