summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-01-13 16:59:56 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2023-01-13 17:41:47 +0000
commitd4d046bb9c5d17cdd432b362c38914cc7b0a75f1 (patch)
tree2068e176e0a771187bf4efd8e776638f374dc626 /sc
parenta5e092b53f91d314fd79b48ceaca88030865ac3b (diff)
tdf#39650: move UItest to CppUnittest
Change-Id: I2ff89c53309d7e3a4da11d652aafeb38cbc41205 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145480 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/uitest/key_f4/f4.py48
-rw-r--r--sc/qa/unit/helper/qahelper.hxx2
-rw-r--r--sc/qa/unit/uicalc/uicalc.cxx28
3 files changed, 25 insertions, 53 deletions
diff --git a/sc/qa/uitest/key_f4/f4.py b/sc/qa/uitest/key_f4/f4.py
index 79d1cc26863d..e5daa47a4420 100644
--- a/sc/qa/uitest/key_f4/f4.py
+++ b/sc/qa/uitest/key_f4/f4.py
@@ -75,52 +75,4 @@ class keyF4(UITestCase):
self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3)
self.assertEqual(get_cell_by_position(document, 0, 2, 2).getFormula(), "=$A3")
-
- def test_tdf39650_F4_R1C1(self):
- #Bug 39650 - Shift+F4 conversion from relative to absolute does not work for R1C1 syntax
- with self.ui_test.create_doc_in_start_center("calc") as document:
- xCalcDoc = self.xUITest.getTopFocusWindow()
- gridwin = xCalcDoc.getChild("grid_window")
- #* Tools --> Options --> Calc --> Formula --> Syntax = Excel R1C1
- with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt:
-
- xPages = xDialogOpt.getChild("pages")
- xCalcEntry = xPages.getChild('3') # Calc
- xCalcEntry.executeAction("EXPAND", tuple())
- xCalcFormulaEntry = xCalcEntry.getChild('4')
- xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula
-
- formulasyntax = xDialogOpt.getChild("formulasyntax")
- #Excel R1C1
- select_by_text(formulasyntax, "Excel R1C1")
-
-
- #In cell R3C3 enter "xxx".
- enter_text_to_cell(gridwin, "C3", "xxx")
- # In cell R2C2 type = and then click on the xxx in R3C3.
- enter_text_to_cell(gridwin, "B2", "=R[1]C[1]")
- # With cell R2C2 still selected, type Shift-F4.
- gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
-
- #F4
- gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"}))
-
- #This should change the formula in R2C2 from =R[1]C[1] to =R3C3.
- self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "xxx")
- enter_text_to_cell(gridwin, "A1", "=FORMULA(R[1]C[1])")
- self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "=R3C3")
-
- #Give it back Tools --> Options --> Calc --> Formula --> Syntax = Calc A1
- with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt:
-
- xPages = xDialogOpt.getChild("pages")
- xCalcEntry = xPages.getChild('3') # Calc
- xCalcEntry.executeAction("EXPAND", tuple())
- xCalcFormulaEntry = xCalcEntry.getChild('4')
- xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula
-
- formulasyntax = xDialogOpt.getChild("formulasyntax")
- #Excel R1C1
- select_by_text(formulasyntax, "Calc A1")
-
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index 128bcad258ad..67d58897ef2a 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -92,7 +92,7 @@ inline std::string print(const ScAddress& rAddr)
/**
* Temporarily set formula grammar.
*/
-class FormulaGrammarSwitch
+class SCQAHELPER_DLLPUBLIC FormulaGrammarSwitch
{
ScDocument* mpDoc;
formula::FormulaGrammar::Grammar meOldGrammar;
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 73ddf9a64fe9..ad4212170dd4 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -328,7 +328,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf113541)
pDoc = getScDoc();
// Change grammar to Excel A1
- pDoc->SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH_XL_A1);
+ FormulaGrammarSwitch aFGSwitch(pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_A1);
// Insert the reference to the external document
OUString aFormula = "=['" + maTempFile.GetURL() + "']Sheet1!A1";
@@ -338,9 +338,6 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf113541)
// - Expected: 50
// - Actual : Err:507
CPPUNIT_ASSERT_EQUAL(OUString("50"), pDoc->GetString(ScAddress(0, 0, 0)));
-
- // Change grammar to default
- pDoc->SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH);
}
CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf126577)
@@ -1377,6 +1374,29 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf102525)
CPPUNIT_ASSERT_EQUAL(OUString("{=IF(A1:A4>2,1,2)}"), pDoc->GetFormula(1, 0, 0));
}
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf39650)
+{
+ createScDoc();
+ ScDocument* pDoc = getScDoc();
+
+ FormulaGrammarSwitch aFGSwitch(pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
+
+ insertStringToCell("R3C3", u"xxx");
+ insertStringToCell("R2C2", u"=R[1]C[1]");
+
+ CPPUNIT_ASSERT_EQUAL(OUString("=R[1]C[1]"), pDoc->GetFormula(1, 1, 0));
+ CPPUNIT_ASSERT_EQUAL(OUString("xxx"), pDoc->GetString(1, 1, 0));
+
+ goToCell("B2");
+
+ ScModelObj* pModelObj = comphelper::getFromUnoTunnel<ScModelObj>(mxComponent);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_F4);
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(OUString("=R3C3"), pDoc->GetFormula(1, 1, 0));
+ CPPUNIT_ASSERT_EQUAL(OUString("xxx"), pDoc->GetString(1, 1, 0));
+}
+
CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf45020)
{
createScDoc();