diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-02-06 19:08:15 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-02-07 12:15:45 +0000 |
commit | fba2d6a1026020164c80d65037ec3aae33a3f774 (patch) | |
tree | 480da4821b3dc982c7ebc126b02698b55acd7f6f | |
parent | 621d4b0afc34646cec59b53e192be47eefe6062d (diff) |
sc: use try/finally to reset the changes in OptionsTreeDialog
Otherwise it might affect other tests if it hits an assert
Change-Id: I49c2b854d19a83ac32f78be32a77ad6e771b73ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146593
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sc/qa/uitest/search_replace/tdf39917.py | 118 |
1 files changed, 54 insertions, 64 deletions
diff --git a/sc/qa/uitest/search_replace/tdf39917.py b/sc/qa/uitest/search_replace/tdf39917.py index 52451a4934c1..3a0b06467445 100644 --- a/sc/qa/uitest/search_replace/tdf39917.py +++ b/sc/qa/uitest/search_replace/tdf39917.py @@ -13,78 +13,68 @@ from uitest.uihelper.common import select_by_text from libreoffice.calc.document import get_cell_by_position from libreoffice.uno.propertyvalue import mkPropertyValues - # Bug 39917 - EDITING Find/Replace modifies formula in R1C1 syntax to invalid lowercase class tdf39917(UITestCase): - def test_tdf39917_find_replace_R1C1(self): - 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 + def change_formula_syntax(self, syntax): + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: - formulasyntax = xDialogOpt.getChild("formulasyntax") - #Excel R1C1 - select_by_text(formulasyntax, "Excel R1C1") + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcFormulaEntry = xCalcEntry.getChild('4') + xCalcFormulaEntry.executeAction("SELECT", tuple()) + xFormulaSyntax = xDialogOpt.getChild('formulasyntax') + select_by_text(xFormulaSyntax, syntax) - #1. Create a workbook with 3 sheets: Page1, Page2, Page3. - # 2. Tools -> Options -> LibreOffice Calc -> Formula: Set syntax to Excel A1 - # 5. Fill fields: - - with self.ui_test.execute_dialog_through_command(".uno:Insert") as xDialog: - after = xDialog.getChild("after") - after.executeAction("CLICK", tuple()) - nameed = xDialog.getChild("nameed") - nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - nameed.executeAction("TYPE", mkPropertyValues({"TEXT":"Page2"})) - with self.ui_test.execute_dialog_through_command(".uno:Insert") as xDialog: - after = xDialog.getChild("after") - after.executeAction("CLICK", tuple()) - nameed = xDialog.getChild("nameed") - nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - nameed.executeAction("TYPE", mkPropertyValues({"TEXT":"Page3"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"})) - # 3. Type in (for example) B4: =Page2!B4 - enter_text_to_cell(gridwin, "B4", "=Page2!RC") - # 4. Edit -> Find and Replace - # Find: Page2 - # Replace: Page3 - # 6. Press Replace all - with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: - searchterm = xDialog.getChild("searchterm") - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Page2"})) - replaceterm = xDialog.getChild("replaceterm") - replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Page3"})) #replace textbox - replace = xDialog.getChild("replace") - replace.executeAction("CLICK", tuple()) - replace.executeAction("CLICK", tuple()) + def test_tdf39917_find_replace_R1C1(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - #verify - enter_text_to_cell(gridwin, "A1", "=FORMULA(R[3]C[1])") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "=Page3!RC") - #Give it back Tools --> Options --> Calc --> Formula --> Syntax = Calc A1 - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: + try: + self.change_formula_syntax("Excel R1C1") - xPages = xDialogOpt.getChild("pages") - xCalcEntry = xPages.getChild('3') # Calc - xCalcEntry.executeAction("EXPAND", tuple()) - xCalcFormulaEntry = xCalcEntry.getChild('4') - xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula + #1. Create a workbook with 3 sheets: Page1, Page2, Page3. + # 2. Tools -> Options -> LibreOffice Calc -> Formula: Set syntax to Excel A1 + # 5. Fill fields: - formulasyntax = xDialogOpt.getChild("formulasyntax") - #Excel R1C1 - select_by_text(formulasyntax, "Calc A1") + with self.ui_test.execute_dialog_through_command(".uno:Insert") as xDialog: + after = xDialog.getChild("after") + after.executeAction("CLICK", tuple()) + nameed = xDialog.getChild("nameed") + nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + nameed.executeAction("TYPE", mkPropertyValues({"TEXT":"Page2"})) + with self.ui_test.execute_dialog_through_command(".uno:Insert") as xDialog: + after = xDialog.getChild("after") + after.executeAction("CLICK", tuple()) + nameed = xDialog.getChild("nameed") + nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + nameed.executeAction("TYPE", mkPropertyValues({"TEXT":"Page3"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"})) + # 3. Type in (for example) B4: =Page2!B4 + enter_text_to_cell(gridwin, "B4", "=Page2!RC") + # 4. Edit -> Find and Replace + # Find: Page2 + # Replace: Page3 + # 6. Press Replace all + with self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog", close_button="close") as xDialog: + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Page2"})) + replaceterm = xDialog.getChild("replaceterm") + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Page3"})) #replace textbox + replace = xDialog.getChild("replace") + replace.executeAction("CLICK", tuple()) + replace.executeAction("CLICK", tuple()) + #verify + enter_text_to_cell(gridwin, "A1", "=FORMULA(R[3]C[1])") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "=Page3!RC") + finally: + self.change_formula_syntax("Calc A1") # vim: set shiftwidth=4 softtabstop=4 expandtab: |