sc/qa/uitest/conditional_format/tdf104026.py | 45 --------------------------- sc/qa/unit/uicalc/data/tdf104026.ods |binary sc/qa/unit/uicalc/uicalc.cxx | 38 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 45 deletions(-)
New commits: commit 30eb9b1941a801ccf18d450e307cbb8b91565fb3 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Jan 16 12:16:16 2024 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Jan 16 21:24:44 2024 +0100 tdf#104026: sc: move UItest to CppUnittest I just realized there was already a test for tdf#104026 added in ad9336f29650dc38be06d771f5c3dbc7f0078ff1 "add tests for tdf#104026" so I don't know why I added a UItest in a7c41f93421ddb2b48e38960b669c4e4f5413efb "tdf#104026: sc: Add UItest" Anyway, I plan to extend this test for tdf#140330, so moving it to CppUnittest Change-Id: I6c4de9298877cc1c51377b099a6a4a53cf54c05b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162168 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/uitest/conditional_format/tdf104026.py b/sc/qa/uitest/conditional_format/tdf104026.py deleted file mode 100644 index 2d8c5fc66c5f..000000000000 --- a/sc/qa/uitest/conditional_format/tdf104026.py +++ /dev/null @@ -1,45 +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 libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file - -class Tdf104026(UITestCase): - - def execute_conditional_format_manager_dialog(self, nCount): - - with self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") as xCondFormatMgr: - - aExpectedResults = ['A2 Cell value != $Sheet1.$B2', 'A3 Cell value != $Sheet1.$B3', - 'A4 Cell value != $Sheet1.$B4', 'A5 Cell value != $Sheet1.$B5', - 'A6 Cell value != $Sheet1.$B6', 'A7 Cell value != $Sheet1.$B7'] - - xList = xCondFormatMgr.getChild("CONTAINER") - self.assertEqual(nCount, len(xList.getChildren())) - - for i in range(nCount): - self.assertEqual(aExpectedResults[i], get_state_as_dict(xList.getChild(str(i)))['Text']) - - - def test_tdf104026(self): - with self.ui_test.load_file(get_url_for_data_file("tdf104026.ods")): - - self.execute_conditional_format_manager_dialog(6) - - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) - - self.xUITest.executeCommand(".uno:DeleteRows") - - # Without the fix in place, this test would have failed with - # AssertionError: 'A2 Cell value != $Sheet1.$B2' != 'A2 Cell value != $Sheet1.$B#REF!' - self.execute_conditional_format_manager_dialog(5) - -# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/unit/uicalc/data/tdf104026.ods b/sc/qa/unit/uicalc/data/tdf104026.ods new file mode 100644 index 000000000000..3d6611fb753c Binary files /dev/null and b/sc/qa/unit/uicalc/data/tdf104026.ods differ diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 53f4a7e2b2b5..16c751fdefce 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -19,6 +19,7 @@ #include <comphelper/servicehelper.hxx> #include <com/sun/star/awt/Key.hpp> #include <com/sun/star/sheet/GlobalSheetSettings.hpp> +#include <condformathelper.hxx> #include <conditio.hxx> #include <document.hxx> #include <docsh.hxx> @@ -44,6 +45,22 @@ ScUiCalcTest::ScUiCalcTest() { } +static void lcl_AssertConditionalFormatList(ScDocument& rDoc, size_t nSize, + std::unordered_map<OUString, OUString>& rExpectedValues) +{ + ScConditionalFormatList* pList = rDoc.GetCondFormList(0); + CPPUNIT_ASSERT_EQUAL(nSize, pList->size()); + + OUString sRangeStr; + for (const auto& rItem : *pList) + { + const ScRangeList& aRange = rItem->GetRange(); + aRange.Format(sRangeStr, ScRefFlags::VALID, rDoc, rDoc.GetAddressConvention()); + CPPUNIT_ASSERT_EQUAL(rExpectedValues[sRangeStr], + ScCondFormatHelper::GetExpression(*rItem, aRange.GetTopLeftCorner())); + } +} + static void lcl_AssertCurrentCursorPosition(ScDocShell& rDocSh, std::u16string_view rStr) { ScAddress aAddr; @@ -1193,6 +1210,27 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf97215) pMod->SetInputOptions(aInputOption); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf104026) +{ + createScDoc("tdf104026.ods"); + ScDocument* pDoc = getScDoc(); + + std::unordered_map<OUString, OUString> aExpectedValues + = { { "A2", "Cell value != $Sheet1.$B2" }, { "A3", "Cell value != $Sheet1.$B3" }, + { "A4", "Cell value != $Sheet1.$B4" }, { "A5", "Cell value != $Sheet1.$B5" }, + { "A6", "Cell value != $Sheet1.$B6" }, { "A7", "Cell value != $Sheet1.$B7" } }; + + lcl_AssertConditionalFormatList(*pDoc, 6, aExpectedValues); + + goToCell("A2"); + dispatchCommand(mxComponent, ".uno:DeleteRows", {}); + + // Without the fix in place, this test would have failed with + // - Expected: Cell value != $Sheet1.$B2 + // - Actual : Cell value != $Sheet1.$B#REF! + lcl_AssertConditionalFormatList(*pDoc, 5, aExpectedValues); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf92963) { createScDoc("tdf92963.ods");