diff options
Diffstat (limited to 'sc/qa/uitest/calc_tests2/consolidate.py')
-rw-r--r-- | sc/qa/uitest/calc_tests2/consolidate.py | 91 |
1 files changed, 42 insertions, 49 deletions
diff --git a/sc/qa/uitest/calc_tests2/consolidate.py b/sc/qa/uitest/calc_tests2/consolidate.py index 83ed3587dad1..91bc581250ae 100644 --- a/sc/qa/uitest/calc_tests2/consolidate.py +++ b/sc/qa/uitest/calc_tests2/consolidate.py @@ -16,32 +16,30 @@ class consolidate(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") - self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") - xDialog = self.xUITest.getTopFocusWindow() - xfunc = xDialog.getChild("func") - xlbdataarea = xDialog.getChild("lbdataarea") - xadd = xDialog.getChild("add") - xbyrow = xDialog.getChild("byrow") - xbycol = xDialog.getChild("bycol") - xeddestarea = xDialog.getChild("eddestarea") + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataConsolidate") as xDialog: + xfunc = xDialog.getChild("func") + xlbdataarea = xDialog.getChild("lbdataarea") + xadd = xDialog.getChild("add") + xbyrow = xDialog.getChild("byrow") + xbycol = xDialog.getChild("bycol") + xeddestarea = xDialog.getChild("eddestarea") - select_by_text(xfunc, "Sum") + select_by_text(xfunc, "Sum") + + select_by_text(xlbdataarea, "range1") + xadd.executeAction("CLICK", tuple()) + select_by_text(xlbdataarea, "range2") + xadd.executeAction("CLICK", tuple()) + propsC = {"TEXT": "range3"} + actionPropsC = mkPropertyValues(propsC) + xlbdataarea.executeAction("SELECT", actionPropsC) + xadd.executeAction("CLICK", tuple()) + xbyrow.executeAction("CLICK", tuple()) + xbycol.executeAction("CLICK", tuple()) + xeddestarea.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xeddestarea.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xeddestarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Total.$A$2"})) - select_by_text(xlbdataarea, "range1") - xadd.executeAction("CLICK", tuple()) - select_by_text(xlbdataarea, "range2") - xadd.executeAction("CLICK", tuple()) - propsC = {"TEXT": "range3"} - actionPropsC = mkPropertyValues(propsC) - xlbdataarea.executeAction("SELECT", actionPropsC) - xadd.executeAction("CLICK", tuple()) - xbyrow.executeAction("CLICK", tuple()) - xbycol.executeAction("CLICK", tuple()) - xeddestarea.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xeddestarea.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xeddestarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Total.$A$2"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #verify self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 2).getValue(), 300) self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 3).getValue(), 303) @@ -63,27 +61,24 @@ class consolidate(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 4).getValue(), 315) self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 5).getValue(), 318) #verify dialog - self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") - xDialog = self.xUITest.getTopFocusWindow() - xfunc = xDialog.getChild("func") - xlbdataarea = xDialog.getChild("lbdataarea") - xdelete = xDialog.getChild("delete") - xbyrow = xDialog.getChild("byrow") - xbycol = xDialog.getChild("bycol") - xeddestarea = xDialog.getChild("eddestarea") - xconsareas = xDialog.getChild("consareas") - self.assertEqual(get_state_as_dict(xfunc)["SelectEntryText"], "Sum") - self.assertEqual(get_state_as_dict(xconsareas)["Children"], "3") - self.assertEqual(get_state_as_dict(xeddestarea)["Text"], "$Total.$A$2") - self.assertEqual(get_state_as_dict(xbyrow)["Selected"], "true") - self.assertEqual(get_state_as_dict(xbycol)["Selected"], "true") - #delete first range - xFirstEntry = xconsareas.getChild("0") - xFirstEntry.executeAction("SELECT", tuple()) - xdelete.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xconsareas)["Children"], "2") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataConsolidate") as xDialog: + xfunc = xDialog.getChild("func") + xlbdataarea = xDialog.getChild("lbdataarea") + xdelete = xDialog.getChild("delete") + xbyrow = xDialog.getChild("byrow") + xbycol = xDialog.getChild("bycol") + xeddestarea = xDialog.getChild("eddestarea") + xconsareas = xDialog.getChild("consareas") + self.assertEqual(get_state_as_dict(xfunc)["SelectEntryText"], "Sum") + self.assertEqual(get_state_as_dict(xconsareas)["Children"], "3") + self.assertEqual(get_state_as_dict(xeddestarea)["Text"], "$Total.$A$2") + self.assertEqual(get_state_as_dict(xbyrow)["Selected"], "true") + self.assertEqual(get_state_as_dict(xbycol)["Selected"], "true") + #delete first range + xFirstEntry = xconsareas.getChild("0") + xFirstEntry.executeAction("SELECT", tuple()) + xdelete.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xconsareas)["Children"], "2") self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 2).getValue(), 200) self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 3).getValue(), 202) @@ -106,9 +101,7 @@ class consolidate(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 5).getValue(), 212) # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataConsolidate", close_button="cancel"): + pass # vim: set shiftwidth=4 softtabstop=4 expandtab: |