From bd8edf5d2ac579e51bfbf5fa6061909a67a309c7 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Mon, 2 Nov 2020 20:08:49 +0100 Subject: tdf#137896: sc: Add UItest Change-Id: I38d2d31f28bfbabc8003a11520ad26e3df2a29a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105199 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sc/qa/uitest/calc_dialogs/openDialogs.py | 3 +- sc/qa/uitest/range_name/create_range_name.py | 54 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) (limited to 'sc') diff --git a/sc/qa/uitest/calc_dialogs/openDialogs.py b/sc/qa/uitest/calc_dialogs/openDialogs.py index 79759b953328..4a76fae293e0 100644 --- a/sc/qa/uitest/calc_dialogs/openDialogs.py +++ b/sc/qa/uitest/calc_dialogs/openDialogs.py @@ -31,7 +31,8 @@ dialogs = [ # {"command": ".uno:FunctionDialog", "closeButton": "cancel"}, # Cancel button tested in uitest/calc_tests/function_wizard.py # OK button tested in sc/qa/uitest/calc_tests7/tdf123479.py - {"command": ".uno:InsertName", "closeButton": "close"}, + # {"command": ".uno:InsertName", "closeButton": "close"}, + # tested in sc/qa/uitest/range_name/create_range_name.py {"command": ".uno:InsertObjectFloatingFrame", "closeButton": "cancel"}, {"command": ".uno:FontworkGalleryFloater", "closeButton": "cancel"}, # {"command": ".uno:HyperlinkDialog", "closeButton": "ok"}, diff --git a/sc/qa/uitest/range_name/create_range_name.py b/sc/qa/uitest/range_name/create_range_name.py index b1b60c1cd83e..1c59d879272b 100644 --- a/sc/qa/uitest/range_name/create_range_name.py +++ b/sc/qa/uitest/range_name/create_range_name.py @@ -93,6 +93,60 @@ class CreateRangeNameTest(UITestCase): # AssertionError: 'localRangeName' != 'A1' self.assertEqual('localRangeName', get_state_as_dict(xPosWindow)['Text']) + gridwin = calcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "1") + + # Use the name range in the current sheet + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + + self.ui_test.execute_dialog_through_command(".uno:InsertName") + xDialog = self.xUITest.getTopFocusWindow() + + xCtrl = xDialog.getChild('ctrl') + self.assertEqual(1, len(xCtrl.getChildren())) + self.assertEqual("localRangeName\t$Sheet1.$A$1\tSheet1", get_state_as_dict(xCtrl.getChild('0'))['Text']) + xCtrl.getChild('0').executeAction("SELECT", tuple()) + + xPasteBtn = xDialog.getChild("paste") + self.ui_test.close_dialog_through_button(xPasteBtn) + + # use return key to paste the name range + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + + document = self.ui_test.get_component() + self.assertEqual("1", get_cell_by_position(document, 0, 1, 0).getString()) + self.assertEqual("=localRangeName", get_cell_by_position(document, 0, 1, 0).getFormula()) + + # Insert a new sheet + self.ui_test.execute_dialog_through_command(".uno:Insert") + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("ok") + xOKButton.executeAction("CLICK", tuple()) + + # Use the name range in the new sheet + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + + self.ui_test.execute_dialog_through_command(".uno:InsertName") + xDialog = self.xUITest.getTopFocusWindow() + + xCtrl = xDialog.getChild('ctrl') + self.assertEqual(1, len(xCtrl.getChildren())) + self.assertEqual("localRangeName\t$Sheet1.$A$1\tSheet1", get_state_as_dict(xCtrl.getChild('0'))['Text']) + xCtrl.getChild('0').executeAction("SELECT", tuple()) + + xPasteBtn = xDialog.getChild("paste") + self.ui_test.close_dialog_through_button(xPasteBtn) + + # use return key to paste the name range + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + + # tdf#137896: Without the fix in place, this test would have failed with + # AssertionError: '1' != '#NAME?' + self.assertEqual("1", get_cell_by_position(document, 0, 1, 0).getString()) + + # and AssertionError: '=Sheet1.localRangeName' != '=localrangename' + self.assertEqual("=Sheet1.localRangeName", get_cell_by_position(document, 0, 1, 0).getFormula()) + self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: -- cgit