tdf#102525: move UItest to CppUnittest
Change-Id: If7881b49cc006157e177559308048a0f2d2c10b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145473
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/uitest/data/tdf102525.ods b/sc/qa/uitest/data/tdf102525.ods
deleted file mode 100644
index 533d2d2..0000000
--- a/sc/qa/uitest/data/tdf102525.ods
+++ /dev/null
Binary files differ
diff --git a/sc/qa/uitest/key_f4/tdf102525.py b/sc/qa/uitest/key_f4/tdf102525.py
deleted file mode 100644
index 24e8b08..0000000
--- a/sc/qa/uitest/key_f4/tdf102525.py
+++ /dev/null
@@ -1,39 +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.uno.propertyvalue import mkPropertyValues
from libreoffice.calc.document import get_cell_by_position
# Bug 102525 - F4 breaks array formula
class tdf102525(UITestCase):
def test_tdf102525_F4_key_array_formula(self):
with self.ui_test.load_file(get_url_for_data_file("tdf102525.ods")) as calc_doc:
xCalcDoc = self.xUITest.getTopFocusWindow()
gridwin = xCalcDoc.getChild("grid_window")
#select B1:B4
gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B4"}))
#F4
gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"}))
#verify
self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 0).getValue(), 2)
self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 0).getFormula(), "{=IF($A$1:$A$4>2;1;2)}")
self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 1).getValue(), 2)
self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 2).getValue(), 1)
self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 3).getValue(), 1)
#Undo
self.xUITest.executeCommand(".uno:Undo")
#verify
self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 0).getValue(), 2)
self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 0).getFormula(), "{=IF(A1:A4>2;1;2)}")
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index b3cb2a6..73ddf9a 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1342,6 +1342,41 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf95306)
CPPUNIT_ASSERT(!pDoc->ColHidden(4, 0));
}
CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf102525)
{
createScDoc();
ScDocument* pDoc = getScDoc();
insertStringToCell("A1", u"1");
insertStringToCell("A2", u"2");
insertStringToCell("A3", u"3");
insertStringToCell("A4", u"4");
insertArrayToCell("B1", u"=IF(A1:A4>2,1,2)");
goToCell("B1:B4");
ScModelObj* pModelObj = comphelper::getFromUnoTunnel<ScModelObj>(mxComponent);
pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_F4);
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(2.0, pDoc->GetValue(1, 0, 0));
CPPUNIT_ASSERT_EQUAL(2.0, pDoc->GetValue(1, 1, 0));
CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(1, 2, 0));
CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(1, 3, 0));
CPPUNIT_ASSERT_EQUAL(OUString("{=IF($A$1:$A$4>2,1,2)}"), pDoc->GetFormula(1, 0, 0));
dispatchCommand(mxComponent, ".uno:Undo", {});
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(2.0, pDoc->GetValue(1, 0, 0));
CPPUNIT_ASSERT_EQUAL(2.0, pDoc->GetValue(1, 1, 0));
CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(1, 2, 0));
CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(1, 3, 0));
CPPUNIT_ASSERT_EQUAL(OUString("{=IF(A1:A4>2,1,2)}"), pDoc->GetFormula(1, 0, 0));
}
CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf45020)
{
createScDoc();