diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-28 16:52:26 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-29 13:24:54 +0200 |
commit | 279ab35ad07a958b5b8d7d593b9817e7365b9bb5 (patch) | |
tree | 725d143d62d22e1ce9bf44f3f58ef3907f24498f /sc | |
parent | beeb10a097cdb44af931b92d2849a7e4d09414c0 (diff) |
uitest: guard execute_dialog_through_command in sc
Mostly done with a script
for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac
< UITest: introduce guarded context managers >
Change-Id: Id49eb66ba2827a6e2d0a737e48726a1d1c49c814
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118029
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
123 files changed, 2596 insertions, 3436 deletions
diff --git a/sc/qa/uitest/autofilter/autofilterBugs.py b/sc/qa/uitest/autofilter/autofilterBugs.py index 908d78aa62d3..5f344536da15 100644 --- a/sc/qa/uitest/autofilter/autofilterBugs.py +++ b/sc/qa/uitest/autofilter/autofilterBugs.py @@ -16,11 +16,9 @@ class autofilter(UITestCase): #autofilter exist self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort", close_button="cancel"): + pass - xcancBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xcancBtn) #autofilter still exist self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) @@ -37,18 +35,15 @@ class autofilter(UITestCase): enter_text_to_cell(xGridWindow, "B3", "d") xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B1"})) - self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter") - xDialog = self.xUITest.getTopFocusWindow() - xYesBtn = xDialog.getChild("yes") - self.ui_test.close_dialog_through_button(xYesBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataFilterAutoFilter", close_button="yes"): + pass xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A3"})) self.xUITest.executeCommand(".uno:SelectRow") #select two rows - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort"): + pass + #autofilter still exist self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) @@ -64,10 +59,9 @@ class autofilter(UITestCase): xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:E6"})) - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort"): + pass + #autofilter still exist self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) diff --git a/sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py b/sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py index 89be1bb51099..ccfd0e36fe56 100644 --- a/sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py +++ b/sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py @@ -97,10 +97,8 @@ class tdf117276_autofilter_reset(UITestCase): xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B6"})) # 2. switch on auto-filter - self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter") - xDialog = self.xUITest.getTopFocusWindow() - xYesBtn = xDialog.getChild("yes") - self.ui_test.close_dialog_through_button(xYesBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataFilterAutoFilter", close_button="yes"): + pass # autofilter still exist self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) diff --git a/sc/qa/uitest/autofilter/tdf126306.py b/sc/qa/uitest/autofilter/tdf126306.py index 73f8d83f8b85..08ca30974354 100644 --- a/sc/qa/uitest/autofilter/tdf126306.py +++ b/sc/qa/uitest/autofilter/tdf126306.py @@ -34,10 +34,8 @@ class tdf126306(UITestCase): xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A15"})) - self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter") - xDialog = self.xUITest.getTopFocusWindow() - xYesBtn = xDialog.getChild("yes") - self.ui_test.close_dialog_through_button(xYesBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataFilterAutoFilter", close_button="yes"): + pass self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) diff --git a/sc/qa/uitest/autofilter/tdf140754.py b/sc/qa/uitest/autofilter/tdf140754.py index 67a4c5055eb7..bd488a7f80b4 100644 --- a/sc/qa/uitest/autofilter/tdf140754.py +++ b/sc/qa/uitest/autofilter/tdf140754.py @@ -16,19 +16,16 @@ class tdf140754(UITestCase): with self.ui_test.load_file(get_url_for_data_file("tdf140754.ods")) as calc_doc: #Make sure 'multi-threaded calculation' is enabled - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") - xDialogOpt = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xCalcEntry = xPages.getChild('3') - xCalcEntry.executeAction("EXPAND", tuple()) - xCalcCalculateEntry = xCalcEntry.getChild('3') - xCalcCalculateEntry.executeAction("SELECT", tuple()) + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcCalculateEntry = xCalcEntry.getChild('3') + xCalcCalculateEntry.executeAction("SELECT", tuple()) - self.assertEqual('true', get_state_as_dict(xDialogOpt.getChild('threadingenabled'))["Selected"]) + self.assertEqual('true', get_state_as_dict(xDialogOpt.getChild('threadingenabled'))["Selected"]) - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) self.assertEqual(0, get_cell_by_position(calc_doc, 0, 0, 30).getValue()) diff --git a/sc/qa/uitest/autofilter/tdf36383.py b/sc/qa/uitest/autofilter/tdf36383.py index d55db21837b3..46bc1c915317 100644 --- a/sc/qa/uitest/autofilter/tdf36383.py +++ b/sc/qa/uitest/autofilter/tdf36383.py @@ -42,24 +42,18 @@ class tdf36383(UITestCase): self.assertFalse(row.getPropertyValue("IsVisible")) #row height - self.ui_test.execute_dialog_through_command(".uno:RowHeight") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) self.assertFalse(row.getPropertyValue("IsVisible")) #optimal row height - self.ui_test.execute_dialog_through_command(".uno:SetOptimalRowHeight") - xDialog = self.xUITest.getTopFocusWindow() - - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:SetOptimalRowHeight"): + pass self.assertFalse(row.getPropertyValue("IsVisible")) diff --git a/sc/qa/uitest/autofilter/tdf46062.py b/sc/qa/uitest/autofilter/tdf46062.py index 41b42eb0e475..bc941ef0fccc 100644 --- a/sc/qa/uitest/autofilter/tdf46062.py +++ b/sc/qa/uitest/autofilter/tdf46062.py @@ -24,10 +24,8 @@ class tdf46062(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter") - xDialog = self.xUITest.getTopFocusWindow() - xYesBtn = xDialog.getChild("yes") - self.ui_test.close_dialog_through_button(xYesBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataFilterAutoFilter", close_button="yes"): + pass gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) xFloatWindow = self.xUITest.getFloatWindow() diff --git a/sc/qa/uitest/calc_tests/CellDropDownItems.py b/sc/qa/uitest/calc_tests/CellDropDownItems.py index 7b089751cff5..def8a81a515a 100644 --- a/sc/qa/uitest/calc_tests/CellDropDownItems.py +++ b/sc/qa/uitest/calc_tests/CellDropDownItems.py @@ -22,28 +22,25 @@ class CellDropDownItems(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C10"})) #Open Validation Dialog - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - - #Select List option - xallow = xDialog.getChild("allow") - xallow.executeAction("SELECT", mkPropertyValues({"POS": "6"})) - - #Add items to the List - xminlist = xDialog.getChild("minlist") - xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item1"})) - xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item2"})) - xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item3"})) - xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item4"})) - xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item5"})) - - #Close the dialog - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + + #Select List option + xallow = xDialog.getChild("allow") + xallow.executeAction("SELECT", mkPropertyValues({"POS": "6"})) + + #Add items to the List + xminlist = xDialog.getChild("minlist") + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item1"})) + xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item2"})) + xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item3"})) + xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item4"})) + xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item5"})) + + #Close the dialog #Launch the Select Menu to view the list ans select first item in the list gridwin = xCalcDoc.getChild("grid_window") diff --git a/sc/qa/uitest/calc_tests/autofill.py b/sc/qa/uitest/calc_tests/autofill.py index 60a5f04f3315..ee0d549fee7b 100644 --- a/sc/qa/uitest/calc_tests/autofill.py +++ b/sc/qa/uitest/calc_tests/autofill.py @@ -19,10 +19,8 @@ class CalcAutofill(UITestCase): gridwin = xCalcDoc.getChild("grid_window") #Select cell A12 and drag the fill handle in the bottom right corner of the cell down to A18 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A12:A18"})) - self.ui_test.execute_dialog_through_command(".uno:FillSeries") - xDialog = self.xUITest.getTopFocusWindow() - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries"): + pass #Compare with the content in the right next column self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 11).getValue(), 18.34) self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 12).getValue(), 19.34) @@ -33,16 +31,13 @@ class CalcAutofill(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 17).getValue(), 24.34) #Select cell A12 and drag the fill handle in the bottom right corner of the cell up to A6 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A6:A12"})) - self.ui_test.execute_dialog_through_command(".uno:FillSeries") - xDialog = self.xUITest.getTopFocusWindow() - xup = xDialog.getChild("up") - xincrement = xDialog.getChild("increment") - xup.executeAction("CLICK", tuple()) - xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"})) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries") as xDialog: + xup = xDialog.getChild("up") + xincrement = xDialog.getChild("increment") + xup.executeAction("CLICK", tuple()) + xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"})) #Compare with the content in the right next column self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 5).getValue(), 12.34) self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 6).getValue(), 13.34) @@ -54,10 +49,8 @@ class CalcAutofill(UITestCase): #Continue with the next cells with grey background gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "M12:M18"})) - self.ui_test.execute_dialog_through_command(".uno:FillSeries") - xDialog = self.xUITest.getTopFocusWindow() - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries"): + pass #Compare with the content in the right next column self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 11).getString(), "12abc40") self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 12).getString(), "12abc41") @@ -68,16 +61,13 @@ class CalcAutofill(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 17).getString(), "12abc46") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "M6:M12"})) - self.ui_test.execute_dialog_through_command(".uno:FillSeries") - xDialog = self.xUITest.getTopFocusWindow() - xup = xDialog.getChild("up") - xincrement = xDialog.getChild("increment") - xup.executeAction("CLICK", tuple()) - xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"})) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries") as xDialog: + xup = xDialog.getChild("up") + xincrement = xDialog.getChild("increment") + xup.executeAction("CLICK", tuple()) + xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"})) #Compare with the content in the right next column self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 5).getString(), "12abc34") self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 6).getString(), "12abc35") @@ -88,10 +78,8 @@ class CalcAutofill(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 11).getString(), "12abc40") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "P12:P18"})) - self.ui_test.execute_dialog_through_command(".uno:FillSeries") - xDialog = self.xUITest.getTopFocusWindow() - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries"): + pass #Compare with the content in the right next column self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 11).getString(), "10.64.127.7") self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 12).getString(), "10.64.127.8") @@ -102,16 +90,13 @@ class CalcAutofill(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 17).getString(), "10.64.127.13") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "P6:P12"})) - self.ui_test.execute_dialog_through_command(".uno:FillSeries") - xDialog = self.xUITest.getTopFocusWindow() - xup = xDialog.getChild("up") - xincrement = xDialog.getChild("increment") - xup.executeAction("CLICK", tuple()) - xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"})) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries") as xDialog: + xup = xDialog.getChild("up") + xincrement = xDialog.getChild("increment") + xup.executeAction("CLICK", tuple()) + xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"})) #Compare with the content in the right next column self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 5).getString(), "10.64.127.1") self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 6).getString(), "10.64.127.2") @@ -129,12 +114,9 @@ class CalcAutofill(UITestCase): enter_text_to_cell(gridwin, "A1", "1st") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) - self.ui_test.execute_dialog_through_command(".uno:FillSeries") - xDialog = self.xUITest.getTopFocusWindow() - xautofill = xDialog.getChild("autofill") - xautofill.executeAction("CLICK", tuple()) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries") as xDialog: + xautofill = xDialog.getChild("autofill") + xautofill.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1st") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "2nd") self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "3rd") diff --git a/sc/qa/uitest/calc_tests/calcSheetDelete.py b/sc/qa/uitest/calc_tests/calcSheetDelete.py index b237003b648d..b52dc67e3dae 100644 --- a/sc/qa/uitest/calc_tests/calcSheetDelete.py +++ b/sc/qa/uitest/calc_tests/calcSheetDelete.py @@ -22,17 +22,13 @@ class calcSheetDelete(UITestCase): xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "L12"})) nrSheets = document.Sheets.getCount() #default number - self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("ok") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"): + pass self.assertEqual(document.Sheets.getCount(), nrSheets + 1) - self.ui_test.execute_dialog_through_command(".uno:Remove") #delete sheet - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("yes") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Remove", close_button="yes"): + pass xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') xToolkit.processEventsToIdle() @@ -51,15 +47,11 @@ class calcSheetDelete(UITestCase): nrSheets = document.Sheets.getCount() #default number of sheets - self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("ok") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"): + pass - self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("ok") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"): + pass xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') xToolkit.processEventsToIdle() @@ -68,10 +60,8 @@ class calcSheetDelete(UITestCase): xGridWindow = xCalcDoc.getChild("grid_window") enter_text_to_cell(xGridWindow, "B2", "abcd") - self.ui_test.execute_dialog_through_command(".uno:Remove") #delete sheet - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("yes") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Remove", close_button="yes"): + pass self.assertEqual(document.Sheets.getCount(), nrSheets + 1) self.xUITest.executeCommand(".uno:Undo") @@ -91,10 +81,8 @@ class calcSheetDelete(UITestCase): nrSheets = document.Sheets.getCount() #default number i = 0 while i < 6: - self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("ok") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"): + pass i = i + 1 self.assertEqual(document.Sheets.getCount(), nrSheets + 6) @@ -103,10 +91,8 @@ class calcSheetDelete(UITestCase): self.xUITest.executeCommand(".uno:JumpToNextTableSel") #select next sheet i = i + 1 - self.ui_test.execute_dialog_through_command(".uno:Remove") #delete selected sheets - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("yes") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Remove", close_button="yes"): + pass xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') xToolkit.processEventsToIdle() @@ -128,10 +114,8 @@ class calcSheetDelete(UITestCase): nrSheets = document.Sheets.getCount() #default number i = 0 while i < 100: - self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("ok") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"): + pass i = i + 1 xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') xToolkit.processEventsToIdle() @@ -142,10 +126,8 @@ class calcSheetDelete(UITestCase): self.xUITest.executeCommand(".uno:JumpToNextTableSel") #select next sheet i = i + 1 - self.ui_test.execute_dialog_through_command(".uno:Remove") #delete selected sheets - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("yes") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Remove", close_button="yes"): + pass self.assertEqual(document.Sheets.getCount(), nrSheets) self.xUITest.executeCommand(".uno:Undo") diff --git a/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py b/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py index 7d4c2ff089ba..e41871b135b2 100644 --- a/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py +++ b/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py @@ -22,122 +22,119 @@ class CalcCellBackgroundColorSelector(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "6") #tab Numbers - # click on color btn - xbtncolor = xDialog.getChild("btncolor") - xbtncolor.executeAction("CLICK",tuple()) - xpaletteselector = xDialog.getChild("paletteselector") - - # Now we have the ColorPage that we can get the color selector from it - xColorpage = xDialog.getChild("ColorPage") - color_selector = xColorpage.getChild("colorset") - - # For chart-palettes colors - select_by_text(xpaletteselector, "chart-palettes") - # Select Color with id 2 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2") - self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,66,14)") - - # Select Color with id 5 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "5"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "5") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "4") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 5") - self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(126,0,33)") - - # For libreoffice colors - select_by_text(xpaletteselector, "libreoffice") - # Select Color with id 6 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "6"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "6") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "5") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "32") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Green Accent") - self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(44,238,14)") - - # Select Color with id 30 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "30"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "30") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "29") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Yellow Accent") - self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,215,76)") - - # For html colors - select_by_text(xpaletteselector, "html") - # Select Color with id 1 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "1") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "0") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "139") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "White") - # Select Color with id 120 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "120"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "120") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "119") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Navy") - - # For freecolour-hlc colors - select_by_text(xpaletteselector, "freecolour-hlc") - # Select Color with id 988 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "988"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "988") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "987") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "1032") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 350 60 10") - # Select Color with id 575 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "575"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "575") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "574") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 190 50 20") - - # For tonal colors - select_by_text(xpaletteselector, "tonal") - # Select Color with id 17 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "17"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "17") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "16") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Cyan 82%") - # Select Color with id 13 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "13"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "13") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Magenta 82%") - - # For material colors - select_by_text(xpaletteselector, "material") - # Select Color with id 9 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "9"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "9") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "8") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "228") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Gray 800") - - # For standard colors - select_by_text(xpaletteselector, "standard") - # Select Color with id 3 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "3"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "3") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "2") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Dark Gray 3") - - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Numbers + # click on color btn + xbtncolor = xDialog.getChild("btncolor") + xbtncolor.executeAction("CLICK",tuple()) + xpaletteselector = xDialog.getChild("paletteselector") + + # Now we have the ColorPage that we can get the color selector from it + xColorpage = xDialog.getChild("ColorPage") + color_selector = xColorpage.getChild("colorset") + + # For chart-palettes colors + select_by_text(xpaletteselector, "chart-palettes") + # Select Color with id 2 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2") + self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,66,14)") + + # Select Color with id 5 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "5"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "5") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "4") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 5") + self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(126,0,33)") + + # For libreoffice colors + select_by_text(xpaletteselector, "libreoffice") + # Select Color with id 6 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "6"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "6") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "5") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "32") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Green Accent") + self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(44,238,14)") + + # Select Color with id 30 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "30"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "30") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "29") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Yellow Accent") + self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,215,76)") + + # For html colors + select_by_text(xpaletteselector, "html") + # Select Color with id 1 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "1") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "0") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "139") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "White") + # Select Color with id 120 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "120"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "120") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "119") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Navy") + + # For freecolour-hlc colors + select_by_text(xpaletteselector, "freecolour-hlc") + # Select Color with id 988 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "988"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "988") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "987") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "1032") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 350 60 10") + # Select Color with id 575 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "575"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "575") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "574") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 190 50 20") + + # For tonal colors + select_by_text(xpaletteselector, "tonal") + # Select Color with id 17 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "17"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "17") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "16") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Cyan 82%") + # Select Color with id 13 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "13"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "13") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Magenta 82%") + + # For material colors + select_by_text(xpaletteselector, "material") + # Select Color with id 9 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "9"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "9") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "8") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "228") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Gray 800") + + # For standard colors + select_by_text(xpaletteselector, "standard") + # Select Color with id 3 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "3"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "3") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "2") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Dark Gray 3") + self.ui_test.close_doc() @@ -151,58 +148,52 @@ class CalcCellBackgroundColorSelector(UITestCase): #select cell A5 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A5"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "6") #tab Numbers - # click on color btn - xbtncolor = xDialog.getChild("btncolor") - xbtncolor.executeAction("CLICK",tuple()) - - # we will select color for cell A5 to be able to predict the latest color in - # recent color selector - xpaletteselector = xDialog.getChild("paletteselector") - xColorpage = xDialog.getChild("ColorPage") - color_selector = xColorpage.getChild("colorset") - - # For chart-palettes colors - select_by_text(xpaletteselector, "chart-palettes") - # Select Color with id 2 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2") - xrgb = get_state_as_dict(color_selector)["RGB"] - - # close the dialog after selection of the color - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Numbers + # click on color btn + xbtncolor = xDialog.getChild("btncolor") + xbtncolor.executeAction("CLICK",tuple()) + + # we will select color for cell A5 to be able to predict the latest color in + # recent color selector + xpaletteselector = xDialog.getChild("paletteselector") + xColorpage = xDialog.getChild("ColorPage") + color_selector = xColorpage.getChild("colorset") + + # For chart-palettes colors + select_by_text(xpaletteselector, "chart-palettes") + # Select Color with id 2 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2") + xrgb = get_state_as_dict(color_selector)["RGB"] + + # close the dialog after selection of the color #select cell D3 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D3"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "6") #tab Numbers - # click on color btn - xbtncolor = xDialog.getChild("btncolor") - xbtncolor.executeAction("CLICK",tuple()) - - xColorpage = xDialog.getChild("ColorPage") - recent_color_selector = xColorpage.getChild("recentcolorset") - - # Select Color with id 1 - recent_color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) - self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorId"], "1") - self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorPos"], "0") - self.assertEqual(get_state_as_dict(recent_color_selector)["ColorText"], "Chart 2") - self.assertEqual(get_state_as_dict(recent_color_selector)["RGB"], xrgb) - - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Numbers + # click on color btn + xbtncolor = xDialog.getChild("btncolor") + xbtncolor.executeAction("CLICK",tuple()) + + xColorpage = xDialog.getChild("ColorPage") + recent_color_selector = xColorpage.getChild("recentcolorset") + + # Select Color with id 1 + recent_color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) + self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorId"], "1") + self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorPos"], "0") + self.assertEqual(get_state_as_dict(recent_color_selector)["ColorText"], "Chart 2") + self.assertEqual(get_state_as_dict(recent_color_selector)["RGB"], xrgb) + self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests/columns.py b/sc/qa/uitest/calc_tests/columns.py index 28649d07f3c2..ff1afd948caf 100644 --- a/sc/qa/uitest/calc_tests/columns.py +++ b/sc/qa/uitest/calc_tests/columns.py @@ -21,34 +21,28 @@ class CalcColumns(UITestCase): #select A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #column width - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - xdefault = xDialog.getChild("default") - self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected - heightStrOrig = get_state_as_dict(xvalue)["Text"] - heightVal = heightStrOrig[:4] #default 2.26 cm - xvalue.executeAction("UP", tuple()) #2.36 cm - heightStr = get_state_as_dict(xvalue)["Text"] - heightValNew = heightStr[:4] - self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected - self.assertEqual(heightValNew > heightVal, True) #new value is bigger - xdefault.executeAction("CLICK", tuple()) #click default - self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True) #default value set - #write your own value - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected + heightStrOrig = get_state_as_dict(xvalue)["Text"] + heightVal = heightStrOrig[:4] #default 2.26 cm + xvalue.executeAction("UP", tuple()) #2.36 cm + heightStr = get_state_as_dict(xvalue)["Text"] + heightValNew = heightStr[:4] + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected + self.assertEqual(heightValNew > heightVal, True) #new value is bigger + xdefault.executeAction("CLICK", tuple()) #click default + self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True) #default value set + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok #verify - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - xCancel = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancel) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth", close_button="cancel") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") self.ui_test.close_doc() @@ -63,33 +57,24 @@ class CalcColumns(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1", "EXTEND":"1"})) - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - xdefault = xDialog.getChild("default") - #write your own value - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok #verify gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") self.ui_test.close_doc() @@ -104,15 +89,12 @@ class CalcColumns(UITestCase): #select A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #column width - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok #select column 1 self.xUITest.executeCommand(".uno:SelectColumn") #copy @@ -123,12 +105,9 @@ class CalcColumns(UITestCase): self.xUITest.executeCommand(".uno:Paste") #verify gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") self.ui_test.close_doc() @@ -193,39 +172,30 @@ class CalcColumns(UITestCase): #select C1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) #column width - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok #select D1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) #column width - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"2 cm"})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"2 cm"})) + # Click Ok #select E1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) #column width - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"3 cm"})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"3 cm"})) + # Click Ok #select columns C-E gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:E1"})) self.xUITest.executeCommand(".uno:SelectColumn") @@ -233,52 +203,34 @@ class CalcColumns(UITestCase): self.xUITest.executeCommand(".uno:InsertColumnsBefore") #verify gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.0003 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.0003 cm") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.0004 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.0004 cm") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "F1"})) - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "G1"})) - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.0003 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.0003 cm") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "H1"})) - self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.0004 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.0004 cm") self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests/formatCells.py b/sc/qa/uitest/calc_tests/formatCells.py index f8b5cfd7c30c..4d4df4ac8f26 100644 --- a/sc/qa/uitest/calc_tests/formatCells.py +++ b/sc/qa/uitest/calc_tests/formatCells.py @@ -21,55 +21,49 @@ class formatCell(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab Numbers - xliststore1 = xDialog.getChild("categorylb") #1st list / Category - xliststore2 = xDialog.getChild("formatlb") #2nd list / Format - xdecimalsed = xDialog.getChild("decimalsed") - xleadzerosed = xDialog.getChild("leadzerosed") - xnegnumred = xDialog.getChild("negnumred") - xthousands = xDialog.getChild("thousands") - xlanguagelb = xDialog.getChild("languagelb") - xformatted = xDialog.getChild("formatted") - #language - select_by_text(xlanguagelb, "English (USA)") - #other properties - xdecimalsed.executeAction("UP", tuple()) - xleadzerosed.executeAction("UP", tuple()) - xnegnumred.executeAction("CLICK", tuple()) - xthousands.executeAction("CLICK", tuple()) - #format #,#00.0;[RED]-#,#00.0 - self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0") - #save - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") + #language + select_by_text(xlanguagelb, "English (USA)") + #other properties + xdecimalsed.executeAction("UP", tuple()) + xleadzerosed.executeAction("UP", tuple()) + xnegnumred.executeAction("CLICK", tuple()) + xthousands.executeAction("CLICK", tuple()) + #format #,#00.0;[RED]-#,#00.0 + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0") + #save #verify gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab Numbers - xliststore1 = xDialog.getChild("categorylb") #1st list / Category - xliststore2 = xDialog.getChild("formatlb") #2nd list / Format - xdecimalsed = xDialog.getChild("decimalsed") - xleadzerosed = xDialog.getChild("leadzerosed") - xnegnumred = xDialog.getChild("negnumred") - xthousands = xDialog.getChild("thousands") - xlanguagelb = xDialog.getChild("languagelb") - xformatted = xDialog.getChild("formatted") - - self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Number") - self.assertEqual(get_state_as_dict(xlanguagelb)["SelectEntryText"], "English (USA)") - self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "1") - self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "2") - self.assertEqual(get_state_as_dict(xnegnumred)["Selected"], "true") - self.assertEqual(get_state_as_dict(xthousands)["Selected"], "true") - self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0") - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") + + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Number") + self.assertEqual(get_state_as_dict(xlanguagelb)["SelectEntryText"], "English (USA)") + self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "1") + self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "2") + self.assertEqual(get_state_as_dict(xnegnumred)["Selected"], "true") + self.assertEqual(get_state_as_dict(xthousands)["Selected"], "true") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0") self.ui_test.close_doc() @@ -82,52 +76,46 @@ class formatCell(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") #tab Font - xSizeFont = xDialog.getChild("westsizelb-cjk") - xSizeFontEast = xDialog.getChild("eastsizelb") - xSizeFontCTL = xDialog.getChild("ctlsizelb") - xLangFont = xDialog.getChild("westlanglb-cjk") - xLangFontEast = xDialog.getChild("eastlanglb") - xLangFontCTL = xDialog.getChild("ctllanglb") - - xSizeFont.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 - xSizeFontEast.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xSizeFontEast.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 - xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 - select_pos(xLangFont, "0") - select_pos(xLangFontEast, "0") - select_pos(xLangFontCTL, "0") - xOK = xDialog.getChild("ok") - xOK.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab Font + xSizeFont = xDialog.getChild("westsizelb-cjk") + xSizeFontEast = xDialog.getChild("eastsizelb") + xSizeFontCTL = xDialog.getChild("ctlsizelb") + xLangFont = xDialog.getChild("westlanglb-cjk") + xLangFontEast = xDialog.getChild("eastlanglb") + xLangFontCTL = xDialog.getChild("ctllanglb") + + xSizeFont.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 + xSizeFontEast.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFontEast.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 + xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 + select_pos(xLangFont, "0") + select_pos(xLangFontEast, "0") + select_pos(xLangFontCTL, "0") #Verify - select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") #tab Font - xSizeFont = xDialog.getChild("westsizelb-cjk") - xSizeFontEast = xDialog.getChild("eastsizelb") - xSizeFontCTL = xDialog.getChild("ctlsizelb") - xLangFont = xDialog.getChild("westlanglb-cjk") - xLangFontEast = xDialog.getChild("eastlanglb") - xLangFontCTL = xDialog.getChild("ctllanglb") - - self.assertEqual(get_state_as_dict(xSizeFont)["Text"], "18 pt") - self.assertEqual(get_state_as_dict(xSizeFontEast)["Text"], "18 pt") - self.assertEqual(get_state_as_dict(xSizeFontCTL)["Text"], "18 pt") #check font size - self.assertEqual(get_state_as_dict(xLangFont)["Text"], "[None]") - self.assertEqual(get_state_as_dict(xLangFontEast)["SelectEntryText"], "[None]") - self.assertEqual(get_state_as_dict(xLangFontCTL)["SelectEntryText"], "[None]") - - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab Font + xSizeFont = xDialog.getChild("westsizelb-cjk") + xSizeFontEast = xDialog.getChild("eastsizelb") + xSizeFontCTL = xDialog.getChild("ctlsizelb") + xLangFont = xDialog.getChild("westlanglb-cjk") + xLangFontEast = xDialog.getChild("eastlanglb") + xLangFontCTL = xDialog.getChild("ctllanglb") + + self.assertEqual(get_state_as_dict(xSizeFont)["Text"], "18 pt") + self.assertEqual(get_state_as_dict(xSizeFontEast)["Text"], "18 pt") + self.assertEqual(get_state_as_dict(xSizeFontCTL)["Text"], "18 pt") #check font size + self.assertEqual(get_state_as_dict(xLangFont)["Text"], "[None]") + self.assertEqual(get_state_as_dict(xLangFontEast)["SelectEntryText"], "[None]") + self.assertEqual(get_state_as_dict(xLangFontCTL)["SelectEntryText"], "[None]") + self.ui_test.close_doc() @@ -140,50 +128,44 @@ class formatCell(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "2") #tab Font Effects - xRelief = xDialog.getChild("relieflb") - xOverline = xDialog.getChild("overlinelb") - xStrikeout = xDialog.getChild("strikeoutlb") - xUnderline = xDialog.getChild("underlinelb") - xEmphasis = xDialog.getChild("emphasislb") - xPosition = xDialog.getChild("positionlb") - - select_pos(xRelief, "1") - select_pos(xOverline, "1") - select_pos(xStrikeout, "1") - select_pos(xUnderline, "1") - select_pos(xEmphasis, "1") - select_pos(xPosition, "1") - - xOK = xDialog.getChild("ok") - xOK.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") #tab Font Effects + xRelief = xDialog.getChild("relieflb") + xOverline = xDialog.getChild("overlinelb") + xStrikeout = xDialog.getChild("strikeoutlb") + xUnderline = xDialog.getChild("underlinelb") + xEmphasis = xDialog.getChild("emphasislb") + xPosition = xDialog.getChild("positionlb") + + select_pos(xRelief, "1") + select_pos(xOverline, "1") + select_pos(xStrikeout, "1") + select_pos(xUnderline, "1") + select_pos(xEmphasis, "1") + select_pos(xPosition, "1") + #Verify- select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "2") - - xRelief = xDialog.getChild("relieflb") - xOverline = xDialog.getChild("overlinelb") - xStrikeout = xDialog.getChild("strikeoutlb") - xUnderline = xDialog.getChild("underlinelb") - xEmphasis = xDialog.getChild("emphasislb") - xPosition = xDialog.getChild("positionlb") - - self.assertEqual(get_state_as_dict(xRelief)["SelectEntryText"], "Embossed") - self.assertEqual(get_state_as_dict(xOverline)["SelectEntryText"], "Single") - self.assertEqual(get_state_as_dict(xStrikeout)["SelectEntryText"], "Single") - self.assertEqual(get_state_as_dict(xUnderline)["SelectEntryText"], "Single") - self.assertEqual(get_state_as_dict(xEmphasis)["SelectEntryText"], "Dot") - self.assertEqual(get_state_as_dict(xPosition)["SelectEntryText"], "Below text") - - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + + xRelief = xDialog.getChild("relieflb") + xOverline = xDialog.getChild("overlinelb") + xStrikeout = xDialog.getChild("strikeoutlb") + xUnderline = xDialog.getChild("underlinelb") + xEmphasis = xDialog.getChild("emphasislb") + xPosition = xDialog.getChild("positionlb") + + self.assertEqual(get_state_as_dict(xRelief)["SelectEntryText"], "Embossed") + self.assertEqual(get_state_as_dict(xOverline)["SelectEntryText"], "Single") + self.assertEqual(get_state_as_dict(xStrikeout)["SelectEntryText"], "Single") + self.assertEqual(get_state_as_dict(xUnderline)["SelectEntryText"], "Single") + self.assertEqual(get_state_as_dict(xEmphasis)["SelectEntryText"], "Dot") + self.assertEqual(get_state_as_dict(xPosition)["SelectEntryText"], "Below text") + self.ui_test.close_doc() @@ -195,52 +177,46 @@ class formatCell(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "3") #tab Alignment - comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign") - xspinIndentFrom = xDialog.getChild("spinIndentFrom") - xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign") - xcheckVertStack = xDialog.getChild("checkVertStack") - xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto") - xcheckHyphActive = xDialog.getChild("checkHyphActive") - xcomboTextDirBox = xDialog.getChild("comboTextDirBox") - - select_by_text(comboboxHorzAlign, "Left") - xspinIndentFrom.executeAction("UP", tuple()) - indentVal = get_state_as_dict(xspinIndentFrom)["Text"] - select_by_text(xcomboboxVertAlign, "Top") - xcheckVertStack.executeAction("CLICK", tuple()) - xcheckWrapTextAuto.executeAction("CLICK", tuple()) - xcheckHyphActive.executeAction("CLICK", tuple()) - select_by_text(xcomboTextDirBox, "Left-to-right (LTR)") - xOK = xDialog.getChild("ok") - xOK.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") #tab Alignment + comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign") + xspinIndentFrom = xDialog.getChild("spinIndentFrom") + xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign") + xcheckVertStack = xDialog.getChild("checkVertStack") + xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto") + xcheckHyphActive = xDialog.getChild("checkHyphActive") + xcomboTextDirBox = xDialog.getChild("comboTextDirBox") + + select_by_text(comboboxHorzAlign, "Left") + xspinIndentFrom.executeAction("UP", tuple()) + indentVal = get_state_as_dict(xspinIndentFrom)["Text"] + select_by_text(xcomboboxVertAlign, "Top") + xcheckVertStack.executeAction("CLICK", tuple()) + xcheckWrapTextAuto.executeAction("CLICK", tuple()) + xcheckHyphActive.executeAction("CLICK", tuple()) + select_by_text(xcomboTextDirBox, "Left-to-right (LTR)") #Verify- select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "3") - comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign") - xspinIndentFrom = xDialog.getChild("spinIndentFrom") - xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign") - xcheckVertStack = xDialog.getChild("checkVertStack") - xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto") - xcheckHyphActive = xDialog.getChild("checkHyphActive") - xcomboTextDirBox = xDialog.getChild("comboTextDirBox") - - self.assertEqual(get_state_as_dict(comboboxHorzAlign)["SelectEntryText"], "Left") - self.assertEqual(get_state_as_dict(xspinIndentFrom)["Text"] == indentVal, True) - self.assertEqual(get_state_as_dict(xcomboboxVertAlign)["SelectEntryText"], "Top") - self.assertEqual(get_state_as_dict(xcheckVertStack)["Selected"], "true") - self.assertEqual(get_state_as_dict(xcheckWrapTextAuto)["Selected"], "true") - self.assertEqual(get_state_as_dict(xcheckHyphActive)["Selected"], "true") - self.assertEqual(get_state_as_dict(xcomboTextDirBox)["SelectEntryText"], "Left-to-right (LTR)") - xOK = xDialog.getChild("ok") - xOK.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") + comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign") + xspinIndentFrom = xDialog.getChild("spinIndentFrom") + xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign") + xcheckVertStack = xDialog.getChild("checkVertStack") + xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto") + xcheckHyphActive = xDialog.getChild("checkHyphActive") + xcomboTextDirBox = xDialog.getChild("comboTextDirBox") + + self.assertEqual(get_state_as_dict(comboboxHorzAlign)["SelectEntryText"], "Left") + self.assertEqual(get_state_as_dict(xspinIndentFrom)["Text"] == indentVal, True) + self.assertEqual(get_state_as_dict(xcomboboxVertAlign)["SelectEntryText"], "Top") + self.assertEqual(get_state_as_dict(xcheckVertStack)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcheckWrapTextAuto)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcheckHyphActive)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcomboTextDirBox)["SelectEntryText"], "Left-to-right (LTR)") self.ui_test.close_doc() @@ -252,25 +228,19 @@ class formatCell(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "4") #tab Asian typography - xcheckForbidList = xDialog.getChild("checkForbidList") - xcheckForbidList.executeAction("CLICK", tuple()) - xOK = xDialog.getChild("ok") - xOK.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") #tab Asian typography + xcheckForbidList = xDialog.getChild("checkForbidList") + xcheckForbidList.executeAction("CLICK", tuple()) #Verify- select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "4") - xcheckForbidList = xDialog.getChild("checkForbidList") - self.assertEqual(get_state_as_dict(xcheckForbidList)["Selected"], "true") - xOK = xDialog.getChild("ok") - xOK.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") + xcheckForbidList = xDialog.getChild("checkForbidList") + self.assertEqual(get_state_as_dict(xcheckForbidList)["Selected"], "true") self.ui_test.close_doc() @@ -287,43 +257,40 @@ class formatCell(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "5") #tab Borders - - linewidthmf = xDialog.getChild("linewidthmf") - xLineSet = xDialog.getChild('lineset') - - # check line-width for default solid line - self.assertEqual('0', get_state_as_dict(xLineSet)['SelectedItemPos']) - widthVal = get_state_as_dict(linewidthmf)["Text"] - self.assertEqual(widthVal, '0.75 pt') - - # set line style to "double" (minimal width is taken) - xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": '16'})) - widthVal = get_state_as_dict(linewidthmf)["Text"] - self.assertEqual(widthVal, '1.10 pt') - - # set line style to "solid" - xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) - widthVal = get_state_as_dict(linewidthmf)["Text"] - self.assertEqual(widthVal, '0.75 pt') - - # make custom line width - linewidthmf.executeAction("UP", tuple()) - linewidthmf.executeAction("UP", tuple()) - linewidthmf.executeAction("UP", tuple()) - widthVal = get_state_as_dict(linewidthmf)["Text"] - self.assertEqual(widthVal, '1.50 pt') - - # set line style to "double" (minimal width is not taken) - xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "8"})) - widthVal = get_state_as_dict(linewidthmf)["Text"] - self.assertEqual(widthVal, '1.50 pt') - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") #tab Borders + + linewidthmf = xDialog.getChild("linewidthmf") + xLineSet = xDialog.getChild('lineset') + + # check line-width for default solid line + self.assertEqual('0', get_state_as_dict(xLineSet)['SelectedItemPos']) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '0.75 pt') + + # set line style to "double" (minimal width is taken) + xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": '16'})) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '1.10 pt') + + # set line style to "solid" + xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '0.75 pt') + + # make custom line width + linewidthmf.executeAction("UP", tuple()) + linewidthmf.executeAction("UP", tuple()) + linewidthmf.executeAction("UP", tuple()) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '1.50 pt') + + # set line style to "double" (minimal width is not taken) + xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "8"})) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '1.50 pt') + self.ui_test.close_doc() @@ -340,57 +307,51 @@ class formatCell(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "5") #tab Borders - xsync = xDialog.getChild("sync") - xleftmf = xDialog.getChild("leftmf") - xrightmf = xDialog.getChild("rightmf") - xtopmf = xDialog.getChild("topmf") - xbottommf = xDialog.getChild("bottommf") - - xsync.executeAction("CLICK", tuple()) #uncheck Synchronize - xleftmf.executeAction("UP", tuple()) - xrightmf.executeAction("UP", tuple()) - xrightmf.executeAction("UP", tuple()) - xtopmf.executeAction("UP", tuple()) - xtopmf.executeAction("UP", tuple()) - xtopmf.executeAction("UP", tuple()) - xbottommf.executeAction("UP", tuple()) - xbottommf.executeAction("UP", tuple()) - xbottommf.executeAction("UP", tuple()) - xbottommf.executeAction("UP", tuple()) - - leftVal = get_state_as_dict(xleftmf)["Text"] - rightVal = get_state_as_dict(xrightmf)["Text"] - topVal = get_state_as_dict(xtopmf)["Text"] - bottomVal = get_state_as_dict(xbottommf)["Text"] - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") #tab Borders + xsync = xDialog.getChild("sync") + xleftmf = xDialog.getChild("leftmf") + xrightmf = xDialog.getChild("rightmf") + xtopmf = xDialog.getChild("topmf") + xbottommf = xDialog.getChild("bottommf") + + xsync.executeAction("CLICK", tuple()) #uncheck Synchronize + xleftmf.executeAction("UP", tuple()) + xrightmf.executeAction("UP", tuple()) + xrightmf.executeAction("UP", tuple()) + xtopmf.executeAction("UP", tuple()) + xtopmf.executeAction("UP", tuple()) + xtopmf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + + leftVal = get_state_as_dict(xleftmf)["Text"] + rightVal = get_state_as_dict(xrightmf)["Text"] + topVal = get_state_as_dict(xtopmf)["Text"] + bottomVal = get_state_as_dict(xbottommf)["Text"] + # Verify select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "5") #tab Borders - xsync = xDialog.getChild("sync") - xleftmf = xDialog.getChild("leftmf") - xrightmf = xDialog.getChild("rightmf") - xtopmf = xDialog.getChild("topmf") - xbottommf = xDialog.getChild("bottommf") - - self.assertEqual(get_state_as_dict(xsync)["Selected"], "false") - self.assertEqual(get_state_as_dict(xleftmf)["Text"] == leftVal, True) - self.assertEqual(get_state_as_dict(xrightmf)["Text"] == rightVal, True) - self.assertEqual(get_state_as_dict(xtopmf)["Text"] == topVal, True) - self.assertEqual(get_state_as_dict(xbottommf)["Text"] == bottomVal, True) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") #tab Borders + xsync = xDialog.getChild("sync") + xleftmf = xDialog.getChild("leftmf") + xrightmf = xDialog.getChild("rightmf") + xtopmf = xDialog.getChild("topmf") + xbottommf = xDialog.getChild("bottommf") + + self.assertEqual(get_state_as_dict(xsync)["Selected"], "false") + self.assertEqual(get_state_as_dict(xleftmf)["Text"] == leftVal, True) + self.assertEqual(get_state_as_dict(xrightmf)["Text"] == rightVal, True) + self.assertEqual(get_state_as_dict(xtopmf)["Text"] == topVal, True) + self.assertEqual(get_state_as_dict(xbottommf)["Text"] == bottomVal, True) + self.ui_test.close_doc() @@ -403,37 +364,31 @@ class formatCell(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "6") #tab Cell protection - xcheckHideFormula = xDialog.getChild("checkHideFormula") - xcheckHideAll = xDialog.getChild("checkHideAll") - xcheckHidePrinting = xDialog.getChild("checkHidePrinting") - - xcheckHideFormula.executeAction("CLICK", tuple()) - xcheckHideAll.executeAction("CLICK", tuple()) - xcheckHidePrinting.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Cell protection + xcheckHideFormula = xDialog.getChild("checkHideFormula") + xcheckHideAll = xDialog.getChild("checkHideAll") + xcheckHidePrinting = xDialog.getChild("checkHidePrinting") + + xcheckHideFormula.executeAction("CLICK", tuple()) + xcheckHideAll.executeAction("CLICK", tuple()) + xcheckHidePrinting.executeAction("CLICK", tuple()) # Verify select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "6") #tab Borders - xcheckHideFormula = xDialog.getChild("checkHideFormula") - xcheckHideAll = xDialog.getChild("checkHideAll") - xcheckHidePrinting = xDialog.getChild("checkHidePrinting") + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Borders + xcheckHideFormula = xDialog.getChild("checkHideFormula") + xcheckHideAll = xDialog.getChild("checkHideAll") + xcheckHidePrinting = xDialog.getChild("checkHidePrinting") - self.assertEqual(get_state_as_dict(xcheckHideFormula)["Selected"], "false") - self.assertEqual(get_state_as_dict(xcheckHideAll)["Selected"], "false") - self.assertEqual(get_state_as_dict(xcheckHidePrinting)["Selected"], "false") + self.assertEqual(get_state_as_dict(xcheckHideFormula)["Selected"], "false") + self.assertEqual(get_state_as_dict(xcheckHideAll)["Selected"], "false") + self.assertEqual(get_state_as_dict(xcheckHidePrinting)["Selected"], "false") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) self.ui_test.close_doc() @@ -445,19 +400,16 @@ class formatCell(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "3") #tab Alignment - xspinDegrees = xDialog.getChild("spinDegrees") - self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0") - xspinDegrees.executeAction("DOWN", tuple()) - self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "355") - xspinDegrees.executeAction("UP", tuple()) - self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0") - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") #tab Alignment + xspinDegrees = xDialog.getChild("spinDegrees") + self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0") + xspinDegrees.executeAction("DOWN", tuple()) + self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "355") + xspinDegrees.executeAction("UP", tuple()) + self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0") + self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests/mergedRowsColumns.py b/sc/qa/uitest/calc_tests/mergedRowsColumns.py index 2bc225d1f84d..f0c6b5ba9ac2 100644 --- a/sc/qa/uitest/calc_tests/mergedRowsColumns.py +++ b/sc/qa/uitest/calc_tests/mergedRowsColumns.py @@ -64,12 +64,9 @@ class mergedRowsColumns(UITestCase): #move the content of the hidden cells into the first cell gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A11:A12"})) - self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") - xDialog = self.xUITest.getTopFocusWindow() - - xMoveCells = xDialog.getChild("move-cells-radio") - xMoveCells.executeAction("CLICK", tuple()) - self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ToggleMergeCells") as xDialog: + xMoveCells = xDialog.getChild("move-cells-radio") + xMoveCells.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 10).getString(), "2 3") self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 11).getString(), "0") @@ -79,12 +76,9 @@ class mergedRowsColumns(UITestCase): #keep the contents of the hidden cells gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A11:A12"})) - self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") - xDialog = self.xUITest.getTopFocusWindow() - - xMoveCells = xDialog.getChild("keep-content-radio") - xMoveCells.executeAction("CLICK", tuple()) - self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ToggleMergeCells") as xDialog: + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 10).getString(), "2") self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 11).getString(), "3") self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 11).getString(), "3") @@ -95,12 +89,9 @@ class mergedRowsColumns(UITestCase): #Empty the contents of the hidden cells gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A11:A12"})) - self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") - xDialog = self.xUITest.getTopFocusWindow() - - xMoveCells = xDialog.getChild("move-cells-radio") - xMoveCells.executeAction("CLICK", tuple()) - self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ToggleMergeCells") as xDialog: + xMoveCells = xDialog.getChild("move-cells-radio") + xMoveCells.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 10).getString(), "2 3") self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 11).getString(), "") self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 11).getString(), "0") @@ -111,12 +102,9 @@ class mergedRowsColumns(UITestCase): #A21-A22 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A21:A22"})) - self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") - xDialog = self.xUITest.getTopFocusWindow() - - xMoveCells = xDialog.getChild("keep-content-radio") - xMoveCells.executeAction("CLICK", tuple()) - self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ToggleMergeCells") as xDialog: + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 20).getString(), "2") self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 21).getString(), "3") self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 21).getString(), "2") @@ -127,12 +115,9 @@ class mergedRowsColumns(UITestCase): #A30-A32 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A30:A32"})) - self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") - xDialog = self.xUITest.getTopFocusWindow() - - xMoveCells = xDialog.getChild("keep-content-radio") - xMoveCells.executeAction("CLICK", tuple()) - self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ToggleMergeCells") as xDialog: + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 31).getString(), "thisisbad") self.xUITest.executeCommand(".uno:Undo") @@ -141,12 +126,10 @@ class mergedRowsColumns(UITestCase): #J12-K12 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "J12:K12"})) - self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:ToggleMergeCells") as xDialog: - xMoveCells = xDialog.getChild("keep-content-radio") - xMoveCells.executeAction("CLICK", tuple()) - self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(calc_doc, 0, 9, 11).getString(), "2") self.assertEqual(get_cell_by_position(calc_doc, 0, 11, 11).getString(), "3") @@ -156,12 +139,9 @@ class mergedRowsColumns(UITestCase): #J22-K22 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "J22:K22"})) - self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") - xDialog = self.xUITest.getTopFocusWindow() - - xMoveCells = xDialog.getChild("keep-content-radio") - xMoveCells.executeAction("CLICK", tuple()) - self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ToggleMergeCells") as xDialog: + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(calc_doc, 0, 9, 21).getString(), "2") self.assertEqual(get_cell_by_position(calc_doc, 0, 11, 21).getString(), "2") diff --git a/sc/qa/uitest/calc_tests/printRange.py b/sc/qa/uitest/calc_tests/printRange.py index a08262595035..bdd85a81749a 100644 --- a/sc/qa/uitest/calc_tests/printRange.py +++ b/sc/qa/uitest/calc_tests/printRange.py @@ -93,10 +93,8 @@ class printRange(UITestCase): self.ui_test.close_dialog_through_button(xOK) #Copy sheet - self.ui_test.execute_dialog_through_command(".uno:Move") - xDialog = self.xUITest.getTopFocusWindow() - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Move"): + pass #Verify Print Range dialog on new sheet self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") xDialog = self.xUITest.getTopFocusWindow() diff --git a/sc/qa/uitest/calc_tests/rows.py b/sc/qa/uitest/calc_tests/rows.py index b5e40fa1e327..8b1c47efb840 100644 --- a/sc/qa/uitest/calc_tests/rows.py +++ b/sc/qa/uitest/calc_tests/rows.py @@ -21,34 +21,28 @@ class CalcRows(UITestCase): #select A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #row height - self.ui_test.execute_dialog_through_command(".uno:RowHeight") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - xdefault = xDialog.getChild("default") - self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected - heightStrOrig = get_state_as_dict(xvalue)["Text"] - heightVal = heightStrOrig[:4] #default 0.45 cm - xvalue.executeAction("UP", tuple()) #0.50 cm - heightStr = get_state_as_dict(xvalue)["Text"] - heightValNew = heightStr[:4] - self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected - self.assertEqual(heightValNew > heightVal, True) #new value is bigger - xdefault.executeAction("CLICK", tuple()) #click default - self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True) #default value set - #write your own value - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected + heightStrOrig = get_state_as_dict(xvalue)["Text"] + heightVal = heightStrOrig[:4] #default 0.45 cm + xvalue.executeAction("UP", tuple()) #0.50 cm + heightStr = get_state_as_dict(xvalue)["Text"] + heightValNew = heightStr[:4] + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected + self.assertEqual(heightValNew > heightVal, True) #new value is bigger + xdefault.executeAction("CLICK", tuple()) #click default + self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True) #default value set + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok #verify - self.ui_test.execute_dialog_through_command(".uno:RowHeight") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - xCancel = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancel) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight", close_button="cancel") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") self.ui_test.close_doc() @@ -63,33 +57,24 @@ class CalcRows(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3", "EXTEND":"1"})) - self.ui_test.execute_dialog_through_command(".uno:RowHeight") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - xdefault = xDialog.getChild("default") - #write your own value - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok #verify gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.ui_test.execute_dialog_through_command(".uno:RowHeight") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - self.ui_test.execute_dialog_through_command(".uno:RowHeight") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") self.ui_test.close_doc() @@ -105,15 +90,12 @@ class CalcRows(UITestCase): #select A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #row height - self.ui_test.execute_dialog_through_command(".uno:RowHeight") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok #select row 1 self.xUITest.executeCommand(".uno:SelectRow") #copy @@ -124,12 +106,9 @@ class CalcRows(UITestCase): self.xUITest.executeCommand(".uno:Paste") #verify gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - self.ui_test.execute_dialog_through_command(".uno:RowHeight") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") self.ui_test.close_doc() @@ -194,15 +173,12 @@ class CalcRows(UITestCase): #select A3 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) #row height - self.ui_test.execute_dialog_through_command(".uno:RowHeight") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok #select row 3 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) self.xUITest.executeCommand(".uno:SelectRow") @@ -211,20 +187,14 @@ class CalcRows(UITestCase): #verify gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - self.ui_test.execute_dialog_through_command(".uno:RowHeight") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"})) - self.ui_test.execute_dialog_through_command(".uno:RowHeight") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests/sheetRename.py b/sc/qa/uitest/calc_tests/sheetRename.py index 0f8478b8454b..8c54ee098909 100644 --- a/sc/qa/uitest/calc_tests/sheetRename.py +++ b/sc/qa/uitest/calc_tests/sheetRename.py @@ -14,19 +14,13 @@ class sheetRename(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() - self.ui_test.execute_dialog_through_command(".uno:RenameTable") - xDialog = self.xUITest.getTopFocusWindow() - xname_entry = xDialog.getChild("name_entry") - xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RenameTable") as xDialog: + xname_entry = xDialog.getChild("name_entry") + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) #Verify - self.ui_test.execute_dialog_through_command(".uno:RenameTable") - xDialog = self.xUITest.getTopFocusWindow() - xname_entry = xDialog.getChild("name_entry") - self.assertEqual(get_state_as_dict(xname_entry)["Text"], "NewName") - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RenameTable", close_button="cancel") as xDialog: + xname_entry = xDialog.getChild("name_entry") + self.assertEqual(get_state_as_dict(xname_entry)["Text"], "NewName") self.ui_test.close_doc() @@ -35,26 +29,22 @@ class sheetRename(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() - self.ui_test.execute_dialog_through_command(".uno:RenameTable") - xDialog = self.xUITest.getTopFocusWindow() - xname_entry = xDialog.getChild("name_entry") - nameVal = get_state_as_dict(xname_entry)["Text"] - xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName**"})) - xOKBtn = xDialog.getChild("ok") + with self.ui_test.execute_dialog_through_command_guarded(".uno:RenameTable", close_button="") as xDialog: + xname_entry = xDialog.getChild("name_entry") + nameVal = get_state_as_dict(xname_entry)["Text"] + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName**"})) + xOKBtn = xDialog.getChild("ok") - with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ())): - pass + with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ())): + pass - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) #Verify - self.ui_test.execute_dialog_through_command(".uno:RenameTable") - xDialog = self.xUITest.getTopFocusWindow() - xname_entry = xDialog.getChild("name_entry") - self.assertEqual(get_state_as_dict(xname_entry)["Text"], nameVal) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RenameTable") as xDialog: + xname_entry = xDialog.getChild("name_entry") + self.assertEqual(get_state_as_dict(xname_entry)["Text"], nameVal) self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests/zoom.py b/sc/qa/uitest/calc_tests/zoom.py index dc4ef64ff5e6..d1a8f0853356 100644 --- a/sc/qa/uitest/calc_tests/zoom.py +++ b/sc/qa/uitest/calc_tests/zoom.py @@ -22,46 +22,34 @@ class calcZoom(UITestCase): self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100") #dialog View-Zoom-Zoom - self.ui_test.execute_dialog_through_command(".uno:Zoom") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:Zoom") as xDialog: - #select fit weight & height - OK - open and verify - fitwandh = xDialog.getChild("fitwandh") - fitwandh.executeAction("CLICK",tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + #select fit weight & height - OK - open and verify + fitwandh = xDialog.getChild("fitwandh") + fitwandh.executeAction("CLICK",tuple()) - self.ui_test.execute_dialog_through_command(".uno:Zoom") - xDialog = self.xUITest.getTopFocusWindow() - #select fit weight - OK - open and verify - fitw = xDialog.getChild("fitw") - fitw.executeAction("CLICK",tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Zoom") as xDialog: + #select fit weight - OK - open and verify + fitw = xDialog.getChild("fitw") + fitw.executeAction("CLICK",tuple()) - self.ui_test.execute_dialog_through_command(".uno:Zoom") - xDialog = self.xUITest.getTopFocusWindow() - #select 100% & Automatic - OK - open and verify - x100pc = xDialog.getChild("100pc") - x100pc.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Zoom") as xDialog: + #select 100% & Automatic - OK - open and verify + x100pc = xDialog.getChild("100pc") + x100pc.executeAction("CLICK", tuple()) self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100") #Set the Zoom to be 103% gridwin.executeAction("SET", mkPropertyValues({"ZOOM": "103"})) self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "103") - self.ui_test.execute_dialog_through_command(".uno:Zoom") - xDialog = self.xUITest.getTopFocusWindow() - #select variable option and make zoom 100% again - OK - open and verify - zoomsb = xDialog.getChild("zoomsb") - self.assertEqual(get_state_as_dict(zoomsb)["Text"], "103%") - zoomsb.executeAction("DOWN",tuple()) - zoomsb.executeAction("DOWN",tuple()) - zoomsb.executeAction("DOWN",tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Zoom") as xDialog: + #select variable option and make zoom 100% again - OK - open and verify + zoomsb = xDialog.getChild("zoomsb") + self.assertEqual(get_state_as_dict(zoomsb)["Text"], "103%") + zoomsb.executeAction("DOWN",tuple()) + zoomsb.executeAction("DOWN",tuple()) + zoomsb.executeAction("DOWN",tuple()) self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100") self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests2/dataform.py b/sc/qa/uitest/calc_tests2/dataform.py index fedbebc3cd52..8d9acb761b4c 100644 --- a/sc/qa/uitest/calc_tests2/dataform.py +++ b/sc/qa/uitest/calc_tests2/dataform.py @@ -15,11 +15,9 @@ class dataform(UITestCase): gridwin = xCalcDoc.getChild("grid_window") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A10"})) - self.ui_test.execute_dialog_through_command(".uno:DataForm") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataForm", close_button="close"): + pass - xCloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xCloseBtn) self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf114992.py b/sc/qa/uitest/calc_tests2/tdf114992.py index 3a4ffb55a857..304ca7a8ecce 100644 --- a/sc/qa/uitest/calc_tests2/tdf114992.py +++ b/sc/qa/uitest/calc_tests2/tdf114992.py @@ -15,10 +15,8 @@ class tdf114992(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") - self.ui_test.execute_dialog_through_command(".uno:Remove") #delete sheet - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("yes") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Remove", close_button="yes"): + pass self.assertEqual(calc_doc.Sheets.getCount(), 1) self.xUITest.executeCommand(".uno:Undo") diff --git a/sc/qa/uitest/calc_tests2/tdf117367.py b/sc/qa/uitest/calc_tests2/tdf117367.py index 47ee214f14de..8b0c3e1698da 100644 --- a/sc/qa/uitest/calc_tests2/tdf117367.py +++ b/sc/qa/uitest/calc_tests2/tdf117367.py @@ -22,30 +22,27 @@ class tdf117367(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B4"})) #Right-click - Merge cells /Select all three options - self.ui_test.execute_dialog_through_command(".uno:MergeCells") - xDialog = self.xUITest.getTopFocusWindow() - xmoveCellsRadio = xDialog.getChild("move-cells-radio") - xemptyCellsRadio = xDialog.getChild("empty-cells-radio") - xkeepContentRadio = xDialog.getChild("keep-content-radio") - xmoveCellsRadio.executeAction("CLICK", tuple()) - xmoveCellsRadio.executeAction("CLICK", tuple()) - #Issue: I think these should be exclusive, not possible to select more than one. It is also impossible to uncheck any of the buttons. - self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "true") - self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "false") - self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "false") - - xemptyCellsRadio.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "false") - self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "true") - self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "false") - - xkeepContentRadio.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "false") - self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "false") - self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "true") - - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:MergeCells") as xDialog: + xmoveCellsRadio = xDialog.getChild("move-cells-radio") + xemptyCellsRadio = xDialog.getChild("empty-cells-radio") + xkeepContentRadio = xDialog.getChild("keep-content-radio") + xmoveCellsRadio.executeAction("CLICK", tuple()) + xmoveCellsRadio.executeAction("CLICK", tuple()) + #Issue: I think these should be exclusive, not possible to select more than one. It is also impossible to uncheck any of the buttons. + self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "true") + self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "false") + + xemptyCellsRadio.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "true") + self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "false") + + xkeepContentRadio.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "true") + self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests2/tdf126577.py b/sc/qa/uitest/calc_tests2/tdf126577.py index 2e994aca7fd3..d8a2fda1ffbc 100644 --- a/sc/qa/uitest/calc_tests2/tdf126577.py +++ b/sc/qa/uitest/calc_tests2/tdf126577.py @@ -19,20 +19,17 @@ class tdf126577(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A20"})) - self.ui_test.execute_dialog_through_command(".uno:FillSeries") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries") as xDialog: - self.assertEqual("true", get_state_as_dict(xDialog.getChild("down"))['Checked']) - self.assertEqual("true", get_state_as_dict(xDialog.getChild("linear"))['Checked']) + self.assertEqual("true", get_state_as_dict(xDialog.getChild("down"))['Checked']) + self.assertEqual("true", get_state_as_dict(xDialog.getChild("linear"))['Checked']) - xStart = xDialog.getChild("startValue") - xStart.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + xStart = xDialog.getChild("startValue") + xStart.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - xEnd = xDialog.getChild("endValue") - xEnd.executeAction("TYPE", mkPropertyValues({"TEXT":"10"})) + xEnd = xDialog.getChild("endValue") + xEnd.executeAction("TYPE", mkPropertyValues({"TEXT":"10"})) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) for i in range(10): self.assertEqual(str(i + 1), get_cell_by_position(document, 0, 0, i).getString()) diff --git a/sc/qa/uitest/calc_tests2/tdf37623.py b/sc/qa/uitest/calc_tests2/tdf37623.py index 00ccf19c4a33..a22a9fc0df45 100644 --- a/sc/qa/uitest/calc_tests2/tdf37623.py +++ b/sc/qa/uitest/calc_tests2/tdf37623.py @@ -16,12 +16,9 @@ class tdf37623(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A6"})) - self.ui_test.execute_dialog_through_command(".uno:FillSeries") - xDialog = self.xUITest.getTopFocusWindow() - xautofill = xDialog.getChild("autofill") - xautofill.executeAction("CLICK", tuple()) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries") as xDialog: + xautofill = xDialog.getChild("autofill") + xautofill.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getValue(), 1) self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 2).getValue(), 0) diff --git a/sc/qa/uitest/calc_tests2/tdf46138.py b/sc/qa/uitest/calc_tests2/tdf46138.py index 244e1634a1ec..0780db3d02bb 100644 --- a/sc/qa/uitest/calc_tests2/tdf46138.py +++ b/sc/qa/uitest/calc_tests2/tdf46138.py @@ -19,12 +19,9 @@ class tdf46138(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:SelectColumn") #select 'edit'>'fill'>'series'>Starting Value '1' then "OK", - self.ui_test.execute_dialog_through_command(".uno:FillSeries") - xDialog = self.xUITest.getTopFocusWindow() - xStart = xDialog.getChild("startValue") - xStart.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries") as xDialog: + xStart = xDialog.getChild("startValue") + xStart.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") #then "Ctrl+Z"/ undo self.xUITest.executeCommand(".uno:Undo") diff --git a/sc/qa/uitest/calc_tests2/tdf51700.py b/sc/qa/uitest/calc_tests2/tdf51700.py index 00eadf1469bd..a798f247e841 100644 --- a/sc/qa/uitest/calc_tests2/tdf51700.py +++ b/sc/qa/uitest/calc_tests2/tdf51700.py @@ -26,14 +26,11 @@ class tdf51700(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:SelectColumn") # Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - xcomma = xDialog.getChild("comma") - if (get_state_as_dict(xcomma)["Selected"]) == "false": - xcomma.executeAction("CLICK", tuple()) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns") as xDialog: + xcomma = xDialog.getChild("comma") + if (get_state_as_dict(xcomma)["Selected"]) == "false": + xcomma.executeAction("CLICK", tuple()) + # Click Ok #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 3242) diff --git a/sc/qa/uitest/calc_tests3/clearCells.py b/sc/qa/uitest/calc_tests3/clearCells.py index 7df66ef7f93f..91db83d5262c 100644 --- a/sc/qa/uitest/calc_tests3/clearCells.py +++ b/sc/qa/uitest/calc_tests3/clearCells.py @@ -22,36 +22,33 @@ class clearCells(UITestCase): enter_text_to_cell(gridwin, "A2", "1") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - self.ui_test.execute_dialog_through_command(".uno:Delete") - xDialog = self.xUITest.getTopFocusWindow() - xdeleteall = xDialog.getChild("deleteall") - xtext = xDialog.getChild("text") - xdatetime = xDialog.getChild("datetime") - xcomments = xDialog.getChild("comments") - xobjects = xDialog.getChild("objects") - xnumbers = xDialog.getChild("numbers") - xformulas = xDialog.getChild("formulas") - xformats = xDialog.getChild("formats") - - if (get_state_as_dict(xdeleteall)["Selected"]) == "true": - xdeleteall.executeAction("CLICK", tuple()) - if (get_state_as_dict(xtext)["Selected"]) == "false": - xtext.executeAction("CLICK", tuple()) - if (get_state_as_dict(xdatetime)["Selected"]) == "true": - xdatetime.executeAction("CLICK", tuple()) - if (get_state_as_dict(xcomments)["Selected"]) == "true": - xcomments.executeAction("CLICK", tuple()) - if (get_state_as_dict(xobjects)["Selected"]) == "true": - xobjects.executeAction("CLICK", tuple()) - if (get_state_as_dict(xnumbers)["Selected"]) == "true": - xnumbers.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformulas)["Selected"]) == "true": - xformulas.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformats)["Selected"]) == "true": - xformats.executeAction("CLICK", tuple()) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "false": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 1) @@ -67,36 +64,33 @@ class clearCells(UITestCase): enter_text_to_cell(gridwin, "A2", "1") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - self.ui_test.execute_dialog_through_command(".uno:Delete") - xDialog = self.xUITest.getTopFocusWindow() - xdeleteall = xDialog.getChild("deleteall") - xtext = xDialog.getChild("text") - xdatetime = xDialog.getChild("datetime") - xcomments = xDialog.getChild("comments") - xobjects = xDialog.getChild("objects") - xnumbers = xDialog.getChild("numbers") - xformulas = xDialog.getChild("formulas") - xformats = xDialog.getChild("formats") - - if (get_state_as_dict(xdeleteall)["Selected"]) == "true": - xdeleteall.executeAction("CLICK", tuple()) - if (get_state_as_dict(xtext)["Selected"]) == "true": - xtext.executeAction("CLICK", tuple()) - if (get_state_as_dict(xdatetime)["Selected"]) == "false": - xdatetime.executeAction("CLICK", tuple()) - if (get_state_as_dict(xcomments)["Selected"]) == "true": - xcomments.executeAction("CLICK", tuple()) - if (get_state_as_dict(xobjects)["Selected"]) == "true": - xobjects.executeAction("CLICK", tuple()) - if (get_state_as_dict(xnumbers)["Selected"]) == "true": - xnumbers.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformulas)["Selected"]) == "true": - xformulas.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformats)["Selected"]) == "true": - xformats.executeAction("CLICK", tuple()) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "false": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 1) @@ -112,36 +106,33 @@ class clearCells(UITestCase): enter_text_to_cell(gridwin, "A2", "1") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - self.ui_test.execute_dialog_through_command(".uno:Delete") - xDialog = self.xUITest.getTopFocusWindow() - xdeleteall = xDialog.getChild("deleteall") - xtext = xDialog.getChild("text") - xdatetime = xDialog.getChild("datetime") - xcomments = xDialog.getChild("comments") - xobjects = xDialog.getChild("objects") - xnumbers = xDialog.getChild("numbers") - xformulas = xDialog.getChild("formulas") - xformats = xDialog.getChild("formats") - - if (get_state_as_dict(xdeleteall)["Selected"]) == "true": - xdeleteall.executeAction("CLICK", tuple()) - if (get_state_as_dict(xtext)["Selected"]) == "true": - xtext.executeAction("CLICK", tuple()) - if (get_state_as_dict(xdatetime)["Selected"]) == "true": - xdatetime.executeAction("CLICK", tuple()) - if (get_state_as_dict(xcomments)["Selected"]) == "true": - xcomments.executeAction("CLICK", tuple()) - if (get_state_as_dict(xobjects)["Selected"]) == "true": - xobjects.executeAction("CLICK", tuple()) - if (get_state_as_dict(xnumbers)["Selected"]) == "false": - xnumbers.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformulas)["Selected"]) == "true": - xformulas.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformats)["Selected"]) == "true": - xformats.executeAction("CLICK", tuple()) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "false": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "aa") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 0) @@ -156,36 +147,33 @@ class clearCells(UITestCase): enter_text_to_cell(gridwin, "A2", "=A1+1") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - self.ui_test.execute_dialog_through_command(".uno:Delete") - xDialog = self.xUITest.getTopFocusWindow() - xdeleteall = xDialog.getChild("deleteall") - xtext = xDialog.getChild("text") - xdatetime = xDialog.getChild("datetime") - xcomments = xDialog.getChild("comments") - xobjects = xDialog.getChild("objects") - xnumbers = xDialog.getChild("numbers") - xformulas = xDialog.getChild("formulas") - xformats = xDialog.getChild("formats") - - if (get_state_as_dict(xdeleteall)["Selected"]) == "true": - xdeleteall.executeAction("CLICK", tuple()) - if (get_state_as_dict(xtext)["Selected"]) == "true": - xtext.executeAction("CLICK", tuple()) - if (get_state_as_dict(xdatetime)["Selected"]) == "true": - xdatetime.executeAction("CLICK", tuple()) - if (get_state_as_dict(xcomments)["Selected"]) == "true": - xcomments.executeAction("CLICK", tuple()) - if (get_state_as_dict(xobjects)["Selected"]) == "true": - xobjects.executeAction("CLICK", tuple()) - if (get_state_as_dict(xnumbers)["Selected"]) == "true": - xnumbers.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformulas)["Selected"]) == "false": - xformulas.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformats)["Selected"]) == "true": - xformats.executeAction("CLICK", tuple()) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "false": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "1") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "") @@ -202,51 +190,45 @@ class clearCells(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) self.xUITest.executeCommand(".uno:Bold") - self.ui_test.execute_dialog_through_command(".uno:Delete") - xDialog = self.xUITest.getTopFocusWindow() - xdeleteall = xDialog.getChild("deleteall") - xtext = xDialog.getChild("text") - xdatetime = xDialog.getChild("datetime") - xcomments = xDialog.getChild("comments") - xobjects = xDialog.getChild("objects") - xnumbers = xDialog.getChild("numbers") - xformulas = xDialog.getChild("formulas") - xformats = xDialog.getChild("formats") - - if (get_state_as_dict(xdeleteall)["Selected"]) == "true": - xdeleteall.executeAction("CLICK", tuple()) - if (get_state_as_dict(xtext)["Selected"]) == "true": - xtext.executeAction("CLICK", tuple()) - if (get_state_as_dict(xdatetime)["Selected"]) == "true": - xdatetime.executeAction("CLICK", tuple()) - if (get_state_as_dict(xcomments)["Selected"]) == "true": - xcomments.executeAction("CLICK", tuple()) - if (get_state_as_dict(xobjects)["Selected"]) == "true": - xobjects.executeAction("CLICK", tuple()) - if (get_state_as_dict(xnumbers)["Selected"]) == "true": - xnumbers.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformulas)["Selected"]) == "true": - xformulas.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformats)["Selected"]) == "false": - xformats.executeAction("CLICK", tuple()) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "false": + xformats.executeAction("CLICK", tuple()) + #Verify gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") #tab Font + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab Font - xstylelb = xDialog.getChild("weststylelb-cjk") - print(get_state_as_dict(xstylelb)) + xstylelb = xDialog.getChild("weststylelb-cjk") + print(get_state_as_dict(xstylelb)) - self.assertEqual(get_state_as_dict(xstylelb)["Text"], "Regular") + self.assertEqual(get_state_as_dict(xstylelb)["Text"], "Regular") - xOK = xDialog.getChild("ok") - xOK.executeAction("CLICK", tuple()) self.ui_test.close_doc() @@ -260,22 +242,19 @@ class clearCells(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) self.xUITest.executeCommand(".uno:Bold") - self.ui_test.execute_dialog_through_command(".uno:Delete") - xDialog = self.xUITest.getTopFocusWindow() - xdeleteall = xDialog.getChild("deleteall") - xtext = xDialog.getChild("text") - xdatetime = xDialog.getChild("datetime") - xcomments = xDialog.getChild("comments") - xobjects = xDialog.getChild("objects") - xnumbers = xDialog.getChild("numbers") - xformulas = xDialog.getChild("formulas") - xformats = xDialog.getChild("formats") - - if (get_state_as_dict(xdeleteall)["Selected"]) == "false": - xdeleteall.executeAction("CLICK", tuple()) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "false": + xdeleteall.executeAction("CLICK", tuple()) + #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "") @@ -291,15 +270,12 @@ class clearCells(UITestCase): enter_text_to_cell(gridwin, "A2", "1") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - self.ui_test.execute_dialog_through_command(".uno:Delete") - xDialog = self.xUITest.getTopFocusWindow() - xdeleteall = xDialog.getChild("deleteall") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Delete", close_button="cancel") as xDialog: + xdeleteall = xDialog.getChild("deleteall") - if (get_state_as_dict(xdeleteall)["Selected"]) == "false": - xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdeleteall)["Selected"]) == "false": + xdeleteall.executeAction("CLICK", tuple()) - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "aa") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "1") diff --git a/sc/qa/uitest/calc_tests3/insertQrCodeGen.py b/sc/qa/uitest/calc_tests3/insertQrCodeGen.py index 691eadcbea29..597ad439fa67 100644 --- a/sc/qa/uitest/calc_tests3/insertQrCodeGen.py +++ b/sc/qa/uitest/calc_tests3/insertQrCodeGen.py @@ -17,32 +17,26 @@ class insertQrCode(UITestCase): document = self.ui_test.get_component() # cancel the dialog without doing anything - self.ui_test.execute_dialog_through_command(".uno:InsertQrCode") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertQrCode", close_button="cancel") as xDialog: - xURL = xDialog.getChild("edit_text") - type_text(xURL, "www.libreoffice.org") + xURL = xDialog.getChild("edit_text") + type_text(xURL, "www.libreoffice.org") - xCloseBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCloseBtn) with self.assertRaises(IndexOutOfBoundsException): document.Sheets.getByIndex(0).DrawPage.getByIndex(0) # Reopen the dialog box - self.ui_test.execute_dialog_through_command(".uno:InsertQrCode") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertQrCode") as xDialog: - # Get elements in the Dialog Box - xURL = xDialog.getChild("edit_text") - xECC_Low = xDialog.getChild("button_low") #How radio button input is written in text. - xBorder = xDialog.getChild("edit_margin") + # Get elements in the Dialog Box + xURL = xDialog.getChild("edit_text") + xECC_Low = xDialog.getChild("button_low") #How radio button input is written in text. + xBorder = xDialog.getChild("edit_margin") - type_text(xURL, "www.libreoffice.org") #set the QR code - xECC_Low.executeAction("CLICK", tuple()) - xBorder.executeAction("UP", tuple()) - xBorder.executeAction("DOWN", tuple()) - xOKBtn = xDialog.getChild("ok") - xOKBtn.executeAction("CLICK", tuple()) + type_text(xURL, "www.libreoffice.org") #set the QR code + xECC_Low.executeAction("CLICK", tuple()) + xBorder.executeAction("UP", tuple()) + xBorder.executeAction("DOWN", tuple()) # check the QR code in the document self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Payload, "www.libreoffice.org") @@ -57,19 +51,16 @@ class insertQrCode(UITestCase): gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() - self.ui_test.execute_dialog_through_command(".uno:InsertQrCode") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertQrCode") as xDialog: - xURL = xDialog.getChild("edit_text") - xECC_Low = xDialog.getChild("button_low") - xBorder = xDialog.getChild("edit_margin") + xURL = xDialog.getChild("edit_text") + xECC_Low = xDialog.getChild("button_low") + xBorder = xDialog.getChild("edit_margin") - type_text(xURL, "www.libreoffice.org") #set the QR code - xECC_Low.executeAction("CLICK", tuple()) - xBorder.executeAction("UP", tuple()) - xBorder.executeAction("DOWN", tuple()) - xOKBtn = xDialog.getChild("ok") - xOKBtn.executeAction("CLICK", tuple()) + type_text(xURL, "www.libreoffice.org") #set the QR code + xECC_Low.executeAction("CLICK", tuple()) + xBorder.executeAction("UP", tuple()) + xBorder.executeAction("DOWN", tuple()) #check the QR Code in the document self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Payload, "www.libreoffice.org") diff --git a/sc/qa/uitest/calc_tests3/tdf57274.py b/sc/qa/uitest/calc_tests3/tdf57274.py index 135a83a223dd..4937a9b42afb 100644 --- a/sc/qa/uitest/calc_tests3/tdf57274.py +++ b/sc/qa/uitest/calc_tests3/tdf57274.py @@ -22,16 +22,14 @@ class tdf57274(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B6:E6"})) self.xUITest.executeCommand(".uno:Copy") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B11"})) - self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") - xDialog = self.xUITest.getTopFocusWindow() - #We paste here using Paste Special with 'Link' Checkbox activated - xLink = xDialog.getChild("link") - xLink.executeAction("CLICK", tuple()) - xOkBtn = xDialog.getChild("ok") - # self.ui_test.close_dialog_through_button(xOkBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:PasteSpecial", close_button="") as xDialog: + #We paste here using Paste Special with 'Link' Checkbox activated + xLink = xDialog.getChild("link") + xLink.executeAction("CLICK", tuple()) - with self.ui_test.execute_blocking_action(xOkBtn.executeAction, args=('CLICK', ()), close_button="yes"): - pass + xOkBtn = xDialog.getChild("ok") + with self.ui_test.execute_blocking_action(xOkBtn.executeAction, args=('CLICK', ()), close_button="yes"): + pass #we would expect a reference to cell E6 here and a zero being displayed, but the cell is also simply blank. self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 10).getValue(), 0) diff --git a/sc/qa/uitest/calc_tests3/tdf62267.py b/sc/qa/uitest/calc_tests3/tdf62267.py index 68654e8d0062..370eefb3ca5e 100644 --- a/sc/qa/uitest/calc_tests3/tdf62267.py +++ b/sc/qa/uitest/calc_tests3/tdf62267.py @@ -23,26 +23,21 @@ class tdf62267(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:Copy") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") - xDialog = self.xUITest.getTopFocusWindow() - #it's the default - text, numbers and dates - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:PasteSpecial") as xDialog: + #it's the default - text, numbers and dates + pass #--> Cell formatting should stay as before - self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") + with self.ui_test.execute_dialog_through_command_guarded(".uno:ConditionalFormatManagerDialog", close_button="cancel") as xCondFormatMgr: - xCondFormatMgr = self.xUITest.getTopFocusWindow() - # check that we have exactly 1 conditional format - xList = xCondFormatMgr.getChild("CONTAINER") - list_state = get_state_as_dict(xList) - self.assertEqual(list_state['Children'], '1') + # check that we have exactly 1 conditional format + xList = xCondFormatMgr.getChild("CONTAINER") + list_state = get_state_as_dict(xList) + self.assertEqual(list_state['Children'], '1') - xTreeEntry = xList.getChild('0') - self.assertEqual(get_state_as_dict(xTreeEntry)["Text"], "A1\tCell value = 1") + xTreeEntry = xList.getChild('0') + self.assertEqual(get_state_as_dict(xTreeEntry)["Text"], "A1\tCell value = 1") - xCancelBtn = xCondFormatMgr.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf63805.py b/sc/qa/uitest/calc_tests3/tdf63805.py index 9f9d9baeca75..1eebbc898420 100644 --- a/sc/qa/uitest/calc_tests3/tdf63805.py +++ b/sc/qa/uitest/calc_tests3/tdf63805.py @@ -24,10 +24,8 @@ class tdf63805(UITestCase): #2 - Select A1:A20 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A20"})) #3 - Edit -> fill -> Series -> Down - Date-Month-Increment=1 <ok> - self.ui_test.execute_dialog_through_command(".uno:FillSeries") - xDialog = self.xUITest.getTopFocusWindow() - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries"): + pass #5 -Expected: All Cells show last day of month / Actual: some months skipped self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getValue(), 41213) self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getValue(), 41243) diff --git a/sc/qa/uitest/calc_tests3/tdf65856.py b/sc/qa/uitest/calc_tests3/tdf65856.py index 5d08e89bc774..56c1bc397c19 100644 --- a/sc/qa/uitest/calc_tests3/tdf65856.py +++ b/sc/qa/uitest/calc_tests3/tdf65856.py @@ -21,14 +21,11 @@ class tdf65856(UITestCase): self.xUITest.executeCommand(".uno:Copy") #mark cell D1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) - self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:PasteSpecial") as xDialog: - xmove_right = xDialog.getChild("move_right") - xmove_right.executeAction("CLICK", tuple()) + xmove_right = xDialog.getChild("move_right") + xmove_right.executeAction("CLICK", tuple()) - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) #check self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "T1") @@ -56,14 +53,11 @@ class tdf65856(UITestCase): self.xUITest.executeCommand(".uno:Copy") #mark cell B2 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) - self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:PasteSpecial") as xDialog: - xmove_right = xDialog.getChild("move_right") - xmove_right.executeAction("CLICK", tuple()) + xmove_right = xDialog.getChild("move_right") + xmove_right.executeAction("CLICK", tuple()) - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) #check self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 1).getString(), "1") diff --git a/sc/qa/uitest/calc_tests3/tdf69450.py b/sc/qa/uitest/calc_tests3/tdf69450.py index 2951b385b8ca..e5be3998ed5e 100644 --- a/sc/qa/uitest/calc_tests3/tdf69450.py +++ b/sc/qa/uitest/calc_tests3/tdf69450.py @@ -23,21 +23,18 @@ class tdf69450(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:Copy") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) - self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:PasteSpecial") as xDialog: - xtext = xDialog.getChild("text") - xnumbers = xDialog.getChild("numbers") - xdatetime = xDialog.getChild("datetime") - xformats = xDialog.getChild("formats") + xtext = xDialog.getChild("text") + xnumbers = xDialog.getChild("numbers") + xdatetime = xDialog.getChild("datetime") + xformats = xDialog.getChild("formats") - xtext.executeAction("CLICK", tuple()) - xnumbers.executeAction("CLICK", tuple()) - xdatetime.executeAction("CLICK", tuple()) - xformats.executeAction("CLICK", tuple()) + xtext.executeAction("CLICK", tuple()) + xnumbers.executeAction("CLICK", tuple()) + xdatetime.executeAction("CLICK", tuple()) + xformats.executeAction("CLICK", tuple()) - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) #check B1 text self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "B") @@ -46,11 +43,8 @@ class tdf69450(UITestCase): self.xUITest.executeCommand(".uno:Bold") self.xUITest.executeCommand(".uno:Copy") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) - self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") - xDialog = self.xUITest.getTopFocusWindow() #previous settings should be remembered (only format) - - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:PasteSpecial"): + pass #check B1 text self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "B") diff --git a/sc/qa/uitest/calc_tests3/tdf69981.py b/sc/qa/uitest/calc_tests3/tdf69981.py index 6d4a548713f3..c553d2eb6fae 100644 --- a/sc/qa/uitest/calc_tests3/tdf69981.py +++ b/sc/qa/uitest/calc_tests3/tdf69981.py @@ -17,35 +17,31 @@ class tdf69981(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xWriterEntry = xPages.getChild('3') # Calc - xWriterEntry.executeAction("EXPAND", tuple()) - xWriterGeneralEntry = xWriterEntry.getChild('0') - xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb - xreplwarncb = xDialogOpt.getChild("replwarncb") - if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": - xreplwarncb.executeAction("CLICK", tuple()) - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) #Select A2:A7 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A7"})) #Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - xtab = xDialog.getChild("tab") - xcomma = xDialog.getChild("comma") - xtab.executeAction("CLICK", tuple()) - xcomma.executeAction("CLICK", tuple()) - #Click Ok - #overwrite warning come up - #press Ok. - xOK = xDialog.getChild("ok") - with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes"): - pass + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns", close_button="") as xDialog: + xtab = xDialog.getChild("tab") + xcomma = xDialog.getChild("comma") + xtab.executeAction("CLICK", tuple()) + xcomma.executeAction("CLICK", tuple()) + #Click Ok + #overwrite warning come up + #press Ok. + xOK = xDialog.getChild("ok") + with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes"): + pass #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "Original") diff --git a/sc/qa/uitest/calc_tests3/tdf73006.py b/sc/qa/uitest/calc_tests3/tdf73006.py index 558367e6e6fb..76e279c4757f 100644 --- a/sc/qa/uitest/calc_tests3/tdf73006.py +++ b/sc/qa/uitest/calc_tests3/tdf73006.py @@ -24,14 +24,11 @@ class tdf73006(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:SelectColumn") # Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - xspace = xDialog.getChild("space") - if (get_state_as_dict(xspace)["Selected"]) == "false": - xspace.executeAction("CLICK", tuple()) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns") as xDialog: + xspace = xDialog.getChild("space") + if (get_state_as_dict(xspace)["Selected"]) == "false": + xspace.executeAction("CLICK", tuple()) + # Click Ok #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "A") diff --git a/sc/qa/uitest/calc_tests3/tdf79983.py b/sc/qa/uitest/calc_tests3/tdf79983.py index c90561cee034..82fe9056f597 100644 --- a/sc/qa/uitest/calc_tests3/tdf79983.py +++ b/sc/qa/uitest/calc_tests3/tdf79983.py @@ -25,22 +25,19 @@ class tdf79983(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) #Tools / Options / LibreOffice Calc / Sort Lists - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xCalcEntry = xPages.getChild('3') # Calc - xCalcEntry.executeAction("EXPAND", tuple()) - xCalcSortEntry = xCalcEntry.getChild('5') - xCalcSortEntry.executeAction("SELECT", tuple()) #Sort List - #copy new list from selected cells - xcopy = xDialogOpt.getChild("copy") - xcopy.executeAction("CLICK", tuple()) + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') # Calc + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcSortEntry = xCalcEntry.getChild('5') + xCalcSortEntry.executeAction("SELECT", tuple()) #Sort List + #copy new list from selected cells + xcopy = xDialogOpt.getChild("copy") + xcopy.executeAction("CLICK", tuple()) - self.assertEqual("AAA\nBBB\nCCC\nDDD", get_state_as_dict(xDialogOpt.getChild("entries"))['Text']) + self.assertEqual("AAA\nBBB\nCCC\nDDD", get_state_as_dict(xDialogOpt.getChild("entries"))['Text']) - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DELETE"})) @@ -48,12 +45,9 @@ class tdf79983(UITestCase): enter_text_to_cell(gridwin, "A1", "AAA") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) #fill down - self.ui_test.execute_dialog_through_command(".uno:FillSeries") - xDialog = self.xUITest.getTopFocusWindow() - xautofill = xDialog.getChild("autofill") - xautofill.executeAction("CLICK", tuple()) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries") as xDialog: + xautofill = xDialog.getChild("autofill") + xautofill.executeAction("CLICK", tuple()) #verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "AAA") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "BBB") diff --git a/sc/qa/uitest/calc_tests3/tdf82398.py b/sc/qa/uitest/calc_tests3/tdf82398.py index 6cf2e8c671d0..1e3b4268e2bf 100644 --- a/sc/qa/uitest/calc_tests3/tdf82398.py +++ b/sc/qa/uitest/calc_tests3/tdf82398.py @@ -27,17 +27,14 @@ class tdf82398(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) self.xUITest.executeCommand(".uno:NumberFormatDate") # Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - xother = xDialog.getChild("other") - xinputother = xDialog.getChild("inputother") + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns") as xDialog: + xother = xDialog.getChild("other") + xinputother = xDialog.getChild("inputother") - if (get_state_as_dict(xother)["Selected"]) == "false": - xother.executeAction("CLICK", tuple()) - xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + if (get_state_as_dict(xother)["Selected"]) == "false": + xother.executeAction("CLICK", tuple()) + xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) + # Click Ok #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "afasdfs") diff --git a/sc/qa/uitest/calc_tests4/tdf131170.py b/sc/qa/uitest/calc_tests4/tdf131170.py index 8f558f78fef6..508fc7d97aa3 100644 --- a/sc/qa/uitest/calc_tests4/tdf131170.py +++ b/sc/qa/uitest/calc_tests4/tdf131170.py @@ -13,36 +13,33 @@ class tdf131170(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") - self.ui_test.execute_dialog_through_command(".uno:DefineLabelRange") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:DefineLabelRange") as xDialog: - xRange = xDialog.getChild("range") - self.assertEqual(4, len(xRange.getChildren())) - self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") - self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "$Sheet1.$I$6:$K$6 [AA, BB, CC]") - self.assertEqual(get_state_as_dict(xRange.getChild('2'))["Text"].strip(), "--- Row ---") - self.assertEqual(get_state_as_dict(xRange.getChild('3'))["Text"].strip(), "$Sheet1.$H$7:$H$9 [X, Y, Z]") + xRange = xDialog.getChild("range") + self.assertEqual(4, len(xRange.getChildren())) + self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") + self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "$Sheet1.$I$6:$K$6 [AA, BB, CC]") + self.assertEqual(get_state_as_dict(xRange.getChild('2'))["Text"].strip(), "--- Row ---") + self.assertEqual(get_state_as_dict(xRange.getChild('3'))["Text"].strip(), "$Sheet1.$H$7:$H$9 [X, Y, Z]") - xDeleteBtn = xDialog.getChild("delete") + xDeleteBtn = xDialog.getChild("delete") - xRange.getChild('1').executeAction("SELECT", tuple()) - with self.ui_test.execute_blocking_action(xDeleteBtn.executeAction, args=('CLICK', ()), close_button="yes"): - pass + xRange.getChild('1').executeAction("SELECT", tuple()) + with self.ui_test.execute_blocking_action(xDeleteBtn.executeAction, args=('CLICK', ()), close_button="yes"): + pass - self.assertEqual(3, len(xRange.getChildren())) - self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") - self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "--- Row ---") - self.assertEqual(get_state_as_dict(xRange.getChild('2'))["Text"].strip(), "$Sheet1.$H$7:$H$9 [X, Y, Z]") + self.assertEqual(3, len(xRange.getChildren())) + self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") + self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "--- Row ---") + self.assertEqual(get_state_as_dict(xRange.getChild('2'))["Text"].strip(), "$Sheet1.$H$7:$H$9 [X, Y, Z]") - xRange.getChild('2').executeAction("SELECT", tuple()) - with self.ui_test.execute_blocking_action(xDeleteBtn.executeAction, args=('CLICK', ()), close_button="yes"): - pass + xRange.getChild('2').executeAction("SELECT", tuple()) + with self.ui_test.execute_blocking_action(xDeleteBtn.executeAction, args=('CLICK', ()), close_button="yes"): + pass - self.assertEqual(2, len(xRange.getChildren())) - self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") - self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "--- Row ---") + self.assertEqual(2, len(xRange.getChildren())) + self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") + self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "--- Row ---") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf85403.py b/sc/qa/uitest/calc_tests4/tdf85403.py index a09475c98838..fb17610d4839 100644 --- a/sc/qa/uitest/calc_tests4/tdf85403.py +++ b/sc/qa/uitest/calc_tests4/tdf85403.py @@ -22,11 +22,8 @@ class tdf85403(UITestCase): #putting a new SUM(A1) in C1 will show 123 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) # Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns"): + pass #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 0).getValue(), 123) diff --git a/sc/qa/uitest/calc_tests4/tdf85979.py b/sc/qa/uitest/calc_tests4/tdf85979.py index 48052fdc1e6a..1e2e6bb63962 100644 --- a/sc/qa/uitest/calc_tests4/tdf85979.py +++ b/sc/qa/uitest/calc_tests4/tdf85979.py @@ -20,14 +20,11 @@ class tdf85979(UITestCase): #(I selected C1 to C5, then Text to Columns, unselected "Tab" and selected "Space") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:C5"})) # Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - xspace = xDialog.getChild("space") - if (get_state_as_dict(xspace)["Selected"]) == "false": - xspace.executeAction("CLICK", tuple()) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns") as xDialog: + xspace = xDialog.getChild("space") + if (get_state_as_dict(xspace)["Selected"]) == "false": + xspace.executeAction("CLICK", tuple()) + # Click Ok #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 0).getValue(), 99) diff --git a/sc/qa/uitest/calc_tests4/tdf86253.py b/sc/qa/uitest/calc_tests4/tdf86253.py index da35ac663ad4..eb815f5080b7 100644 --- a/sc/qa/uitest/calc_tests4/tdf86253.py +++ b/sc/qa/uitest/calc_tests4/tdf86253.py @@ -19,37 +19,31 @@ class tdf86253(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) self.xUITest.executeCommand(".uno:Copy") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:C17"})) - self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:PasteSpecial") as xDialog: - xtext = xDialog.getChild("text") - xnumbers = xDialog.getChild("numbers") - xdatetime = xDialog.getChild("datetime") - xformats = xDialog.getChild("formats") + xtext = xDialog.getChild("text") + xnumbers = xDialog.getChild("numbers") + xdatetime = xDialog.getChild("datetime") + xformats = xDialog.getChild("formats") - xtext.executeAction("CLICK", tuple()) - xnumbers.executeAction("CLICK", tuple()) - xdatetime.executeAction("CLICK", tuple()) - xformats.executeAction("CLICK", tuple()) + xtext.executeAction("CLICK", tuple()) + xnumbers.executeAction("CLICK", tuple()) + xdatetime.executeAction("CLICK", tuple()) + xformats.executeAction("CLICK", tuple()) - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) #--> Cell formatting for C1:C17 is changed. But, if you go to "Format - Conditional Formatting - Manage", #you will see that a new formatting condition is created with the range "C1:C6", rather than "C1:C17". This is wrong behavior. - self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") + with self.ui_test.execute_dialog_through_command_guarded(".uno:ConditionalFormatManagerDialog", close_button="cancel") as xCondFormatMgr: - xCondFormatMgr = self.xUITest.getTopFocusWindow() - # check that we have exactly 1 conditional format and range is C1:C17 - xList = xCondFormatMgr.getChild("CONTAINER") - list_state = get_state_as_dict(xList) - self.assertEqual(list_state['Children'], '1') + # check that we have exactly 1 conditional format and range is C1:C17 + xList = xCondFormatMgr.getChild("CONTAINER") + list_state = get_state_as_dict(xList) + self.assertEqual(list_state['Children'], '1') - xTreeEntry = xList.getChild('0') - self.assertEqual(get_state_as_dict(xTreeEntry)["Text"], "A1:A6,C1:C17\tCell value >= 0") + xTreeEntry = xList.getChild('0') + self.assertEqual(get_state_as_dict(xTreeEntry)["Text"], "A1:A6,C1:C17\tCell value >= 0") - xCancelBtn = xCondFormatMgr.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf88999.py b/sc/qa/uitest/calc_tests4/tdf88999.py index 4f27a34d85f5..40300f8c31c6 100644 --- a/sc/qa/uitest/calc_tests4/tdf88999.py +++ b/sc/qa/uitest/calc_tests4/tdf88999.py @@ -23,26 +23,23 @@ class tdf88999(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab Numbers - xliststore1 = xDialog.getChild("categorylb") #1st list / Category - xliststore2 = xDialog.getChild("formatlb") #2nd list / Format - xdecimalsed = xDialog.getChild("decimalsed") - xleadzerosed = xDialog.getChild("leadzerosed") - xnegnumred = xDialog.getChild("negnumred") - xthousands = xDialog.getChild("thousands") - xlanguagelb = xDialog.getChild("languagelb") - xformatted = xDialog.getChild("formatted") + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") - self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Scientific") - self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "2") - self.assertEqual(get_state_as_dict(xdecimalsed)["Enabled"], "true") - self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "1") - self.assertEqual(get_state_as_dict(xformatted)["Text"], "0.00E+00") - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Scientific") + self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "2") + self.assertEqual(get_state_as_dict(xdecimalsed)["Enabled"], "true") + self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "1") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "0.00E+00") self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests4/tdf89907.py b/sc/qa/uitest/calc_tests4/tdf89907.py index 5e0cde458670..aaa6b7cc4523 100644 --- a/sc/qa/uitest/calc_tests4/tdf89907.py +++ b/sc/qa/uitest/calc_tests4/tdf89907.py @@ -29,16 +29,13 @@ class tdf89907(UITestCase): #Optimal Width self.xUITest.executeCommand(".uno:SetOptimalColumnWidthDirect") # Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - xother = xDialog.getChild("other") - xinputother = xDialog.getChild("inputother") - if (get_state_as_dict(xother)["Selected"]) == "false": - xother.executeAction("CLICK", tuple()) - xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns") as xDialog: + xother = xDialog.getChild("other") + xinputother = xDialog.getChild("inputother") + if (get_state_as_dict(xother)["Selected"]) == "false": + xother.executeAction("CLICK", tuple()) + xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) + # Click Ok #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "afasdfs") diff --git a/sc/qa/uitest/calc_tests4/tdf92423.py b/sc/qa/uitest/calc_tests4/tdf92423.py index c5bde52e2468..f374a0d2f9ff 100644 --- a/sc/qa/uitest/calc_tests4/tdf92423.py +++ b/sc/qa/uitest/calc_tests4/tdf92423.py @@ -19,19 +19,16 @@ class tdf92423(UITestCase): document = self.ui_test.get_component() #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xWriterEntry = xPages.getChild('3') # Calc - xWriterEntry.executeAction("EXPAND", tuple()) - xWriterGeneralEntry = xWriterEntry.getChild('0') - xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb - xreplwarncb = xDialogOpt.getChild("replwarncb") - if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": - xreplwarncb.executeAction("CLICK", tuple()) - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) #enter data enter_text_to_cell(gridwin, "A1", "1;2") enter_text_to_cell(gridwin, "A2", "2;3") @@ -51,14 +48,11 @@ class tdf92423(UITestCase): gridWinState = get_state_as_dict(gridwin) self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A7:Sheet1.A9") # Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - xSemicolon = xDialog.getChild("semicolon") #check semicolon checkbox - if (get_state_as_dict(xSemicolon)["Selected"]) == "false": - xSemicolon.executeAction("CLICK", tuple()) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns") as xDialog: + xSemicolon = xDialog.getChild("semicolon") #check semicolon checkbox + if (get_state_as_dict(xSemicolon)["Selected"]) == "false": + xSemicolon.executeAction("CLICK", tuple()) + # Click Ok #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 6).getValue(), 1) diff --git a/sc/qa/uitest/calc_tests4/textToColumns.py b/sc/qa/uitest/calc_tests4/textToColumns.py index fac0666452b3..f7948ba29c87 100644 --- a/sc/qa/uitest/calc_tests4/textToColumns.py +++ b/sc/qa/uitest/calc_tests4/textToColumns.py @@ -19,45 +19,41 @@ class CalcTextToColumns(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() - - xPages = xDialogOpt.getChild("pages") - xWriterEntry = xPages.getChild('3') # Calc - xWriterEntry.executeAction("EXPAND", tuple()) - xWriterGeneralEntry = xWriterEntry.getChild('0') - xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb - xreplwarncb = xDialogOpt.getChild("replwarncb") - print(get_state_as_dict(xreplwarncb)["Selected"]) - if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": - xreplwarncb.executeAction("CLICK", tuple()) - print(get_state_as_dict(xreplwarncb)["Selected"]) - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + print(get_state_as_dict(xreplwarncb)["Selected"]) + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) + print(get_state_as_dict(xreplwarncb)["Selected"]) #Select A1:A5 on Sheet 'Dot_as_Separator' gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) #Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - #Untag Tab as separator and tag other. Put a dot into the input field next to the other checkbox - xtab = xDialog.getChild("tab") - xcomma = xDialog.getChild("comma") - xsemicolon = xDialog.getChild("semicolon") - xspace = xDialog.getChild("space") - xother = xDialog.getChild("other") - xinputother = xDialog.getChild("inputother") - - if (get_state_as_dict(xother)["Selected"]) == "false": - xother.executeAction("CLICK", tuple()) - xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) - #Click Ok - #Does an overwrite warning come up? If not file an Issue. - #Tag the 'Do not show warning again' checkbox and press Ok. - xOK = xDialog.getChild("ok") - with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes") as dialog: - xask = dialog.getChild("ask") - xask.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns", close_button="") as xDialog: + #Untag Tab as separator and tag other. Put a dot into the input field next to the other checkbox + xtab = xDialog.getChild("tab") + xcomma = xDialog.getChild("comma") + xsemicolon = xDialog.getChild("semicolon") + xspace = xDialog.getChild("space") + xother = xDialog.getChild("other") + xinputother = xDialog.getChild("inputother") + + if (get_state_as_dict(xother)["Selected"]) == "false": + xother.executeAction("CLICK", tuple()) + xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) + #Click Ok + #Does an overwrite warning come up? If not file an Issue. + #Tag the 'Do not show warning again' checkbox and press Ok. + xOK = xDialog.getChild("ok") + with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes") as dialog: + xask = dialog.getChild("ask") + xask.executeAction("CLICK", tuple()) #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getValue(), 1) @@ -95,19 +91,17 @@ class CalcTextToColumns(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 2).getValue(), 0) self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 3).getValue(), 0) self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 4).getString(), "random content") + #verify setting in options - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() - - xPages = xDialogOpt.getChild("pages") - xWriterEntry = xPages.getChild('3') # Calc - xWriterEntry.executeAction("EXPAND", tuple()) - xWriterGeneralEntry = xWriterEntry.getChild('0') - xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb - xreplwarncb = xDialogOpt.getChild("replwarncb") - self.assertEqual(get_state_as_dict(xreplwarncb)["Selected"], "false") - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + self.assertEqual(get_state_as_dict(xreplwarncb)["Selected"], "false") def test_text_to_columns_comma(self): #Comma as Separator @@ -115,36 +109,32 @@ class CalcTextToColumns(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() - - xPages = xDialogOpt.getChild("pages") - xWriterEntry = xPages.getChild('3') # Calc - xWriterEntry.executeAction("EXPAND", tuple()) - xWriterGeneralEntry = xWriterEntry.getChild('0') - xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb - xreplwarncb = xDialogOpt.getChild("replwarncb") - print(get_state_as_dict(xreplwarncb)["Selected"]) - if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": - xreplwarncb.executeAction("CLICK", tuple()) - print(get_state_as_dict(xreplwarncb)["Selected"]) - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + print(get_state_as_dict(xreplwarncb)["Selected"]) + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) + print(get_state_as_dict(xreplwarncb)["Selected"]) # Select A1:A5 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) # Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - # Untag Tab as separator and tag comma. - xComma = xDialog.getChild("comma") - if (get_state_as_dict(xComma)["Selected"]) == "false": - xComma.executeAction("CLICK", tuple()) - # Click Ok - xOK = xDialog.getChild("ok") - - with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes"): - pass + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns", close_button="") as xDialog: + # Untag Tab as separator and tag comma. + xComma = xDialog.getChild("comma") + if (get_state_as_dict(xComma)["Selected"]) == "false": + xComma.executeAction("CLICK", tuple()) + # Click Ok + + xOK = xDialog.getChild("ok") + with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes"): + pass #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getValue(), 1) @@ -183,40 +173,35 @@ class CalcTextToColumns(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 3).getValue(), 0) self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 4).getString(), "random content") - def test_text_to_columns_semicolon(self): - #Semicolon as Separator - with self.ui_test.load_file(get_url_for_data_file("text_to_columns_semicolon.ods")) as calc_doc: - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() - - xPages = xDialogOpt.getChild("pages") - xWriterEntry = xPages.getChild('3') # Calc - xWriterEntry.executeAction("EXPAND", tuple()) - xWriterGeneralEntry = xWriterEntry.getChild('0') - xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb - xreplwarncb = xDialogOpt.getChild("replwarncb") - if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": - xreplwarncb.executeAction("CLICK", tuple()) - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + def test_text_to_columns_semicolon(self): + #Semicolon as Separator + with self.ui_test.load_file(get_url_for_data_file("text_to_columns_semicolon.ods")) as calc_doc: + gridwin = xCalcDoc.getChild("grid_window") + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) # Select A1:A5 on Sheet gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) # Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - # Untag comma as separator and tag Semicolon - xSemicolon = xDialog.getChild("semicolon") - if (get_state_as_dict(xSemicolon)["Selected"]) == "false": - xSemicolon.executeAction("CLICK", tuple()) - # Click Ok - xOK = xDialog.getChild("ok") - - with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes"): - pass + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns", close_button="") as xDialog: + # Untag comma as separator and tag Semicolon + xSemicolon = xDialog.getChild("semicolon") + if (get_state_as_dict(xSemicolon)["Selected"]) == "false": + xSemicolon.executeAction("CLICK", tuple()) + # Click Ok + + xOK = xDialog.getChild("ok") + with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes"): + pass #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getValue(), 1) @@ -255,41 +240,36 @@ class CalcTextToColumns(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 3).getValue(), 0) self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 4).getString(), "random content") - def test_text_to_columns_space(self): - #Space as Separator - with self.ui_test.load_file(get_url_for_data_file("text_to_columns_space.ods")) as calc_doc: - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() - - xPages = xDialogOpt.getChild("pages") - xWriterEntry = xPages.getChild('3') # Calc - xWriterEntry.executeAction("EXPAND", tuple()) - xWriterGeneralEntry = xWriterEntry.getChild('0') - xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb - xreplwarncb = xDialogOpt.getChild("replwarncb") - if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": - xreplwarncb.executeAction("CLICK", tuple()) - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + def test_text_to_columns_space(self): + #Space as Separator + with self.ui_test.load_file(get_url_for_data_file("text_to_columns_space.ods")) as calc_doc: + gridwin = xCalcDoc.getChild("grid_window") + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) # Select A1:A5 on Sheet gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) # Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - # Untag comma as separator and tag Semicolon - xSpace = xDialog.getChild("space") - if (get_state_as_dict(xSpace)["Selected"]) == "false": - xSpace.executeAction("CLICK", tuple()) - # xspace.executeAction("CLICK", tuple()) - # Click Ok - xOK = xDialog.getChild("ok") - - with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes"): - pass + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns", close_button="") as xDialog: + # Untag comma as separator and tag Semicolon + xSpace = xDialog.getChild("space") + if (get_state_as_dict(xSpace)["Selected"]) == "false": + xSpace.executeAction("CLICK", tuple()) + # xspace.executeAction("CLICK", tuple()) + # Click Ok + + xOK = xDialog.getChild("ok") + with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes"): + pass #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getValue(), 1) @@ -328,47 +308,42 @@ class CalcTextToColumns(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 3).getValue(), 0) self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 4).getString(), "random content") - def test_text_to_columns_pipe(self): - #Space as Separator - with self.ui_test.load_file(get_url_for_data_file("text_to_columns_pipe.ods")) as calc_doc: - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() - - xPages = xDialogOpt.getChild("pages") - xWriterEntry = xPages.getChild('3') # Calc - xWriterEntry.executeAction("EXPAND", tuple()) - xWriterGeneralEntry = xWriterEntry.getChild('0') - xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb - xreplwarncb = xDialogOpt.getChild("replwarncb") - if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": - xreplwarncb.executeAction("CLICK", tuple()) - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + def test_text_to_columns_pipe(self): + #Space as Separator + with self.ui_test.load_file(get_url_for_data_file("text_to_columns_pipe.ods")) as calc_doc: + gridwin = xCalcDoc.getChild("grid_window") + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) # Select A1:A5 on Sheet gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) # Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - # Untag comma as separator and tag Semicolon - xtab = xDialog.getChild("tab") - xcomma = xDialog.getChild("comma") - xsemicolon = xDialog.getChild("semicolon") - xspace = xDialog.getChild("space") - xother = xDialog.getChild("other") - xinputother = xDialog.getChild("inputother") - xSpace = xDialog.getChild("space") - if (get_state_as_dict(xother)["Selected"]) == "false": - xother.executeAction("CLICK", tuple()) - xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"|"})) - # Click Ok - xOK = xDialog.getChild("ok") - - with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes"): - pass + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns", close_button="") as xDialog: + # Untag comma as separator and tag Semicolon + xtab = xDialog.getChild("tab") + xcomma = xDialog.getChild("comma") + xsemicolon = xDialog.getChild("semicolon") + xspace = xDialog.getChild("space") + xother = xDialog.getChild("other") + xinputother = xDialog.getChild("inputother") + xSpace = xDialog.getChild("space") + if (get_state_as_dict(xother)["Selected"]) == "false": + xother.executeAction("CLICK", tuple()) + xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"|"})) + # Click Ok + + xOK = xDialog.getChild("ok") + with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes"): + pass #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getValue(), 1) @@ -407,48 +382,42 @@ class CalcTextToColumns(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 3).getValue(), 0) self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 4).getString(), "random content") - def test_text_to_columns_pipespace(self): - #Space as Separator - with self.ui_test.load_file(get_url_for_data_file("text_to_columns_pipe_space.ods")) as calc_doc: - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() - - xPages = xDialogOpt.getChild("pages") - xWriterEntry = xPages.getChild('3') # Calc - xWriterEntry.executeAction("EXPAND", tuple()) - xWriterGeneralEntry = xWriterEntry.getChild('0') - xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb - xreplwarncb = xDialogOpt.getChild("replwarncb") - if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": - xreplwarncb.executeAction("CLICK", tuple()) - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + def test_text_to_columns_pipespace(self): + #Space as Separator + with self.ui_test.load_file(get_url_for_data_file("text_to_columns_pipe_space.ods")) as calc_doc: + gridwin = xCalcDoc.getChild("grid_window") + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) # Select A1:A5 on Sheet gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) # Data - Text to Columns - self.ui_test.execute_dialog_through_command(".uno:TextToColumns") - xDialog = self.xUITest.getTopFocusWindow() - # - xtab = xDialog.getChild("tab") - xcomma = xDialog.getChild("comma") - xsemicolon = xDialog.getChild("semicolon") - xspace = xDialog.getChild("space") - xother = xDialog.getChild("other") - xinputother = xDialog.getChild("inputother") - if (get_state_as_dict(xspace)["Selected"]) == "false": - xspace.executeAction("CLICK", tuple()) - if (get_state_as_dict(xother)["Selected"]) == "false": - xother.executeAction("CLICK", tuple()) - xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"|"})) - # Click Ok - xOK = xDialog.getChild("ok") - - with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes"): - pass + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextToColumns", close_button="") as xDialog: + xtab = xDialog.getChild("tab") + xcomma = xDialog.getChild("comma") + xsemicolon = xDialog.getChild("semicolon") + xspace = xDialog.getChild("space") + xother = xDialog.getChild("other") + xinputother = xDialog.getChild("inputother") + if (get_state_as_dict(xspace)["Selected"]) == "false": + xspace.executeAction("CLICK", tuple()) + if (get_state_as_dict(xother)["Selected"]) == "false": + xother.executeAction("CLICK", tuple()) + xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"|"})) + # Click Ok + + xOK = xDialog.getChild("ok") + with self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), close_button="yes"): + pass #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getValue(), 1) @@ -486,4 +455,5 @@ class CalcTextToColumns(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 2).getValue(), 0) self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 3).getValue(), 0) self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 4).getString(), "random content") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/trackedChanges.py b/sc/qa/uitest/calc_tests4/trackedChanges.py index e9e54206faa7..e6d29efa87e2 100644 --- a/sc/qa/uitest/calc_tests4/trackedChanges.py +++ b/sc/qa/uitest/calc_tests4/trackedChanges.py @@ -47,21 +47,15 @@ class CalcTrackedChanges(UITestCase): document = self.ui_test.get_component() self.xUITest.executeCommand(".uno:TraceChangeMode") #protect dialog - self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode") - xDialog = self.xUITest.getTopFocusWindow() - xpass = xDialog.getChild("pass1ed") - xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) - xconfirm = xDialog.getChild("confirm1ed") - xconfirm.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ProtectTraceChangeMode") as xDialog: + xpass = xDialog.getChild("pass1ed") + xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + xconfirm = xDialog.getChild("confirm1ed") + xconfirm.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) #verify password - self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode") - xDialog = self.xUITest.getTopFocusWindow() - xpass = xDialog.getChild("pass1ed") - xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ProtectTraceChangeMode") as xDialog: + xpass = xDialog.getChild("pass1ed") + xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests6/autoFormat.py b/sc/qa/uitest/calc_tests6/autoFormat.py index 362a42a6a411..0744d0d397ac 100644 --- a/sc/qa/uitest/calc_tests6/autoFormat.py +++ b/sc/qa/uitest/calc_tests6/autoFormat.py @@ -18,57 +18,51 @@ class autoFormat(UITestCase): #select A1:C5 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C5"})) #AutoFormat Styles - self.ui_test.execute_dialog_through_command(".uno:AutoFormat") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:AutoFormat") as xDialog: - formatlb = xDialog.getChild("formatlb") - numformatcb = xDialog.getChild("numformatcb") - bordercb = xDialog.getChild("bordercb") - fontcb = xDialog.getChild("fontcb") - patterncb = xDialog.getChild("patterncb") - alignmentcb = xDialog.getChild("alignmentcb") - autofitcb = xDialog.getChild("autofitcb") + formatlb = xDialog.getChild("formatlb") + numformatcb = xDialog.getChild("numformatcb") + bordercb = xDialog.getChild("bordercb") + fontcb = xDialog.getChild("fontcb") + patterncb = xDialog.getChild("patterncb") + alignmentcb = xDialog.getChild("alignmentcb") + autofitcb = xDialog.getChild("autofitcb") - entry = formatlb.getChild("7") #Financial - entry.executeAction("SELECT", tuple()) - numformatcb.executeAction("CLICK", tuple()) - bordercb.executeAction("CLICK", tuple()) - fontcb.executeAction("CLICK", tuple()) - patterncb.executeAction("CLICK", tuple()) - alignmentcb.executeAction("CLICK", tuple()) - autofitcb.executeAction("CLICK", tuple()) + entry = formatlb.getChild("7") #Financial + entry.executeAction("SELECT", tuple()) + numformatcb.executeAction("CLICK", tuple()) + bordercb.executeAction("CLICK", tuple()) + fontcb.executeAction("CLICK", tuple()) + patterncb.executeAction("CLICK", tuple()) + alignmentcb.executeAction("CLICK", tuple()) + autofitcb.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #verify - self.ui_test.execute_dialog_through_command(".uno:AutoFormat") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:AutoFormat") as xDialog: - formatlb = xDialog.getChild("formatlb") - numformatcb = xDialog.getChild("numformatcb") - bordercb = xDialog.getChild("bordercb") - fontcb = xDialog.getChild("fontcb") - patterncb = xDialog.getChild("patterncb") - alignmentcb = xDialog.getChild("alignmentcb") - autofitcb = xDialog.getChild("autofitcb") + formatlb = xDialog.getChild("formatlb") + numformatcb = xDialog.getChild("numformatcb") + bordercb = xDialog.getChild("bordercb") + fontcb = xDialog.getChild("fontcb") + patterncb = xDialog.getChild("patterncb") + alignmentcb = xDialog.getChild("alignmentcb") + autofitcb = xDialog.getChild("autofitcb") - entry = formatlb.getChild("7") #Financial - entry.executeAction("SELECT", tuple()) - self.assertEqual(get_state_as_dict(numformatcb)["Selected"], "false") - self.assertEqual(get_state_as_dict(bordercb)["Selected"], "false") - self.assertEqual(get_state_as_dict(fontcb)["Selected"], "false") - self.assertEqual(get_state_as_dict(patterncb)["Selected"], "false") - self.assertEqual(get_state_as_dict(alignmentcb)["Selected"], "false") - self.assertEqual(get_state_as_dict(autofitcb)["Selected"], "false") - numformatcb.executeAction("CLICK", tuple()) - bordercb.executeAction("CLICK", tuple()) - fontcb.executeAction("CLICK", tuple()) - patterncb.executeAction("CLICK", tuple()) - alignmentcb.executeAction("CLICK", tuple()) - autofitcb.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + entry = formatlb.getChild("7") #Financial + entry.executeAction("SELECT", tuple()) + self.assertEqual(get_state_as_dict(numformatcb)["Selected"], "false") + self.assertEqual(get_state_as_dict(bordercb)["Selected"], "false") + self.assertEqual(get_state_as_dict(fontcb)["Selected"], "false") + self.assertEqual(get_state_as_dict(patterncb)["Selected"], "false") + self.assertEqual(get_state_as_dict(alignmentcb)["Selected"], "false") + self.assertEqual(get_state_as_dict(autofitcb)["Selected"], "false") + numformatcb.executeAction("CLICK", tuple()) + bordercb.executeAction("CLICK", tuple()) + fontcb.executeAction("CLICK", tuple()) + patterncb.executeAction("CLICK", tuple()) + alignmentcb.executeAction("CLICK", tuple()) + autofitcb.executeAction("CLICK", tuple()) self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests6/autocorrectOptions.py b/sc/qa/uitest/calc_tests6/autocorrectOptions.py index 8daa3e537bfb..a3519a1dcd2e 100644 --- a/sc/qa/uitest/calc_tests6/autocorrectOptions.py +++ b/sc/qa/uitest/calc_tests6/autocorrectOptions.py @@ -17,84 +17,81 @@ class autocorrectOptions(UITestCase): gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() - self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab replace - origtext = xDialog.getChild("origtext") - newtext = xDialog.getChild("newtext") - xnew = xDialog.getChild("new") - xdelete = xDialog.getChild("delete") - xtabview = xDialog.getChild("tabview") - xreset = xDialog.getChild("reset") - nrRows = get_state_as_dict(xtabview)["VisibleCount"] - - self.assertTrue(int(nrRows) > 0) - - #add new rule - origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) - newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) - xnew.executeAction("CLICK", tuple()) - nrRowsNew = get_state_as_dict(xtabview)["VisibleCount"] - nrRowsDiff = int(nrRowsNew) - int(nrRows) - self.assertEqual(nrRowsDiff, 1) #we have +1 rule - #delete rule - origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) - newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) - xdelete.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xtabview)["VisibleCount"], nrRows) #we have default nr of rules - - select_pos(xTabs, "1") #tab Exceptions - #abbreviations - abbrev = xDialog.getChild("abbrev") - newabbrev = xDialog.getChild("newabbrev") - delabbrev = xDialog.getChild("delabbrev") - abbrevlist = xDialog.getChild("abbrevlist") - - nrRowsAbb = get_state_as_dict(abbrevlist)["VisibleCount"] - - self.assertTrue(int(nrRowsAbb) > 0) - - abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - abbrev.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"})) - newabbrev.executeAction("CLICK", tuple()) - nrRowsAbbNew = get_state_as_dict(abbrevlist)["VisibleCount"] - nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb) - self.assertEqual(nrRowsAbbDiff, 1) #we have +1 rule - delabbrev.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(abbrevlist)["VisibleCount"], nrRowsAbb) #we have default nr of rules - - #words with two initial capitals - double = xDialog.getChild("double") - newdouble = xDialog.getChild("newdouble") - deldouble = xDialog.getChild("deldouble") - doublelist = xDialog.getChild("doublelist") - - nrRowsDouble = get_state_as_dict(doublelist)["VisibleCount"] - - self.assertTrue(int(nrRowsDouble) > 0) - - double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - double.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"})) - newdouble.executeAction("CLICK", tuple()) - nrRowsDoubleNew = get_state_as_dict(doublelist)["VisibleCount"] - nrRowsDoubleDiff = int(nrRowsDoubleNew) - int(nrRowsDouble) #convert string and - self.assertEqual(nrRowsDoubleDiff, 1) #we have +1 rule - deldouble.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(doublelist)["VisibleCount"], nrRowsDouble) #we have default nr of rules - - xCancelButton = xDialog.getChild("cancel") - xCancelButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:AutoCorrectDlg", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab replace + origtext = xDialog.getChild("origtext") + newtext = xDialog.getChild("newtext") + xnew = xDialog.getChild("new") + xdelete = xDialog.getChild("delete") + xtabview = xDialog.getChild("tabview") + xreset = xDialog.getChild("reset") + nrRows = get_state_as_dict(xtabview)["VisibleCount"] + + self.assertTrue(int(nrRows) > 0) + + #add new rule + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) + xnew.executeAction("CLICK", tuple()) + nrRowsNew = get_state_as_dict(xtabview)["VisibleCount"] + nrRowsDiff = int(nrRowsNew) - int(nrRows) + self.assertEqual(nrRowsDiff, 1) #we have +1 rule + #delete rule + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) + xdelete.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xtabview)["VisibleCount"], nrRows) #we have default nr of rules + + select_pos(xTabs, "1") #tab Exceptions + #abbreviations + abbrev = xDialog.getChild("abbrev") + newabbrev = xDialog.getChild("newabbrev") + delabbrev = xDialog.getChild("delabbrev") + abbrevlist = xDialog.getChild("abbrevlist") + + nrRowsAbb = get_state_as_dict(abbrevlist)["VisibleCount"] + + self.assertTrue(int(nrRowsAbb) > 0) + + abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + abbrev.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"})) + newabbrev.executeAction("CLICK", tuple()) + nrRowsAbbNew = get_state_as_dict(abbrevlist)["VisibleCount"] + nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb) + self.assertEqual(nrRowsAbbDiff, 1) #we have +1 rule + delabbrev.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(abbrevlist)["VisibleCount"], nrRowsAbb) #we have default nr of rules + + #words with two initial capitals + double = xDialog.getChild("double") + newdouble = xDialog.getChild("newdouble") + deldouble = xDialog.getChild("deldouble") + doublelist = xDialog.getChild("doublelist") + + nrRowsDouble = get_state_as_dict(doublelist)["VisibleCount"] + + self.assertTrue(int(nrRowsDouble) > 0) + + double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + double.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"})) + newdouble.executeAction("CLICK", tuple()) + nrRowsDoubleNew = get_state_as_dict(doublelist)["VisibleCount"] + nrRowsDoubleDiff = int(nrRowsDoubleNew) - int(nrRowsDouble) #convert string and + self.assertEqual(nrRowsDoubleDiff, 1) #we have +1 rule + deldouble.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(doublelist)["VisibleCount"], nrRowsDouble) #we have default nr of rules + self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests6/hideShowSheet.py b/sc/qa/uitest/calc_tests6/hideShowSheet.py index c6fccd92561b..f84d44fc3ac2 100644 --- a/sc/qa/uitest/calc_tests6/hideShowSheet.py +++ b/sc/qa/uitest/calc_tests6/hideShowSheet.py @@ -16,39 +16,29 @@ class hideShowSheet(UITestCase): gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #insert sheet - self.ui_test.execute_dialog_through_command(".uno:Insert") - current_dialog = self.xUITest.getTopFocusWindow() - xOkButton = current_dialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkButton) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"): + pass #select sheet gridwin.executeAction("SELECT", mkPropertyValues({"TABLE":"1"})) self.assertEqual(get_state_as_dict(gridwin)["SelectedTable"], "1") #hide sheet self.xUITest.executeCommand(".uno:Hide") #show sheet Dialog - self.ui_test.execute_dialog_through_command(".uno:Show") - xDialog = self.xUITest.getTopFocusWindow() - treeview = xDialog.getChild("treeview") - self.assertEqual(get_state_as_dict(treeview)["Children"], "1") - xcancel = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xcancel) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Show", close_button="cancel") as xDialog: + treeview = xDialog.getChild("treeview") + self.assertEqual(get_state_as_dict(treeview)["Children"], "1") #insert 2nd sheet - self.ui_test.execute_dialog_through_command(".uno:Insert") - current_dialog = self.xUITest.getTopFocusWindow() - xOkButton = current_dialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkButton) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"): + pass #select sheet gridwin.executeAction("SELECT", mkPropertyValues({"TABLE":"2"})) self.assertEqual(get_state_as_dict(gridwin)["SelectedTable"], "1") #hide sheet self.xUITest.executeCommand(".uno:Hide") #show sheet Dialog - self.ui_test.execute_dialog_through_command(".uno:Show") - xDialog = self.xUITest.getTopFocusWindow() - treeview = xDialog.getChild("treeview") - self.assertEqual(get_state_as_dict(treeview)["Children"], "2") - xcancel = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xcancel) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Show", close_button="cancel") as xDialog: + treeview = xDialog.getChild("treeview") + self.assertEqual(get_state_as_dict(treeview)["Children"], "2") self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests6/moveCopySheet.py b/sc/qa/uitest/calc_tests6/moveCopySheet.py index 8a0465c376e8..747dd77d3d69 100644 --- a/sc/qa/uitest/calc_tests6/moveCopySheet.py +++ b/sc/qa/uitest/calc_tests6/moveCopySheet.py @@ -16,32 +16,26 @@ class moveCopySheet(UITestCase): gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #default - 1 sheet; select the sheet (is selected), dialog move/copy sheet - self.ui_test.execute_dialog_through_command(".uno:Move") - xDialog = self.xUITest.getTopFocusWindow() - #new name = newName - newName = xDialog.getChild("newName") - newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - newName.executeAction("TYPE", mkPropertyValues({"TEXT":"newName"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Move") as xDialog: + #new name = newName + newName = xDialog.getChild("newName") + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newName.executeAction("TYPE", mkPropertyValues({"TEXT":"newName"})) #verify, the file has 2 sheets; first one "newName" is selected self.assertEqual(document.Sheets.getCount(), 2) # dialog move/copy sheet ; Move is selected; select -move to end position - ; New Name = moveName - self.ui_test.execute_dialog_through_command(".uno:Move") - xDialog = self.xUITest.getTopFocusWindow() - insertBefore = xDialog.getChild("insertBefore") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Move") as xDialog: + insertBefore = xDialog.getChild("insertBefore") - xTreeEntry = insertBefore.getChild('2') - xTreeEntry.executeAction("SELECT", tuple()) + xTreeEntry = insertBefore.getChild('2') + xTreeEntry.executeAction("SELECT", tuple()) - newName = xDialog.getChild("newName") - self.assertEqual(get_state_as_dict(newName)["Text"], "newName") - newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - newName.executeAction("TYPE", mkPropertyValues({"TEXT":"moveName"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + newName = xDialog.getChild("newName") + self.assertEqual(get_state_as_dict(newName)["Text"], "newName") + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newName.executeAction("TYPE", mkPropertyValues({"TEXT":"moveName"})) # Verify, the file has 2 sheets; first one is "Sheet1" ; second one is "moveName" self.assertEqual(document.Sheets.getCount(), 2) @@ -49,26 +43,21 @@ class moveCopySheet(UITestCase): self.assertEqual(document.Sheets[1].Name, "moveName") # Verify that the cancel button does not do anything - self.ui_test.execute_dialog_through_command(".uno:Move") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Move", close_button="cancel"): + pass self.assertEqual(document.Sheets.getCount(), 2) self.assertEqual(document.Sheets[0].Name, "Sheet1") self.assertEqual(document.Sheets[1].Name, "moveName") #Check copy option - self.ui_test.execute_dialog_through_command(".uno:Move") - xDialog = self.xUITest.getTopFocusWindow() - xCopy = xDialog.getChild("copy") - xCopy.executeAction("CLICK", tuple()) - sheetName = "moveName_2" - newName = xDialog.getChild("newName") - self.assertEqual(get_state_as_dict(newName)["Text"], sheetName) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Move") as xDialog: + xCopy = xDialog.getChild("copy") + xCopy.executeAction("CLICK", tuple()) + sheetName = "moveName_2" + newName = xDialog.getChild("newName") + self.assertEqual(get_state_as_dict(newName)["Text"], sheetName) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) self.assertEqual(document.Sheets.getCount(), 3) self.assertEqual(document.Sheets[0].Name, sheetName) diff --git a/sc/qa/uitest/calc_tests6/scenarios.py b/sc/qa/uitest/calc_tests6/scenarios.py index 64469be7a2ea..0686aaabd749 100644 --- a/sc/qa/uitest/calc_tests6/scenarios.py +++ b/sc/qa/uitest/calc_tests6/scenarios.py @@ -25,26 +25,20 @@ class scenarios(UITestCase): enter_text_to_cell(xGridWindow, "B4", "1") xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B4"})) #scenarios - scenario A1 - self.ui_test.execute_dialog_through_command(".uno:ScenarioManager") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:ScenarioManager") as xDialog: - name = xDialog.getChild("name") - name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - name.executeAction("TYPE", mkPropertyValues({"TEXT":"A1"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + name = xDialog.getChild("name") + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + name.executeAction("TYPE", mkPropertyValues({"TEXT":"A1"})) #next scenarios - scenario B1 - self.ui_test.execute_dialog_through_command(".uno:ScenarioManager") - xDialog = self.xUITest.getTopFocusWindow() - - name = xDialog.getChild("name") - name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - name.executeAction("TYPE", mkPropertyValues({"TEXT":"B1"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ScenarioManager") as xDialog: + + name = xDialog.getChild("name") + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + name.executeAction("TYPE", mkPropertyValues({"TEXT":"B1"})) self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/shareSpreadsheet.py b/sc/qa/uitest/calc_tests6/shareSpreadsheet.py index 032b32271e9a..feef08e5022b 100644 --- a/sc/qa/uitest/calc_tests6/shareSpreadsheet.py +++ b/sc/qa/uitest/calc_tests6/shareSpreadsheet.py @@ -18,15 +18,12 @@ class shareSpreadsheet(UITestCase): document = self.ui_test.get_component() #dialog shareSpreadsheet - self.ui_test.execute_dialog_through_command(".uno:ShareDocument") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:ShareDocument", close_button="cancel") as xDialog: - share = xDialog.getChild("share") - share.executeAction("CLICK", tuple()) - users = xDialog.getChild("users") - self.assertEqual(get_state_as_dict(users)["Children"], "1") - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + share = xDialog.getChild("share") + share.executeAction("CLICK", tuple()) + users = xDialog.getChild("users") + self.assertEqual(get_state_as_dict(users)["Children"], "1") self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf104378.py b/sc/qa/uitest/calc_tests6/tdf104378.py index 44c786019636..e228bbb9dd7e 100644 --- a/sc/qa/uitest/calc_tests6/tdf104378.py +++ b/sc/qa/uitest/calc_tests6/tdf104378.py @@ -17,11 +17,8 @@ class tdf104378(UITestCase): enter_text_to_cell(gridwin, "A1", "遠程MySQL連接遠程MySQL連接遠程MySQL連接") - self.ui_test.execute_dialog_through_command(".uno:ChineseConversion") - - xDialog = self.xUITest.getTopFocusWindow() - xOKBtn = xDialog.getChild('ok') - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ChineseConversion"): + pass document = self.ui_test.get_component() diff --git a/sc/qa/uitest/calc_tests6/tdf107267.py b/sc/qa/uitest/calc_tests6/tdf107267.py index d9de215503fe..9e005abbed38 100644 --- a/sc/qa/uitest/calc_tests6/tdf107267.py +++ b/sc/qa/uitest/calc_tests6/tdf107267.py @@ -23,45 +23,42 @@ class Subtotals(UITestCase): # 1. Open the test file gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F123"})) # 2. Data->Subtotals - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - # = 1st group = 3. Group by "Person Number", select "shipping time" and use the Max function. - xGroupBy = xDialog.getChild("group_by") - select_by_text(xGroupBy, "Person Number") - # 4. Tick 'Calculate subtotals for' -> "shipping time" - already selected - # xCheckListMenu = xDialog.getChild("grid1") - # xTreeList = xCheckListMenu.getChild("columns") - # x6Entry = xTreeList.getChild("5") - # xFirstEntry.executeAction("CLICK", tuple()) - #use the Max function + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSubTotals") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + # = 1st group = 3. Group by "Person Number", select "shipping time" and use the Max function. + xGroupBy = xDialog.getChild("group_by") + select_by_text(xGroupBy, "Person Number") + # 4. Tick 'Calculate subtotals for' -> "shipping time" - already selected + # xCheckListMenu = xDialog.getChild("grid1") + # xTreeList = xCheckListMenu.getChild("columns") + # x6Entry = xTreeList.getChild("5") + # xFirstEntry.executeAction("CLICK", tuple()) + #use the Max function - #= 2nd group =5. Group by "Person Number", select "shipping time" and use the Min function. - select_pos(xTabs, "1") - xGroupBy = xDialog.getChild("group_by") - select_by_text(xGroupBy, "Person Number") - # 4. Tick 'Calculate subtotals for' -> "shipping time" - already selected - # xCheckListMenu = xDialog.getChild("grid1") - # xTreeList = xCheckListMenu.getChild("columns") - # x6Entry = xTreeList.getChild("5") - # xFirstEntry.executeAction("CLICK", tuple()) - #use the Min function + #= 2nd group =5. Group by "Person Number", select "shipping time" and use the Min function. + select_pos(xTabs, "1") + xGroupBy = xDialog.getChild("group_by") + select_by_text(xGroupBy, "Person Number") + # 4. Tick 'Calculate subtotals for' -> "shipping time" - already selected + # xCheckListMenu = xDialog.getChild("grid1") + # xTreeList = xCheckListMenu.getChild("columns") + # x6Entry = xTreeList.getChild("5") + # xFirstEntry.executeAction("CLICK", tuple()) + #use the Min function - #= 3rd group = Group by "Person Number", select "shipping time" and use the Average function. - select_pos(xTabs, "2") - xGroupBy = xDialog.getChild("group_by") - select_by_text(xGroupBy, "Person Number") - # 4. Tick 'Calculate subtotals for' -> "shipping time" - already selected - # xCheckListMenu = xDialog.getChild("grid1") - # xTreeList = xCheckListMenu.getChild("columns") - # x6Entry = xTreeList.getChild("5") - # xFirstEntry.executeAction("CLICK", tuple()) - #use the Average function + #= 3rd group = Group by "Person Number", select "shipping time" and use the Average function. + select_pos(xTabs, "2") + xGroupBy = xDialog.getChild("group_by") + select_by_text(xGroupBy, "Person Number") + # 4. Tick 'Calculate subtotals for' -> "shipping time" - already selected + # xCheckListMenu = xDialog.getChild("grid1") + # xTreeList = xCheckListMenu.getChild("columns") + # x6Entry = xTreeList.getChild("5") + # xFirstEntry.executeAction("CLICK", tuple()) + #use the Average function - # 5. Click OK - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + # 5. Click OK #verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 141).getString(), "Grand Average") diff --git a/sc/qa/uitest/calc_tests6/tdf116996.py b/sc/qa/uitest/calc_tests6/tdf116996.py index 31cde88f909b..fc6fd625cb0c 100644 --- a/sc/qa/uitest/calc_tests6/tdf116996.py +++ b/sc/qa/uitest/calc_tests6/tdf116996.py @@ -16,38 +16,35 @@ class tdf116996(UITestCase): gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog", close_button="") as xDialogOpt: + xPages = xDialogOpt.getChild("pages") + xLOEntry = xPages.getChild('0') # Libreoffice + xLOEntry.executeAction("EXPAND", tuple()) + xAdvancedEntry = xLOEntry.getChild('10') + xAdvancedEntry.executeAction("SELECT", tuple()) #Libreoffice / Advanced + xexperimental = xDialogOpt.getChild("experimental") + xexperimental.executeAction("CLICK", tuple()) #enable experimental features - xPages = xDialogOpt.getChild("pages") - xLOEntry = xPages.getChild('0') # Libreoffice - xLOEntry.executeAction("EXPAND", tuple()) - xAdvancedEntry = xLOEntry.getChild('10') - xAdvancedEntry.executeAction("SELECT", tuple()) #Libreoffice / Advanced - xexperimental = xDialogOpt.getChild("experimental") - xexperimental.executeAction("CLICK", tuple()) #enable experimental features + xOKBtn = xDialogOpt.getChild("ok") - xOKBtn = xDialogOpt.getChild("ok") - - with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), close_button="no"): - pass + with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), close_button="no"): + pass #reopen options dialog and verify - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() - xPages = xDialogOpt.getChild("pages") - xLOEntry = xPages.getChild('0') # Libreoffice - xLOEntry.executeAction("EXPAND", tuple()) - xAdvancedEntry = xLOEntry.getChild('10') - xAdvancedEntry.executeAction("SELECT", tuple()) #Libreoffice / Advanced - xexperimental = xDialogOpt.getChild("experimental") - - self.assertEqual(get_state_as_dict(xexperimental)["Selected"], "true") - xexperimental.executeAction("CLICK", tuple()) #disable experimental features - xOKBtn = xDialogOpt.getChild("ok") - - with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), close_button="no"): - pass + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog", close_button="") as xDialogOpt: + xPages = xDialogOpt.getChild("pages") + xLOEntry = xPages.getChild('0') # Libreoffice + xLOEntry.executeAction("EXPAND", tuple()) + xAdvancedEntry = xLOEntry.getChild('10') + xAdvancedEntry.executeAction("SELECT", tuple()) #Libreoffice / Advanced + xexperimental = xDialogOpt.getChild("experimental") + + self.assertEqual(get_state_as_dict(xexperimental)["Selected"], "true") + xexperimental.executeAction("CLICK", tuple()) #disable experimental features + xOKBtn = xDialogOpt.getChild("ok") + + with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), close_button="no"): + pass self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf118638.py b/sc/qa/uitest/calc_tests6/tdf118638.py index 94c99f50666d..1c499603f57c 100644 --- a/sc/qa/uitest/calc_tests6/tdf118638.py +++ b/sc/qa/uitest/calc_tests6/tdf118638.py @@ -22,25 +22,22 @@ class Subtotals(UITestCase): # Open the test file gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B15"})) #Data->Subtotals - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xGroupBy = xDialog.getChild("group_by") - select_by_text(xGroupBy, "Store Name") - xCheckListMenu = xDialog.getChild("grid1") - xTreeList = xCheckListMenu.getChild("columns") - xEntry = xTreeList.getChild("1") - xEntry.executeAction("CLICK", tuple()) - - #use the SUM function - # xfunctions = xDialog.getChild("functions") - # propsF = {"TEXT": "Sum"} - # actionPropsF = mkPropertyValues(propsF) - # xfunctions.executeAction("SELECT", actionPropsF) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSubTotals") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xGroupBy = xDialog.getChild("group_by") + select_by_text(xGroupBy, "Store Name") + xCheckListMenu = xDialog.getChild("grid1") + xTreeList = xCheckListMenu.getChild("columns") + xEntry = xTreeList.getChild("1") + xEntry.executeAction("CLICK", tuple()) + + #use the SUM function + # xfunctions = xDialog.getChild("functions") + # propsF = {"TEXT": "Sum"} + # actionPropsF = mkPropertyValues(propsF) + # xfunctions.executeAction("SELECT", actionPropsF) + #verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 15).getString(), "5408 Sum") diff --git a/sc/qa/uitest/calc_tests6/tdf121263.py b/sc/qa/uitest/calc_tests6/tdf121263.py index 9d80fc24c64d..5bda02d27fac 100644 --- a/sc/qa/uitest/calc_tests6/tdf121263.py +++ b/sc/qa/uitest/calc_tests6/tdf121263.py @@ -18,14 +18,10 @@ class tdf121263(UITestCase): document = self.ui_test.get_component() gridwin = xTopWindow.getChild("grid_window") - self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("ok") - xOKButton.executeAction("CLICK", tuple()) - self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("ok") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"): + pass + with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"): + pass gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "2"})) #select previous sheet @@ -35,12 +31,9 @@ class tdf121263(UITestCase): self.xUITest.executeCommand(".uno:Hide") #show sheet Dialog - self.ui_test.execute_dialog_through_command(".uno:Show") - xDialog = self.xUITest.getTopFocusWindow() - treeview = xDialog.getChild("treeview") - self.assertEqual(get_state_as_dict(treeview)["Children"], "2") - xcancel = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xcancel) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Show", close_button="cancel") as xDialog: + treeview = xDialog.getChild("treeview") + self.assertEqual(get_state_as_dict(treeview)["Children"], "2") self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf91726.py b/sc/qa/uitest/calc_tests6/tdf91726.py index bc134547aaf8..a6071e0a4fae 100644 --- a/sc/qa/uitest/calc_tests6/tdf91726.py +++ b/sc/qa/uitest/calc_tests6/tdf91726.py @@ -18,33 +18,32 @@ class tdf91726(UITestCase): #select A1:E9 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:E9"})) #AutoFormat Styles - self.ui_test.execute_dialog_through_command(".uno:AutoFormat") - xDialog = self.xUITest.getTopFocusWindow() - #add new style "Default" - xadd = xDialog.getChild("add") - - # Use empty close_button to open consecutive dialogs - with self.ui_test.execute_blocking_action( - xadd.executeAction, args=('CLICK', ()), close_button="") as dialog: - nameEntry = dialog.getChild("name_entry") - nameEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"Default"})) - xOKBtn = dialog.getChild("ok") + with self.ui_test.execute_dialog_through_command_guarded(".uno:AutoFormat", close_button="") as xDialog: + #add new style "Default" + xadd = xDialog.getChild("add") + # Use empty close_button to open consecutive dialogs with self.ui_test.execute_blocking_action( - xOKBtn.executeAction, args=('CLICK', ()), close_button="") as dialog2: - #Error message: You have entered an invalid name. - #AutoFormat could not be created. - #Try again using a different name. - xOKBtn2 = dialog2.getChild("ok") + xadd.executeAction, args=('CLICK', ()), close_button="") as dialog: + nameEntry = dialog.getChild("name_entry") + nameEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"Default"})) + xOKBtn = dialog.getChild("ok") with self.ui_test.execute_blocking_action( - xOKBtn2.executeAction, args=('CLICK', ()), close_button="cancel") as dialog3: - nameEntry = dialog3.getChild("name_entry") - #back to name dialog, LO should not crash - self.assertEqual(get_state_as_dict(nameEntry)["Text"], "Default") + xOKBtn.executeAction, args=('CLICK', ()), close_button="") as dialog2: + #Error message: You have entered an invalid name. + #AutoFormat could not be created. + #Try again using a different name. + xOKBtn2 = dialog2.getChild("ok") + + with self.ui_test.execute_blocking_action( + xOKBtn2.executeAction, args=('CLICK', ()), close_button="cancel") as dialog3: + nameEntry = dialog3.getChild("name_entry") + #back to name dialog, LO should not crash + self.assertEqual(get_state_as_dict(nameEntry)["Text"], "Default") - xCanceltn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanceltn) + xCanceltn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanceltn) self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests7/tdf106667.py b/sc/qa/uitest/calc_tests7/tdf106667.py index 6c2792d1b403..30727b42bf8e 100644 --- a/sc/qa/uitest/calc_tests7/tdf106667.py +++ b/sc/qa/uitest/calc_tests7/tdf106667.py @@ -25,10 +25,8 @@ class tdf106667(UITestCase): self.xUITest.executeCommand(".uno:SelectAll") - self.ui_test.execute_dialog_through_command(".uno:About") - xAboutDlg = self.xUITest.getTopFocusWindow() - xCloseBtn = xAboutDlg.getChild("btnClose") - self.ui_test.close_dialog_through_button(xCloseBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:About", close_button="btnClose") as xAboutDlg: + pass self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests7/tdf122509.py b/sc/qa/uitest/calc_tests7/tdf122509.py index a2f2b44289ed..71deb3ee412a 100644 --- a/sc/qa/uitest/calc_tests7/tdf122509.py +++ b/sc/qa/uitest/calc_tests7/tdf122509.py @@ -21,29 +21,26 @@ class tdf122509(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab Numbers - xliststore1 = xDialog.getChild("categorylb") #1st list / Category - xliststore2 = xDialog.getChild("formatlb") #2nd list / Format - xdecimalsed = xDialog.getChild("decimalsed") - xleadzerosed = xDialog.getChild("leadzerosed") - xnegnumred = xDialog.getChild("negnumred") - xthousands = xDialog.getChild("thousands") - xlanguagelb = xDialog.getChild("languagelb") - xformatted = xDialog.getChild("formatted") + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") - self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,##0.00 [$USD];[RED]-#,##0.00 [$USD]") - #click negative - xnegnumred.executeAction("CLICK", tuple()) - #format check; https://bugs.documentfoundation.org/show_bug.cgi?id=122509#c7 - self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,##0.00 [$USD];-#,##0.00 [$USD]") - # click negative - xnegnumred.executeAction("CLICK", tuple()) - #OK - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,##0.00 [$USD];[RED]-#,##0.00 [$USD]") + #click negative + xnegnumred.executeAction("CLICK", tuple()) + #format check; https://bugs.documentfoundation.org/show_bug.cgi?id=122509#c7 + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,##0.00 [$USD];-#,##0.00 [$USD]") + # click negative + xnegnumred.executeAction("CLICK", tuple()) + #OK #verify; no crashes self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getValue(), 2) diff --git a/sc/qa/uitest/calc_tests7/tdf123122.py b/sc/qa/uitest/calc_tests7/tdf123122.py index d8d845b6c6e2..6e267d3f4d53 100644 --- a/sc/qa/uitest/calc_tests7/tdf123122.py +++ b/sc/qa/uitest/calc_tests7/tdf123122.py @@ -21,47 +21,41 @@ class tdf123122(UITestCase): #select cell A1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab Numbers - xliststore1 = xDialog.getChild("categorylb") #1st list / Category - xliststore2 = xDialog.getChild("formatlb") #2nd list / Format - xdecimalsed = xDialog.getChild("decimalsed") - xleadzerosed = xDialog.getChild("leadzerosed") - xnegnumred = xDialog.getChild("negnumred") - xthousands = xDialog.getChild("thousands") - xlanguagelb = xDialog.getChild("languagelb") - xformatted = xDialog.getChild("formatted") + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") - #Format cells and enter NN MMM DD YYYY HH:MM as format code - xformatted.executeAction("CLEAR", tuple()) #clear textbox - xformatted.executeAction("TYPE", mkPropertyValues({"TEXT":"NN MMM DD YYYY HH:MM"})) - #save - OK - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + #Format cells and enter NN MMM DD YYYY HH:MM as format code + xformatted.executeAction("CLEAR", tuple()) #clear textbox + xformatted.executeAction("TYPE", mkPropertyValues({"TEXT":"NN MMM DD YYYY HH:MM"})) + #save - OK #verify gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #format - cell - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab Numbers - xliststore1 = xDialog.getChild("categorylb") #1st list / Category - xliststore2 = xDialog.getChild("formatlb") #2nd list / Format - xdecimalsed = xDialog.getChild("decimalsed") - xleadzerosed = xDialog.getChild("leadzerosed") - xnegnumred = xDialog.getChild("negnumred") - xthousands = xDialog.getChild("thousands") - xlanguagelb = xDialog.getChild("languagelb") - xformatted = xDialog.getChild("formatted") + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") - self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Date") - self.assertEqual(get_state_as_dict(xformatted)["Text"], "NN MMM DD YYYY HH:MM") - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Date") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "NN MMM DD YYYY HH:MM") self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf124896.py b/sc/qa/uitest/calc_tests7/tdf124896.py index 287631b177dd..4d328d1391ce 100644 --- a/sc/qa/uitest/calc_tests7/tdf124896.py +++ b/sc/qa/uitest/calc_tests7/tdf124896.py @@ -16,10 +16,9 @@ class tdf124896(UITestCase): gridwin = xCalcDoc.getChild("grid_window") # Remove X Bar R Chart (2) sheet - self.ui_test.execute_dialog_through_command(".uno:Remove") #delete sheet - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("yes") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Remove", close_button="yes") as xDialog: + pass + #verify; no crashes self.assertEqual(calc_doc.Sheets.getCount(), 2) diff --git a/sc/qa/uitest/calc_tests8/navigator.py b/sc/qa/uitest/calc_tests8/navigator.py index d92226771eb5..de4059bbc5f9 100644 --- a/sc/qa/uitest/calc_tests8/navigator.py +++ b/sc/qa/uitest/calc_tests8/navigator.py @@ -37,12 +37,9 @@ class navigator(UITestCase): self.assertEqual(len(xComments.getChildren()), 1) self.assertEqual(get_state_as_dict(xComments.getChild('0'))['Text'], 'Test Comment') - self.ui_test.execute_dialog_through_command(".uno:RenameTable") - xDialog = self.xUITest.getTopFocusWindow() - xname_entry = xDialog.getChild("name_entry") - xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT": "S1"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RenameTable") as xDialog: + xname_entry = xDialog.getChild("name_entry") + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT": "S1"})) xCalcDoc = self.xUITest.getTopFocusWindow() xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel") diff --git a/sc/qa/uitest/calc_tests8/tdf114710.py b/sc/qa/uitest/calc_tests8/tdf114710.py index d0de48c10c74..f12d1fae2493 100644 --- a/sc/qa/uitest/calc_tests8/tdf114710.py +++ b/sc/qa/uitest/calc_tests8/tdf114710.py @@ -22,22 +22,19 @@ class tdf114710(UITestCase): self.xUITest.getTopFocusWindow() - self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:PasteSpecial") as xDialog: - xList = xDialog.getChild('list') + xList = xDialog.getChild('list') - for childName in xList.getChildren(): - xChild = xList.getChild(childName) - if get_state_as_dict(xChild)['Text'] == "Graphics Device Interface metafile (GDI)": - break + for childName in xList.getChildren(): + xChild = xList.getChild(childName) + if get_state_as_dict(xChild)['Text'] == "Graphics Device Interface metafile (GDI)": + break - xChild.executeAction("SELECT", tuple()) - self.assertEqual( - get_state_as_dict(xList)['SelectEntryText'], "Graphics Device Interface metafile (GDI)") + xChild.executeAction("SELECT", tuple()) + self.assertEqual( + get_state_as_dict(xList)['SelectEntryText'], "Graphics Device Interface metafile (GDI)") - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) # Without the fix in place, this test would have crashed here self.assertEqual(1, writer_document.GraphicObjects.getCount()) diff --git a/sc/qa/uitest/calc_tests8/tdf118308.py b/sc/qa/uitest/calc_tests8/tdf118308.py index 7a99d5aedac3..a3d6f74111e5 100644 --- a/sc/qa/uitest/calc_tests8/tdf118308.py +++ b/sc/qa/uitest/calc_tests8/tdf118308.py @@ -29,24 +29,21 @@ class tdf118308(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") - xDialog = self.xUITest.getTopFocusWindow() - - # Without the fix in place, this test would have failed here - # since a different dialog would have been opened and the children - # wouldn't have been found - xText = xDialog.getChild("text") - xNumbers = xDialog.getChild("numbers") - xDatetime = xDialog.getChild("datetime") - xFormats = xDialog.getChild("formats") - - self.assertEqual("true", get_state_as_dict(xText)["Selected"]) - self.assertEqual("true", get_state_as_dict(xNumbers)["Selected"]) - self.assertEqual("true", get_state_as_dict(xDatetime)["Selected"]) - self.assertEqual("false", get_state_as_dict(xFormats)["Selected"]) - - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:PasteSpecial") as xDialog: + + # Without the fix in place, this test would have failed here + # since a different dialog would have been opened and the children + # wouldn't have been found + xText = xDialog.getChild("text") + xNumbers = xDialog.getChild("numbers") + xDatetime = xDialog.getChild("datetime") + xFormats = xDialog.getChild("formats") + + self.assertEqual("true", get_state_as_dict(xText)["Selected"]) + self.assertEqual("true", get_state_as_dict(xNumbers)["Selected"]) + self.assertEqual("true", get_state_as_dict(xDatetime)["Selected"]) + self.assertEqual("false", get_state_as_dict(xFormats)["Selected"]) + self.assertEqual("A", get_cell_by_position(calc_document, 0, 0, 0).getString()) diff --git a/sc/qa/uitest/calc_tests8/tdf125051.py b/sc/qa/uitest/calc_tests8/tdf125051.py index 5ebd02446450..0f4eb92efbb9 100644 --- a/sc/qa/uitest/calc_tests8/tdf125051.py +++ b/sc/qa/uitest/calc_tests8/tdf125051.py @@ -21,12 +21,9 @@ class tdf125051(UITestCase): document = self.ui_test.get_component() enter_text_to_cell(gridwin, "A1", "text") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.ui_test.execute_dialog_through_command(".uno:SpellDialog") - xDialog = self.xUITest.getTopFocusWindow() #Spelling dialog + with self.ui_test.execute_dialog_through_command_guarded(".uno:SpellDialog") as xDialog2: + pass - xDialog2 = self.xUITest.getTopFocusWindow() # info dialog "The spellcheck of this sheet has been completed.-> OK" - okBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(okBtn) xDialog = self.xUITest.getTopFocusWindow() #Spelling dialog #open options diff --git a/sc/qa/uitest/calc_tests8/tdf137726.py b/sc/qa/uitest/calc_tests8/tdf137726.py index 8256a778ba26..662d91da64a1 100644 --- a/sc/qa/uitest/calc_tests8/tdf137726.py +++ b/sc/qa/uitest/calc_tests8/tdf137726.py @@ -13,10 +13,11 @@ class tdf137726(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") - self.ui_test.execute_dialog_through_command(".uno:DataDataPilotRun") - # three dialogs are displayed one after the other, click OK in all of them - for i in range(3): + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataDataPilotRun") as xDialog: + pass + + for i in range(2): xDialog = self.xUITest.getTopFocusWindow() xOKBtn = xDialog.getChild('ok') self.ui_test.close_dialog_through_button(xOKBtn) diff --git a/sc/qa/uitest/calc_tests9/pivotTable.py b/sc/qa/uitest/calc_tests9/pivotTable.py index c5879f8ce143..402682378457 100644 --- a/sc/qa/uitest/calc_tests9/pivotTable.py +++ b/sc/qa/uitest/calc_tests9/pivotTable.py @@ -25,42 +25,39 @@ class pivotTable(UITestCase): self.xUITest.executeCommand(".uno:GoUp") - self.ui_test.execute_dialog_through_command(".uno:DataDataPilotRun") + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataDataPilotRun") as xDialog: + xFields = xDialog.getChild("listbox-fields") + self.assertEqual(2, len(xFields.getChildren())) + self.assertEqual("qtX", get_state_as_dict(xFields.getChild('0'))['Text']) + self.assertEqual("qtY", get_state_as_dict(xFields.getChild('1'))['Text']) - xDialog = self.xUITest.getTopFocusWindow() + xColumns = xDialog.getChild("listbox-column") + self.assertEqual(1, len(xColumns.getChildren())) + self.assertEqual("Data", get_state_as_dict(xColumns.getChild('0'))['Text']) - xFields = xDialog.getChild("listbox-fields") - self.assertEqual(2, len(xFields.getChildren())) - self.assertEqual("qtX", get_state_as_dict(xFields.getChild('0'))['Text']) - self.assertEqual("qtY", get_state_as_dict(xFields.getChild('1'))['Text']) + xPage = xDialog.getChild("listbox-page") + self.assertEqual(1, len(xPage.getChildren())) + xPageChild = xPage.getChild('0') + self.assertEqual("qtX", get_state_as_dict(xPageChild)['Text']) - xColumns = xDialog.getChild("listbox-column") - self.assertEqual(1, len(xColumns.getChildren())) - self.assertEqual("Data", get_state_as_dict(xColumns.getChild('0'))['Text']) + with self.ui_test.execute_blocking_action(xPageChild.executeAction, args=('DOUBLECLICK', ())) as dialog: + optionBtn = dialog.getChild("options") - xPage = xDialog.getChild("listbox-page") - self.assertEqual(1, len(xPage.getChildren())) - xPageChild = xPage.getChild('0') - self.assertEqual("qtX", get_state_as_dict(xPageChild)['Text']) + with self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ())) as dialog2: + xEmptyLine = dialog2.getChild("emptyline") - with self.ui_test.execute_blocking_action(xPageChild.executeAction, args=('DOUBLECLICK', ())) as dialog: - optionBtn = dialog.getChild("options") + xEmptyLine.executeAction("CLICK", tuple()) + self.assertEqual('true', get_state_as_dict(xEmptyLine)['Selected']) - with self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ())) as dialog2: - xEmptyLine = dialog2.getChild("emptyline") + with self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog2: + xEmptyLine = dialog2.getChild("emptyline") - xEmptyLine.executeAction("CLICK", tuple()) - self.assertEqual('true', get_state_as_dict(xEmptyLine)['Selected']) + xEmptyLine.executeAction("CLICK", tuple()) + self.assertEqual('false', get_state_as_dict(xEmptyLine)['Selected']) - with self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog2: - xEmptyLine = dialog2.getChild("emptyline") + with self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ())) as dialog2: + xEmptyLine = dialog2.getChild("emptyline") - xEmptyLine.executeAction("CLICK", tuple()) - self.assertEqual('false', get_state_as_dict(xEmptyLine)['Selected']) - - with self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ())) as dialog2: - xEmptyLine = dialog2.getChild("emptyline") - - self.assertEqual('true', get_state_as_dict(xEmptyLine)['Selected']) + self.assertEqual('true', get_state_as_dict(xEmptyLine)['Selected']) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf121949.py b/sc/qa/uitest/calc_tests9/tdf121949.py index 92dd66866510..e3e8da9340a8 100644 --- a/sc/qa/uitest/calc_tests9/tdf121949.py +++ b/sc/qa/uitest/calc_tests9/tdf121949.py @@ -19,10 +19,8 @@ class tdf121949 (UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B1", "EXTEND":"1"})) gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B3:B3", "EXTEND":"1"})) gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:C3", "EXTEND":"1"})) - self.ui_test.execute_dialog_through_command(".uno:Copy") - xDialog = self.xUITest.getTopFocusWindow() - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Copy"): + pass self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests9/tdf126673.py b/sc/qa/uitest/calc_tests9/tdf126673.py index 442cde01cd6d..a837a4d900e9 100644 --- a/sc/qa/uitest/calc_tests9/tdf126673.py +++ b/sc/qa/uitest/calc_tests9/tdf126673.py @@ -25,22 +25,16 @@ class tdf126673(UITestCase): #select A2 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) #optimal row height - self.ui_test.execute_dialog_through_command(".uno:SetOptimalRowHeight") - xDialog = self.xUITest.getTopFocusWindow() - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:SetOptimalRowHeight") as xDialog: + pass + #select A2 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) #row height - self.ui_test.execute_dialog_through_command(".uno:RowHeight") - xDialog = self.xUITest.getTopFocusWindow() - xvalue = xDialog.getChild("value") - heightStrOrig = get_state_as_dict(xvalue)["Text"] - heightVal = heightStrOrig[:4] #default 0.45 cm, - self.assertEqual(heightVal > '0.45', True) #new value is bigger then default - # Click Ok - xcancel = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xcancel) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight", close_button="cancel") as xDialog: + xvalue = xDialog.getChild("value") + heightStrOrig = get_state_as_dict(xvalue)["Text"] + heightVal = heightStrOrig[:4] #default 0.45 cm, + self.assertEqual(heightVal > '0.45', True) #new value is bigger then default # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf130371.py b/sc/qa/uitest/calc_tests9/tdf130371.py index e5108a118e03..c376da47e0d9 100644 --- a/sc/qa/uitest/calc_tests9/tdf130371.py +++ b/sc/qa/uitest/calc_tests9/tdf130371.py @@ -20,15 +20,12 @@ class namedRanges(UITestCase): text2 = "value\t$Sheet3.$B$2\tSheet3" text3 = "value\t$Sheet4.$B$2\tSheet4" - self.ui_test.execute_dialog_through_command(".uno:DefineName") - xDialog = self.xUITest.getTopFocusWindow() - namesList = xDialog.getChild('names') - self.assertEqual(2, len(namesList.getChildren())) - self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) - self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DefineName") as xDialog: + namesList = xDialog.getChild('names') + self.assertEqual(2, len(namesList.getChildren())) + self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) + self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) self.xUITest.executeCommand(".uno:Copy") @@ -38,27 +35,21 @@ class namedRanges(UITestCase): self.xUITest.executeCommand(".uno:Paste") - self.ui_test.execute_dialog_through_command(".uno:DefineName") - xDialog = self.xUITest.getTopFocusWindow() - namesList = xDialog.getChild('names') - self.assertEqual(3, len(namesList.getChildren())) - self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) - self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) - self.assertEqual(get_state_as_dict(namesList.getChild('2'))["Text"], text3) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DefineName") as xDialog: + namesList = xDialog.getChild('names') + self.assertEqual(3, len(namesList.getChildren())) + self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) + self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) + self.assertEqual(get_state_as_dict(namesList.getChild('2'))["Text"], text3) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) self.xUITest.executeCommand(".uno:Undo") - self.ui_test.execute_dialog_through_command(".uno:DefineName") - xDialog = self.xUITest.getTopFocusWindow() - namesList = xDialog.getChild('names') - self.assertEqual(2, len(namesList.getChildren())) - self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) - self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DefineName", close_button="cancel") as xDialog: + namesList = xDialog.getChild('names') + self.assertEqual(2, len(namesList.getChildren())) + self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) + self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) - xCancelBtn = xDialog.getChild("cancel") - xCancelBtn.executeAction("CLICK", tuple()) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf133629.py b/sc/qa/uitest/calc_tests9/tdf133629.py index 2b13645420ec..d2e0ee722bb2 100644 --- a/sc/qa/uitest/calc_tests9/tdf133629.py +++ b/sc/qa/uitest/calc_tests9/tdf133629.py @@ -16,10 +16,8 @@ class tdf133629(UITestCase): gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() - self.ui_test.execute_dialog_through_command(".uno:Insert") - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("ok") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"): + pass self.xUITest.executeCommand(".uno:TableSelectAll") @@ -29,22 +27,19 @@ class tdf133629(UITestCase): self.assertIsNotNone(getattr(document.CurrentSelection, 'Sheet1.A1:AMJ1048576')) self.assertIsNotNone(getattr(document.CurrentSelection, 'Sheet1.A2:AMJ1048576')) - self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "5") + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") - xPresets = xDialog.getChild("presets") - xPresets.executeAction("CHOOSE", mkPropertyValues({"POS": "4"})) + xPresets = xDialog.getChild("presets") + xPresets.executeAction("CHOOSE", mkPropertyValues({"POS": "4"})) - # Change width - xLineWidth = xDialog.getChild("linewidthmf") - xLineWidth.executeAction("UP", tuple()) - xLineWidth.executeAction("UP", tuple()) - self.assertEqual("1.25 pt", get_state_as_dict(xLineWidth)['Text']) + # Change width + xLineWidth = xDialog.getChild("linewidthmf") + xLineWidth.executeAction("UP", tuple()) + xLineWidth.executeAction("UP", tuple()) + self.assertEqual("1.25 pt", get_state_as_dict(xLineWidth)['Text']) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) # Without the fix in place, this test would have crash here diff --git a/sc/qa/uitest/calc_tests9/tdf137446.py b/sc/qa/uitest/calc_tests9/tdf137446.py index efdfb0213fb2..f62280401ecf 100644 --- a/sc/qa/uitest/calc_tests9/tdf137446.py +++ b/sc/qa/uitest/calc_tests9/tdf137446.py @@ -21,35 +21,29 @@ class tdf137446(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "lineObject"})) - self.ui_test.execute_dialog_through_command(".uno:TransformDialog") + with self.ui_test.execute_dialog_through_command_guarded(".uno:TransformDialog") as xDialog: - xDialog = self.xUITest.getTopFocusWindow() - self.assertEqual('10', get_state_as_dict(xDialog.getChild('MTR_FLD_WIDTH'))['Value']) - self.assertEqual('0', get_state_as_dict(xDialog.getChild('MTR_FLD_HEIGHT'))['Value']) - self.assertEqual('5.51', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_X'))['Value']) - self.assertEqual('2.55', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_Y'))['Value']) - self.assertEqual('0', get_state_as_dict(xDialog.getChild('NF_ANGLE'))['Value']) + self.assertEqual('10', get_state_as_dict(xDialog.getChild('MTR_FLD_WIDTH'))['Value']) + self.assertEqual('0', get_state_as_dict(xDialog.getChild('MTR_FLD_HEIGHT'))['Value']) + self.assertEqual('5.51', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_X'))['Value']) + self.assertEqual('2.55', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_Y'))['Value']) + self.assertEqual('0', get_state_as_dict(xDialog.getChild('NF_ANGLE'))['Value']) - xDialog.getChild('MTR_FLD_WIDTH').executeAction("UP", tuple()) + xDialog.getChild('MTR_FLD_WIDTH').executeAction("UP", tuple()) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) - self.ui_test.execute_dialog_through_command(".uno:TransformDialog") + with self.ui_test.execute_dialog_through_command_guarded(".uno:TransformDialog") as xDialog: - xDialog = self.xUITest.getTopFocusWindow() - self.assertEqual('10.1', get_state_as_dict(xDialog.getChild('MTR_FLD_WIDTH'))['Value']) - self.assertEqual('0', get_state_as_dict(xDialog.getChild('MTR_FLD_HEIGHT'))['Value']) - self.assertEqual('5.51', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_X'))['Value']) - self.assertEqual('2.55', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_Y'))['Value']) + self.assertEqual('10.1', get_state_as_dict(xDialog.getChild('MTR_FLD_WIDTH'))['Value']) + self.assertEqual('0', get_state_as_dict(xDialog.getChild('MTR_FLD_HEIGHT'))['Value']) + self.assertEqual('5.51', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_X'))['Value']) + self.assertEqual('2.55', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_Y'))['Value']) - # Without the fix in place, this test would have failed with AssertionError: '0' != '180' - self.assertEqual('0', get_state_as_dict(xDialog.getChild('NF_ANGLE'))['Value']) + # Without the fix in place, this test would have failed with AssertionError: '0' != '180' + self.assertEqual('0', get_state_as_dict(xDialog.getChild('NF_ANGLE'))['Value']) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf141244.py b/sc/qa/uitest/calc_tests9/tdf141244.py index 402215fdf333..187891cb2b0c 100644 --- a/sc/qa/uitest/calc_tests9/tdf141244.py +++ b/sc/qa/uitest/calc_tests9/tdf141244.py @@ -20,23 +20,20 @@ class tdf141244(UITestCase): enter_text_to_cell(gridwin, "A1", '=DDE("soffice";"data1.ods";"sheet1.A1")') - self.ui_test.execute_dialog_through_command(".uno:EditLinks") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:EditLinks", close_button="close") as xDialog: - xLinks = xDialog.getChild("TB_LINKS") - self.assertEqual(1, len(xLinks.getChildren())) + xLinks = xDialog.getChild("TB_LINKS") + self.assertEqual(1, len(xLinks.getChildren())) - xChangeBtn = xDialog.getChild("CHANGE_SOURCE") + xChangeBtn = xDialog.getChild("CHANGE_SOURCE") - with self.ui_test.execute_blocking_action(xChangeBtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog: - self.assertEqual("soffice", get_state_as_dict(dialog.getChild("app"))['Text']) - self.assertEqual("data1.ods", get_state_as_dict(dialog.getChild("file"))['Text']) - self.assertEqual("sheet1.A1", get_state_as_dict(dialog.getChild("category"))['Text']) + with self.ui_test.execute_blocking_action(xChangeBtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog: + self.assertEqual("soffice", get_state_as_dict(dialog.getChild("app"))['Text']) + self.assertEqual("data1.ods", get_state_as_dict(dialog.getChild("file"))['Text']) + self.assertEqual("sheet1.A1", get_state_as_dict(dialog.getChild("category"))['Text']) - # tdf#141770: Without the fix in place, the cancel button wouldn't have worked here + # tdf#141770: Without the fix in place, the cancel button wouldn't have worked here - xClose = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xClose) self.ui_test.close_doc() diff --git a/sc/qa/uitest/chart/copyPaste.py b/sc/qa/uitest/chart/copyPaste.py index 35ac13a2fdd1..bef17145690a 100644 --- a/sc/qa/uitest/chart/copyPaste.py +++ b/sc/qa/uitest/chart/copyPaste.py @@ -39,15 +39,12 @@ class CopyPaste(UITestCase): with self.ui_test.load_empty_file("calc") as calc_document: # Rename the sheet to match the same name as the first document - self.ui_test.execute_dialog_through_command(".uno:RenameTable") - xDialog = self.xUITest.getTopFocusWindow() - xname_entry = xDialog.getChild("name_entry") - - xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"Sheet.1"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:RenameTable") as xDialog: + xname_entry = xDialog.getChild("name_entry") + + xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"Sheet.1"})) self.xUITest.executeCommand(".uno:Paste") diff --git a/sc/qa/uitest/chart/create_chart.py b/sc/qa/uitest/chart/create_chart.py index cced0ac63d37..42f8211a8e83 100644 --- a/sc/qa/uitest/chart/create_chart.py +++ b/sc/qa/uitest/chart/create_chart.py @@ -15,11 +15,6 @@ import unittest class CalcChartUIDemo(UITestCase): - def create_insert_chart_dialog(self): - self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart") - # time.sleep(1) # ideally wait for a creation event - return self.xUITest.getTopFocusWindow() - def fill_spreadsheet(self): xCalcDoc = self.xUITest.getTopFocusWindow() xGridWindow = xCalcDoc.getChild("grid_window") @@ -39,10 +34,8 @@ class CalcChartUIDemo(UITestCase): self.fill_spreadsheet() - xChartDlg = self.create_insert_chart_dialog(); - - xCancelBtn = xChartDlg.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="cancel"): + pass self.ui_test.close_doc() @@ -52,10 +45,8 @@ class CalcChartUIDemo(UITestCase): self.fill_spreadsheet() - xChartDlg = self.create_insert_chart_dialog(); - - xOkBtn = xChartDlg.getChild("finish") - self.ui_test.close_dialog_through_button(xOkBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="finish"): + pass self.ui_test.close_doc() @@ -65,19 +56,15 @@ class CalcChartUIDemo(UITestCase): self.fill_spreadsheet() - xChartDlg = self.create_insert_chart_dialog(); - - xNextBtn = xChartDlg.getChild("next") - xNextBtn.executeAction("CLICK", tuple()) - - xDataInRows = xChartDlg.getChild("RB_DATAROWS") - xDataInRows.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="finish") as xChartDlg: + xNextBtn = xChartDlg.getChild("next") + xNextBtn.executeAction("CLICK", tuple()) - xDataInCols = xChartDlg.getChild("RB_DATACOLS") - xDataInCols.executeAction("CLICK", tuple()) + xDataInRows = xChartDlg.getChild("RB_DATAROWS") + xDataInRows.executeAction("CLICK", tuple()) - xCancelBtn = xChartDlg.getChild("finish") - self.ui_test.close_dialog_through_button(xCancelBtn) + xDataInCols = xChartDlg.getChild("RB_DATACOLS") + xDataInCols.executeAction("CLICK", tuple()) self.ui_test.close_doc() @@ -89,10 +76,8 @@ class CalcChartUIDemo(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() xGridWindow = xCalcDoc.getChild("grid_window") - xChartDlg = self.create_insert_chart_dialog(); - - xNextBtn = xChartDlg.getChild("finish") - self.ui_test.close_dialog_through_button(xNextBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="finish"): + pass xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) @@ -109,10 +94,8 @@ class CalcChartUIDemo(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() xGridWindow = xCalcDoc.getChild("grid_window") - xChartDlg = self.create_insert_chart_dialog(); - - xNextBtn = xChartDlg.getChild("finish") - self.ui_test.close_dialog_through_button(xNextBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="finish"): + pass xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) @@ -132,17 +115,14 @@ class CalcChartUIDemo(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() xGridWindow = xCalcDoc.getChild("grid_window") - xChartDlg = self.create_insert_chart_dialog(); - - xNextBtn = xChartDlg.getChild("finish") - self.ui_test.close_dialog_through_button(xNextBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="finish"): + pass xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"})) xGridWindow.executeAction("ACTIVATE", tuple()) - xCalcDoc = self.xUITest.getTopFocusWindow() self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/chart/edit_chart.py b/sc/qa/uitest/chart/edit_chart.py index b3742fe6c42b..4c9bb50c25ea 100644 --- a/sc/qa/uitest/chart/edit_chart.py +++ b/sc/qa/uitest/chart/edit_chart.py @@ -36,12 +36,8 @@ class CalcChartEditUIDemo(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() xGridWindow = xCalcDoc.getChild("grid_window") - self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart") - - xChartDlg = self.xUITest.getTopFocusWindow() - - xNextBtn = xChartDlg.getChild("finish") - self.ui_test.close_dialog_through_button(xNextBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="finish"): + pass xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) diff --git a/sc/qa/uitest/chart/tdf101894.py b/sc/qa/uitest/chart/tdf101894.py index 419b9c645add..66dcf1fbc483 100644 --- a/sc/qa/uitest/chart/tdf101894.py +++ b/sc/qa/uitest/chart/tdf101894.py @@ -34,26 +34,20 @@ class tdf101894(UITestCase): xOldSheetRanges.append(xRow) # Rename the sheet first - self.ui_test.execute_dialog_through_command(".uno:RenameTable") - xDialog = self.xUITest.getTopFocusWindow() - xname_entry = xDialog.getChild("name_entry") + with self.ui_test.execute_dialog_through_command_guarded(".uno:RenameTable") as xDialog: + xname_entry = xDialog.getChild("name_entry") - oldName = get_state_as_dict(xname_entry)['Text'] - xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + oldName = get_state_as_dict(xname_entry)['Text'] + xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) # Copy sheet and use the old name - self.ui_test.execute_dialog_through_command(".uno:Move") - xDialog = self.xUITest.getTopFocusWindow() - newName = xDialog.getChild("newName") - newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - newName.executeAction("TYPE", mkPropertyValues({"TEXT": oldName})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Move") as xDialog: + newName = xDialog.getChild("newName") + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newName.executeAction("TYPE", mkPropertyValues({"TEXT": oldName})) xChart = calc_doc.Sheets[0].Charts[0] xDataSeries = xChart.getEmbeddedObject().getFirstDiagram().CoordinateSystems[0].ChartTypes[0].DataSeries diff --git a/sc/qa/uitest/chart/tdf124295.py b/sc/qa/uitest/chart/tdf124295.py index a3fda3f03b46..f4f75e42c6f3 100644 --- a/sc/qa/uitest/chart/tdf124295.py +++ b/sc/qa/uitest/chart/tdf124295.py @@ -16,20 +16,17 @@ class tdf124295(UITestCase): def test_tdf124295(self): # Open spreadsheet and insert chart self.ui_test.create_doc_in_start_center("calc") - self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart") - xChartDlg = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="cancel") as xChartDlg: - # Click 3D look check button - x3DCheckBtn = xChartDlg.getChild("3dlook") - x3DCheckBtn.executeAction("CLICK", tuple()) + # Click 3D look check button + x3DCheckBtn = xChartDlg.getChild("3dlook") + x3DCheckBtn.executeAction("CLICK", tuple()) - x3DSchemeLstBox = xChartDlg.getChild("3dscheme") - # Without the fix in place, this test would have failed with: - # AssertionError: 'Realistic' != '' - self.assertEqual("Realistic", get_state_as_dict(x3DSchemeLstBox)["SelectEntryText"]) + x3DSchemeLstBox = xChartDlg.getChild("3dscheme") + # Without the fix in place, this test would have failed with: + # AssertionError: 'Realistic' != '' + self.assertEqual("Realistic", get_state_as_dict(x3DSchemeLstBox)["SelectEntryText"]) - xCancelBtn = xChartDlg.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) self.ui_test.close_doc() diff --git a/sc/qa/uitest/chart/tdf131715.py b/sc/qa/uitest/chart/tdf131715.py index 380aac21e964..11c4ae42fd2c 100644 --- a/sc/qa/uitest/chart/tdf131715.py +++ b/sc/qa/uitest/chart/tdf131715.py @@ -11,18 +11,15 @@ class tdf131715(UITestCase): def test_tdf131715(self): self.ui_test.create_doc_in_start_center("calc") - self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart") - xChartDlg = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="finish") as xChartDlg: - xWizard = xChartDlg.getChild('Wizard') + xWizard = xChartDlg.getChild('Wizard') - for i in range(10): - #without the fix in place, it would crash here - select_pos(xWizard, "2") + for i in range(10): + #without the fix in place, it would crash here + select_pos(xWizard, "2") - self.assertEqual(get_state_as_dict(xWizard)['CurrentStep'], "2") + self.assertEqual(get_state_as_dict(xWizard)['CurrentStep'], "2") - xOkBtn = xChartDlg.getChild("finish") - self.ui_test.close_dialog_through_button(xOkBtn) self.ui_test.close_doc() diff --git a/sc/qa/uitest/chart/tdf43175.py b/sc/qa/uitest/chart/tdf43175.py index 47470a71fefd..cc3b24e8b778 100644 --- a/sc/qa/uitest/chart/tdf43175.py +++ b/sc/qa/uitest/chart/tdf43175.py @@ -15,16 +15,13 @@ class Tdf43175(UITestCase): self.xUITest.executeCommand(".uno:TableSelectAll") - self.ui_test.execute_dialog_through_command(".uno:Move") - xDialog = self.xUITest.getTopFocusWindow() - insertBefore = xDialog.getChild("insertBefore") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Move") as xDialog: + insertBefore = xDialog.getChild("insertBefore") - # Select - move to end position - - xTreeEntry = insertBefore.getChild('2') - xTreeEntry.executeAction("SELECT", tuple()) + # Select - move to end position - + xTreeEntry = insertBefore.getChild('2') + xTreeEntry.executeAction("SELECT", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) aSheetNames = ['Blad1', 'Blad2', 'Blad1_2', 'Blad2_2'] diff --git a/sc/qa/uitest/chart/tdf46885.py b/sc/qa/uitest/chart/tdf46885.py index c629058d605b..6f95ab9636bb 100644 --- a/sc/qa/uitest/chart/tdf46885.py +++ b/sc/qa/uitest/chart/tdf46885.py @@ -21,12 +21,9 @@ class tdf46885(UITestCase): document = self.ui_test.get_component() enter_text_to_cell(gridwin, "A10", "col1") #When you start a new chart and have one empty cell selected LibO will crash when you select the Next>> button. - self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart") - xChartDlg = self.xUITest.getTopFocusWindow() - xNextBtn = xChartDlg.getChild("next") - xNextBtn.executeAction("CLICK", tuple()) - xOkBtn = xChartDlg.getChild("finish") - self.ui_test.close_dialog_through_button(xOkBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="finish") as xChartDlg: + xNextBtn = xChartDlg.getChild("next") + xNextBtn.executeAction("CLICK", tuple()) #verify, we didn't crash self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "col1") @@ -41,12 +38,9 @@ class tdf46885(UITestCase): enter_text_to_cell(gridwin, "A10", "col1") #If you select multiple empty cells and then start a new chart LibO will crash immediately. gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C4"})) - self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart") - xChartDlg = self.xUITest.getTopFocusWindow() - xNextBtn = xChartDlg.getChild("next") - xNextBtn.executeAction("CLICK", tuple()) - xOkBtn = xChartDlg.getChild("finish") - self.ui_test.close_dialog_through_button(xOkBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="finish") as xChartDlg: + xNextBtn = xChartDlg.getChild("next") + xNextBtn.executeAction("CLICK", tuple()) #verify, we didn't crash self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "col1") diff --git a/sc/qa/uitest/chart/tdf62349.py b/sc/qa/uitest/chart/tdf62349.py index db2170612664..cf5d231bbba5 100644 --- a/sc/qa/uitest/chart/tdf62349.py +++ b/sc/qa/uitest/chart/tdf62349.py @@ -21,11 +21,8 @@ class tdf62349(UITestCase): #3: select all data cells C5:H9 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C5:H9"})) # 4: create a chart with insert/chart menu - self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart") - xChartDlg = self.xUITest.getTopFocusWindow() - - xOkBtn = xChartDlg.getChild("finish") - self.ui_test.close_dialog_through_button(xOkBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="finish"): + pass # 5: (single) click to an empty cell to finalize the chart gridwin.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) diff --git a/sc/qa/uitest/chart/tdf99069.py b/sc/qa/uitest/chart/tdf99069.py index 355bac8a6896..c6eec4d035e7 100644 --- a/sc/qa/uitest/chart/tdf99069.py +++ b/sc/qa/uitest/chart/tdf99069.py @@ -20,12 +20,10 @@ class tdf99069(UITestCase): gridwin = xCalcDoc.getChild("grid_window") #(1) Download and open example.ods attached to tdf#97266 with cell B1 active. #(2) In tool bar, click the chart icon. Program presents Chart Wizard. - self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart") - xDialog = self.xUITest.getTopFocusWindow() - #(3) In Chart Wizard, click <Finish>. The program closes the wizard; - # the chart shows a border with handles on each side and at each corner. - xFinishBtn = xDialog.getChild("finish") - self.ui_test.close_dialog_through_button(xFinishBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertObjectChart", close_button="finish"): + # the chart shows a border with handles on each side and at each corner. + pass + for _ in range(0,5): #(4) Click outside the chart, for example in cell C23. The borders #disappear from the chart and the program restores the menubar to diff --git a/sc/qa/uitest/conditional_format/tdf100793.py b/sc/qa/uitest/conditional_format/tdf100793.py index 0fec3c69648f..15da954df0ba 100644 --- a/sc/qa/uitest/conditional_format/tdf100793.py +++ b/sc/qa/uitest/conditional_format/tdf100793.py @@ -25,64 +25,61 @@ class tdf100793(UITestCase): #2) Go to sheet "plan" gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "2"})) #3) Open the conditional formatting management dialog-> The indicated range should be G18:K29,F18,F20:F29 - self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") + with self.ui_test.execute_dialog_through_command_guarded(".uno:ConditionalFormatManagerDialog", close_button="") as xCondFormatMgr: - xCondFormatMgr = self.xUITest.getTopFocusWindow() + # check that we have exactly one conditional formats in the beginning + xList = xCondFormatMgr.getChild("CONTAINER") + list_state = get_state_as_dict(xList) + self.assertEqual(list_state['Children'], '1') - # check that we have exactly one conditional formats in the beginning - xList = xCondFormatMgr.getChild("CONTAINER") - list_state = get_state_as_dict(xList) - self.assertEqual(list_state['Children'], '1') + #3) Click Edit & try to change to intended one, F18:K33 + xEditBtn = xCondFormatMgr.getChild("edit") + with self.ui_test.execute_dialog_through_action(xEditBtn, "CLICK", event_name = "ModelessDialogVisible") as xCondFormatDlg: - #3) Click Edit & try to change to intended one, F18:K33 - xEditBtn = xCondFormatMgr.getChild("edit") - with self.ui_test.execute_dialog_through_action(xEditBtn, "CLICK", event_name = "ModelessDialogVisible") as xCondFormatDlg: + #modify textbox + xedassign = xCondFormatDlg.getChild("edassign") + #go at the beginning + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "END"})) + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "HOME"})) + # 11x right + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + #now I'm at F18 - write :K33 + xedassign.executeAction("TYPE", mkPropertyValues({"TEXT":":K33"})) - #modify textbox - xedassign = xCondFormatDlg.getChild("edassign") - #go at the beginning - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "END"})) - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "HOME"})) - # 11x right - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xedassign.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - #now I'm at F18 - write :K33 - xedassign.executeAction("TYPE", mkPropertyValues({"TEXT":":K33"})) + # we need to get a pointer again as the old window has been deleted + xCondFormatMgr = self.xUITest.getTopFocusWindow() + # check again that we still have 1 entry in the list + # and still only 1 conditional format in the document + xList = xCondFormatMgr.getChild("CONTAINER") + list_state = get_state_as_dict(xList) + self.assertEqual(list_state['Children'], '1') - # we need to get a pointer again as the old window has been deleted - xCondFormatMgr = self.xUITest.getTopFocusWindow() + self.assertEqual(conditional_format_list.getLength(), 1) - # check again that we still have 1 entry in the list - # and still only 1 conditional format in the document - xList = xCondFormatMgr.getChild("CONTAINER") - list_state = get_state_as_dict(xList) - self.assertEqual(list_state['Children'], '1') - - self.assertEqual(conditional_format_list.getLength(), 1) - - # close the conditional format manager - xOKBtn = xCondFormatMgr.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + # close the conditional format manager + xOKBtn = xCondFormatMgr.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) #verify - reopen, check range - self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") - xCondFormatMgr = self.xUITest.getTopFocusWindow() - xEditBtn = xCondFormatMgr.getChild("edit") - with self.ui_test.execute_dialog_through_action(xEditBtn, "CLICK", event_name = "ModelessDialogVisible") as xCondFormatDlg: - xedassign = xCondFormatDlg.getChild("edassign") - self.assertEqual(get_state_as_dict(xedassign)["Text"], "G18:K29,F18:K33,F20:F29") - xCondFormatMgr = self.xUITest.getTopFocusWindow() - xCancelBtn = xCondFormatMgr.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ConditionalFormatManagerDialog", close_button="") as xCondFormatMgr: + xEditBtn = xCondFormatMgr.getChild("edit") + with self.ui_test.execute_dialog_through_action(xEditBtn, "CLICK", event_name = "ModelessDialogVisible") as xCondFormatDlg: + xedassign = xCondFormatDlg.getChild("edassign") + self.assertEqual(get_state_as_dict(xedassign)["Text"], "G18:K29,F18:K33,F20:F29") + + xCondFormatMgr = self.xUITest.getTopFocusWindow() + xCancelBtn = xCondFormatMgr.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/conditional_format/tdf104026.py b/sc/qa/uitest/conditional_format/tdf104026.py index 45c2b9dea665..3f8195f60dc4 100644 --- a/sc/qa/uitest/conditional_format/tdf104026.py +++ b/sc/qa/uitest/conditional_format/tdf104026.py @@ -12,21 +12,18 @@ class Tdf104026(UITestCase): def execute_conditional_format_manager_dialog(self, nCount): - self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") - xCondFormatMgr = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:ConditionalFormatManagerDialog") as xCondFormatMgr: - aExpectedResults = ['A2\tCell value != $Sheet1.$B2', 'A3\tCell value != $Sheet1.$B3', - 'A4\tCell value != $Sheet1.$B4', 'A5\tCell value != $Sheet1.$B5', - 'A6\tCell value != $Sheet1.$B6', 'A7\tCell value != $Sheet1.$B7'] + aExpectedResults = ['A2\tCell value != $Sheet1.$B2', 'A3\tCell value != $Sheet1.$B3', + 'A4\tCell value != $Sheet1.$B4', 'A5\tCell value != $Sheet1.$B5', + 'A6\tCell value != $Sheet1.$B6', 'A7\tCell value != $Sheet1.$B7'] - xList = xCondFormatMgr.getChild("CONTAINER") - self.assertEqual(nCount, len(xList.getChildren())) + xList = xCondFormatMgr.getChild("CONTAINER") + self.assertEqual(nCount, len(xList.getChildren())) - for i in range(nCount): - self.assertEqual(aExpectedResults[i], get_state_as_dict(xList.getChild(str(i)))['Text']) + for i in range(nCount): + self.assertEqual(aExpectedResults[i], get_state_as_dict(xList.getChild(str(i)))['Text']) - xOKBtn = xCondFormatMgr.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) def test_tdf104026(self): with self.ui_test.load_file(get_url_for_data_file("tdf104026.ods")): diff --git a/sc/qa/uitest/conditional_format/tdf105544.py b/sc/qa/uitest/conditional_format/tdf105544.py index 0c656ec4998f..e0c58b55e373 100644 --- a/sc/qa/uitest/conditional_format/tdf105544.py +++ b/sc/qa/uitest/conditional_format/tdf105544.py @@ -20,30 +20,29 @@ class tdf105544(UITestCase): gridwin = xCalcDoc.getChild("grid_window") #2. select B3. Format> conditional formatting> manage gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) - self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") - xCondFormatMgr = self.xUITest.getTopFocusWindow() - - # check that we have exactly four conditional formats in the beginning - xList = xCondFormatMgr.getChild("CONTAINER") - list_state = get_state_as_dict(xList) - self.assertEqual(list_state['Children'], '4') - - #select B3:B37 range and click edit, then click yes - xList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) #2nd position in the list - xEditBtn = xCondFormatMgr.getChild("edit") - with self.ui_test.execute_dialog_through_action(xEditBtn, "CLICK", event_name = "ModelessDialogVisible"): - pass - - # we need to get a pointer again as the old window has been deleted - xCondFormatMgr = self.xUITest.getTopFocusWindow() - - # check again that we still have 4 entry in the list - xList = xCondFormatMgr.getChild("CONTAINER") - list_state = get_state_as_dict(xList) - self.assertEqual(list_state['Children'], '4') - - # close the conditional format manager - xOKBtn = xCondFormatMgr.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:ConditionalFormatManagerDialog", close_button="") as xCondFormatMgr: + + # check that we have exactly four conditional formats in the beginning + xList = xCondFormatMgr.getChild("CONTAINER") + list_state = get_state_as_dict(xList) + self.assertEqual(list_state['Children'], '4') + + #select B3:B37 range and click edit, then click yes + xList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) #2nd position in the list + xEditBtn = xCondFormatMgr.getChild("edit") + with self.ui_test.execute_dialog_through_action(xEditBtn, "CLICK", event_name = "ModelessDialogVisible"): + pass + + # we need to get a pointer again as the old window has been deleted + xCondFormatMgr = self.xUITest.getTopFocusWindow() + + # check again that we still have 4 entry in the list + xList = xCondFormatMgr.getChild("CONTAINER") + list_state = get_state_as_dict(xList) + self.assertEqual(list_state['Children'], '4') + + # close the conditional format manager + xOKBtn = xCondFormatMgr.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/conditional_format/tdf117899.py b/sc/qa/uitest/conditional_format/tdf117899.py index 389ff3cb4c34..12bbb5cce5b4 100644 --- a/sc/qa/uitest/conditional_format/tdf117899.py +++ b/sc/qa/uitest/conditional_format/tdf117899.py @@ -16,16 +16,13 @@ class Tdf117899(UITestCase): def execute_conditional_format_manager_dialog(self): - self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") - xCondFormatMgr = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:ConditionalFormatManagerDialog") as xCondFormatMgr: - aExpectedResult = 'Formula is $E3="нет"' - xList = xCondFormatMgr.getChild("CONTAINER") - self.assertEqual(1, len(xList.getChildren())) - self.assertTrue(get_state_as_dict(xList.getChild('0'))['Text'].endswith(aExpectedResult)) + aExpectedResult = 'Formula is $E3="нет"' + xList = xCondFormatMgr.getChild("CONTAINER") + self.assertEqual(1, len(xList.getChildren())) + self.assertTrue(get_state_as_dict(xList.getChild('0'))['Text'].endswith(aExpectedResult)) - xOKBtn = xCondFormatMgr.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) def test_tdf117899(self): with self.ui_test.load_file(get_url_for_data_file("tdf117899.ods")): @@ -48,16 +45,13 @@ class Tdf117899(UITestCase): self.xUITest.executeCommandWithParameters(".uno:ClipboardFormatItems", formatProperty) # Save Copy as - self.ui_test.execute_dialog_through_command(".uno:ObjectMenue?VerbID:short=-8") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:ObjectMenue?VerbID:short=-8", close_button="open") as xDialog: - xFileName = xDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xFileName = xDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) - xOpenBtn = xDialog.getChild("open") - self.ui_test.close_dialog_through_button(xOpenBtn) with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): diff --git a/sc/qa/uitest/conditional_format/tdf81696.py b/sc/qa/uitest/conditional_format/tdf81696.py index 6ad9a4531309..18c3d32f3ac8 100644 --- a/sc/qa/uitest/conditional_format/tdf81696.py +++ b/sc/qa/uitest/conditional_format/tdf81696.py @@ -24,14 +24,11 @@ class tdf81696(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B3"})) #Open sort dialog by DATA - SORT,Just sort it by Column A, ascending. (it's default) - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - xleftright = xDialog.getChild("leftright") - select_pos(xTabs, "0") + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + select_pos(xTabs, "0") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) #verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "A") self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 0).getString(), "B") diff --git a/sc/qa/uitest/conditional_format/tdf96453.py b/sc/qa/uitest/conditional_format/tdf96453.py index 0b6e5753f88a..39b6b6eabb50 100644 --- a/sc/qa/uitest/conditional_format/tdf96453.py +++ b/sc/qa/uitest/conditional_format/tdf96453.py @@ -20,44 +20,43 @@ class ConditionalFormatDlgTest(UITestCase): conditional_format_list = get_conditional_format_from_sheet(sheet) self.assertEqual(conditional_format_list.getLength(), 2) - self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") + with self.ui_test.execute_dialog_through_command_guarded(".uno:ConditionalFormatManagerDialog", close_button="") as xCondFormatMgr: - xCondFormatMgr = self.xUITest.getTopFocusWindow() - # check that we have exactly two conditional formats in the beginning - xList = xCondFormatMgr.getChild("CONTAINER") - list_state = get_state_as_dict(xList) - self.assertEqual(list_state['Children'], '2') + # check that we have exactly two conditional formats in the beginning + xList = xCondFormatMgr.getChild("CONTAINER") + list_state = get_state_as_dict(xList) + self.assertEqual(list_state['Children'], '2') - # remove one conditional format - xRemoveBtn = xCondFormatMgr.getChild("remove") - xRemoveBtn.executeAction("CLICK", tuple()) + # remove one conditional format + xRemoveBtn = xCondFormatMgr.getChild("remove") + xRemoveBtn.executeAction("CLICK", tuple()) - # check that the table only shows one - # but the document still contains two - list_state = get_state_as_dict(xList) - self.assertEqual(list_state['Children'], '1') + # check that the table only shows one + # but the document still contains two + list_state = get_state_as_dict(xList) + self.assertEqual(list_state['Children'], '1') - self.assertEqual(conditional_format_list.getLength(), 2) + self.assertEqual(conditional_format_list.getLength(), 2) - # add a new conditional format through the add button - xAddBtn = xCondFormatMgr.getChild("add") - with self.ui_test.execute_dialog_through_action(xAddBtn, "CLICK", event_name = "ModelessDialogVisible"): - pass + # add a new conditional format through the add button + xAddBtn = xCondFormatMgr.getChild("add") + with self.ui_test.execute_dialog_through_action(xAddBtn, "CLICK", event_name = "ModelessDialogVisible"): + pass - # we need to get a pointer again as the old window has been deleted - xCondFormatMgr = self.xUITest.getTopFocusWindow() + # we need to get a pointer again as the old window has been deleted + xCondFormatMgr = self.xUITest.getTopFocusWindow() - # check again that we now have 2 and not 3 entries in the list - # and still only 2 conditional formats in the document - xList = xCondFormatMgr.getChild("CONTAINER") - list_state = get_state_as_dict(xList) - self.assertEqual(list_state['Children'], '2') + # check again that we now have 2 and not 3 entries in the list + # and still only 2 conditional formats in the document + xList = xCondFormatMgr.getChild("CONTAINER") + list_state = get_state_as_dict(xList) + self.assertEqual(list_state['Children'], '2') - self.assertEqual(conditional_format_list.getLength(), 2) + self.assertEqual(conditional_format_list.getLength(), 2) - # close the conditional format manager - xCancelBtn = xCondFormatMgr.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + # close the conditional format manager + xCancelBtn = xCondFormatMgr.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/csv_dialog/tdf142395.py b/sc/qa/uitest/csv_dialog/tdf142395.py index b1906c7295ec..412ce6e6f53a 100644 --- a/sc/qa/uitest/csv_dialog/tdf142395.py +++ b/sc/qa/uitest/csv_dialog/tdf142395.py @@ -14,14 +14,11 @@ class Tdf142395(UITestCase): def test_tdf142395(self): # Load file from Open dialog - self.ui_test.execute_dialog_through_command(".uno:Open") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Open", close_button="open") as xOpenDialog: - xOpenDialog = self.xUITest.getTopFocusWindow() - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf142395.csv")})) + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf142395.csv")})) - xOpenBtn = xOpenDialog.getChild("open") - xOpenBtn.executeAction("CLICK", tuple()) xDialog = self.ui_test.wait_for_top_focus_window('TextImportCsvDialog') # Remove the text delimiter diff --git a/sc/qa/uitest/csv_dialog/tdf57841.py b/sc/qa/uitest/csv_dialog/tdf57841.py index 995fab2647de..9deda7611aa7 100644 --- a/sc/qa/uitest/csv_dialog/tdf57841.py +++ b/sc/qa/uitest/csv_dialog/tdf57841.py @@ -14,14 +14,11 @@ class Tdf57841(UITestCase): def test_tdf57841(self): # Load file from Open dialog - self.ui_test.execute_dialog_through_command(".uno:Open") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Open", close_button="open") as xOpenDialog: - xOpenDialog = self.xUITest.getTopFocusWindow() - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf57841.csv")})) + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf57841.csv")})) - xOpenBtn = xOpenDialog.getChild("open") - xOpenBtn.executeAction("CLICK", tuple()) xDialog = self.ui_test.wait_for_top_focus_window('TextImportCsvDialog') self.assertEqual('true', get_state_as_dict(xDialog.getChild("tab"))['Selected']) diff --git a/sc/qa/uitest/csv_dialog/tdf60468.py b/sc/qa/uitest/csv_dialog/tdf60468.py index 77b4a0f37c6a..36baa64082fa 100644 --- a/sc/qa/uitest/csv_dialog/tdf60468.py +++ b/sc/qa/uitest/csv_dialog/tdf60468.py @@ -14,14 +14,11 @@ class Tdf60468(UITestCase): def test_tdf60468(self): # Load file from Open dialog - self.ui_test.execute_dialog_through_command(".uno:Open") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Open", close_button="open") as xOpenDialog: - xOpenDialog = self.xUITest.getTopFocusWindow() - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf60468.csv")})) + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf60468.csv")})) - xOpenBtn = xOpenDialog.getChild("open") - xOpenBtn.executeAction("CLICK", tuple()) xDialog = self.ui_test.wait_for_top_focus_window('TextImportCsvDialog') self.assertEqual('true', get_state_as_dict(xDialog.getChild("tab"))['Selected']) diff --git a/sc/qa/uitest/key_f4/f4.py b/sc/qa/uitest/key_f4/f4.py index ede0b2fdef9c..a6da13d8afc9 100644 --- a/sc/qa/uitest/key_f4/f4.py +++ b/sc/qa/uitest/key_f4/f4.py @@ -84,21 +84,18 @@ class keyF4(UITestCase): gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #* Tools --> Options --> Calc --> Formula --> Syntax = Excel R1C1 - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".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 + 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") + formulasyntax = xDialogOpt.getChild("formulasyntax") + #Excel R1C1 + select_by_text(formulasyntax, "Excel R1C1") - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #In cell R3C3 enter "xxx". enter_text_to_cell(gridwin, "C3", "xxx") @@ -116,20 +113,17 @@ class keyF4(UITestCase): self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "=R3C3") #Give it back Tools --> Options --> Calc --> Formula --> Syntax = Calc A1 - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".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 + 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") + formulasyntax = xDialogOpt.getChild("formulasyntax") + #Excel R1C1 + select_by_text(formulasyntax, "Calc A1") - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/manual_tests/calc.py b/sc/qa/uitest/manual_tests/calc.py index 247f7028e2ae..6e05f5b97de9 100644 --- a/sc/qa/uitest/manual_tests/calc.py +++ b/sc/qa/uitest/manual_tests/calc.py @@ -37,16 +37,12 @@ class ManualCalcTests(UITestCase): xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) # Execute "Select DB Range dialog" - self.ui_test.execute_dialog_through_command(".uno:SelectDB") - xSelectNameDlg = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:SelectDB") as xSelectNameDlg: - xListBox = xSelectNameDlg.getChild("treeview") - xListBoxState = get_state_as_dict(xListBox) - self.assertEqual(xListBoxState["SelectionCount"], "1") - self.assertEqual(xListBoxState["SelectEntryText"], "my_database") - - xOkBtn = xSelectNameDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + xListBox = xSelectNameDlg.getChild("treeview") + xListBoxState = get_state_as_dict(xListBox) + self.assertEqual(xListBoxState["SelectionCount"], "1") + self.assertEqual(xListBoxState["SelectEntryText"], "my_database") # Assert that the correct range has been selected gridWinState = get_state_as_dict(xGridWin) @@ -74,11 +70,8 @@ class ManualCalcTests(UITestCase): xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B10"})) # Execute "Sort" dialog - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xSortDlg = self.xUITest.getTopFocusWindow() - - xOkBtn = xSortDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort"): + pass document = self.ui_test.get_component() @@ -102,20 +95,17 @@ class ManualCalcTests(UITestCase): xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C10"})) - self.ui_test.execute_dialog_through_command(".uno:Validation") - xValidationDlg = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xValidationDlg: - xAllowList = xValidationDlg.getChild("allow") - xAllowList.executeAction("SELECT", mkPropertyValues({"POS": "1"})) + xAllowList = xValidationDlg.getChild("allow") + xAllowList.executeAction("SELECT", mkPropertyValues({"POS": "1"})) - xData = xValidationDlg.getChild("data") - xData.executeAction("SELECT", mkPropertyValues({"POS": "5"})) + xData = xValidationDlg.getChild("data") + xData.executeAction("SELECT", mkPropertyValues({"POS": "5"})) - xVal = xValidationDlg.getChild("max") - xVal.executeAction("TYPE", mkPropertyValues({"TEXT":"0"})) + xVal = xValidationDlg.getChild("max") + xVal.executeAction("TYPE", mkPropertyValues({"TEXT":"0"})) - xOkBtn = xValidationDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) def enter_text(cell, text): enter_text_to_cell(xGridWin, cell, text) @@ -145,18 +135,14 @@ class ManualCalcTests(UITestCase): xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") + with self.ui_test.execute_dialog_through_command_guarded(".uno:PasteSpecial") as xPasteSpecialDlg: - xPasteSpecialDlg = self.xUITest.getTopFocusWindow() + xAllChkBox = xPasteSpecialDlg.getChild("paste_all") + xAllChkBox.executeAction("CLICK", tuple()) - xAllChkBox = xPasteSpecialDlg.getChild("paste_all") - xAllChkBox.executeAction("CLICK", tuple()) + xTransposeChkBox = xPasteSpecialDlg.getChild("transpose") + xTransposeChkBox.executeAction("CLICK", tuple()) - xTransposeChkBox = xPasteSpecialDlg.getChild("transpose") - xTransposeChkBox.executeAction("CLICK", tuple()) - - xOkBtn = xPasteSpecialDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) document = self.ui_test.get_component() self.assertEqual(get_cell_by_position(document, 0, 2, 1).getString(), "abcd") diff --git a/sc/qa/uitest/manual_tests/more_calc.py b/sc/qa/uitest/manual_tests/more_calc.py index 08aeb654e449..e99015a92f2e 100644 --- a/sc/qa/uitest/manual_tests/more_calc.py +++ b/sc/qa/uitest/manual_tests/more_calc.py @@ -35,14 +35,11 @@ class ManualCalcTests(UITestCase): xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) # Choose Paste Special Options and paste data - self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") - xPasteSpecialDlg = self.xUITest.getTopFocusWindow() - xAllChkBox = xPasteSpecialDlg.getChild("paste_all") - xAllChkBox.executeAction("CLICK", tuple()) - xLinkChkBox = xPasteSpecialDlg.getChild("link") - xLinkChkBox.executeAction("CLICK", tuple()) - xOkBtn = xPasteSpecialDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:PasteSpecial") as xPasteSpecialDlg: + xAllChkBox = xPasteSpecialDlg.getChild("paste_all") + xAllChkBox.executeAction("CLICK", tuple()) + xLinkChkBox = xPasteSpecialDlg.getChild("link") + xLinkChkBox.executeAction("CLICK", tuple()) # Assert successful paste document = self.ui_test.get_component() diff --git a/sc/qa/uitest/options/tdf122977.py b/sc/qa/uitest/options/tdf122977.py index b81adbc2616a..342faf23df50 100644 --- a/sc/qa/uitest/options/tdf122977.py +++ b/sc/qa/uitest/options/tdf122977.py @@ -21,40 +21,37 @@ class chartDefaultColors(UITestCase): document = self.ui_test.get_component() #Go to Tools -> Options -> Charts -> Default Colors - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() - - xPages = xDialogOpt.getChild("pages") - xChartEntry = xPages.getChild('5') # Charts - xChartEntry.executeAction("EXPAND", tuple()) - xChartGeneralEntry = xChartEntry.getChild('0') - xChartGeneralEntry.executeAction("SELECT", tuple()) #Default Colors - xColors = xDialogOpt.getChild("colors") - xAdd = xDialogOpt.getChild("add") - xDelete = xDialogOpt.getChild("delete") - xDefault = xDialogOpt.getChild("default") - - #click Default - reset - xDefault.executeAction("CLICK", tuple()) - nrDefaultColors = get_state_as_dict(xColors)["Children"] - nrDefaultColors1 = int(nrDefaultColors) + 1 - xAdd.executeAction("CLICK", tuple()) #add new color - self.assertEqual(get_state_as_dict(xColors)["Children"], str(nrDefaultColors1)) - - #delete new color - with self.ui_test.execute_blocking_action(xDelete.executeAction, args=('CLICK', ()), close_button="yes"): - pass - - self.assertEqual(get_state_as_dict(xColors)["Children"], nrDefaultColors) - - xAdd.executeAction("CLICK", tuple()) #add new color - self.assertEqual(get_state_as_dict(xColors)["Children"], str(nrDefaultColors1)) - #click Default - xDefault.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xColors)["Children"], nrDefaultColors) - - xCancelBtn = xDialogOpt.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog", close_button="cancel") as xDialogOpt: + + xPages = xDialogOpt.getChild("pages") + xChartEntry = xPages.getChild('5') # Charts + xChartEntry.executeAction("EXPAND", tuple()) + xChartGeneralEntry = xChartEntry.getChild('0') + xChartGeneralEntry.executeAction("SELECT", tuple()) #Default Colors + xColors = xDialogOpt.getChild("colors") + xAdd = xDialogOpt.getChild("add") + xDelete = xDialogOpt.getChild("delete") + xDefault = xDialogOpt.getChild("default") + + #click Default - reset + xDefault.executeAction("CLICK", tuple()) + nrDefaultColors = get_state_as_dict(xColors)["Children"] + nrDefaultColors1 = int(nrDefaultColors) + 1 + xAdd.executeAction("CLICK", tuple()) #add new color + self.assertEqual(get_state_as_dict(xColors)["Children"], str(nrDefaultColors1)) + + #delete new color + with self.ui_test.execute_blocking_action(xDelete.executeAction, args=('CLICK', ()), close_button="yes"): + pass + + self.assertEqual(get_state_as_dict(xColors)["Children"], nrDefaultColors) + + xAdd.executeAction("CLICK", tuple()) #add new color + self.assertEqual(get_state_as_dict(xColors)["Children"], str(nrDefaultColors1)) + #click Default + xDefault.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xColors)["Children"], nrDefaultColors) + self.ui_test.close_doc() diff --git a/sc/qa/uitest/pageFormat/tdf123508.py b/sc/qa/uitest/pageFormat/tdf123508.py index c4b8fe9c8431..5b74955c6072 100644 --- a/sc/qa/uitest/pageFormat/tdf123508.py +++ b/sc/qa/uitest/pageFormat/tdf123508.py @@ -20,36 +20,30 @@ class tdf123508(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") #open "Format > Page - Sheet > Scale - self.ui_test.execute_dialog_through_command(".uno:PageFormatDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "6") #tab Scale - scalingMode = xDialog.getChild("comboLB_SCALEMODE") - spinEDSCALEPAGEWIDTH = xDialog.getChild("spinED_SCALEPAGEWIDTH") - spinEDSCALEPAGEHEIGHT = xDialog.getChild("spinED_SCALEPAGEHEIGHT") - #select "Fit print range(s) to width/height" from the scale mode drop-down list - select_by_text(scalingMode, "Fit print range(s) to width/height") - #define a value for the page, e.g.: width 2; height 2 - spinEDSCALEPAGEWIDTH.executeAction("UP", tuple()) - spinEDSCALEPAGEHEIGHT.executeAction("UP", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:PageFormatDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Scale + scalingMode = xDialog.getChild("comboLB_SCALEMODE") + spinEDSCALEPAGEWIDTH = xDialog.getChild("spinED_SCALEPAGEWIDTH") + spinEDSCALEPAGEHEIGHT = xDialog.getChild("spinED_SCALEPAGEHEIGHT") + #select "Fit print range(s) to width/height" from the scale mode drop-down list + select_by_text(scalingMode, "Fit print range(s) to width/height") + #define a value for the page, e.g.: width 2; height 2 + spinEDSCALEPAGEWIDTH.executeAction("UP", tuple()) + spinEDSCALEPAGEHEIGHT.executeAction("UP", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #verify - self.ui_test.execute_dialog_through_command(".uno:PageFormatDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "6") #tab Scale - scalingMode = xDialog.getChild("comboLB_SCALEMODE") - spinEDSCALEPAGEWIDTH = xDialog.getChild("spinED_SCALEPAGEWIDTH") - spinEDSCALEPAGEHEIGHT = xDialog.getChild("spinED_SCALEPAGEHEIGHT") + with self.ui_test.execute_dialog_through_command_guarded(".uno:PageFormatDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Scale + scalingMode = xDialog.getChild("comboLB_SCALEMODE") + spinEDSCALEPAGEWIDTH = xDialog.getChild("spinED_SCALEPAGEWIDTH") + spinEDSCALEPAGEHEIGHT = xDialog.getChild("spinED_SCALEPAGEHEIGHT") - self.assertEqual(get_state_as_dict(scalingMode)["SelectEntryText"], "Fit print range(s) to width/height") - self.assertEqual(get_state_as_dict(spinEDSCALEPAGEWIDTH)["Text"], "2") - self.assertEqual(get_state_as_dict(spinEDSCALEPAGEHEIGHT)["Text"], "2") + self.assertEqual(get_state_as_dict(scalingMode)["SelectEntryText"], "Fit print range(s) to width/height") + self.assertEqual(get_state_as_dict(spinEDSCALEPAGEWIDTH)["Text"], "2") + self.assertEqual(get_state_as_dict(spinEDSCALEPAGEHEIGHT)["Text"], "2") - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/protect/protectSheet.py b/sc/qa/uitest/protect/protectSheet.py index 90030b5322e7..12b0cd336f05 100644 --- a/sc/qa/uitest/protect/protectSheet.py +++ b/sc/qa/uitest/protect/protectSheet.py @@ -21,39 +21,31 @@ class protectSheet(UITestCase): gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #enter password - lock - self.ui_test.execute_dialog_through_command(".uno:Protect") - xDialog = self.xUITest.getTopFocusWindow() - xprotect = xDialog.getChild("protect") - xpassword1 = xDialog.getChild("password1") - xpassword2 = xDialog.getChild("password2") - - if (get_state_as_dict(xprotect)["Selected"]) == "false": - xprotect.executeAction("CLICK", tuple()) - xpassword1.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) - xpassword2.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) - - xOKBtn = xDialog.getChild("ok") -# self.ui_test.close_dialog_through_button(xOKBtn) - xOKBtn.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Protect") as xDialog: + xprotect = xDialog.getChild("protect") + xpassword1 = xDialog.getChild("password1") + xpassword2 = xDialog.getChild("password2") + + if (get_state_as_dict(xprotect)["Selected"]) == "false": + xprotect.executeAction("CLICK", tuple()) + xpassword1.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) + xpassword2.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) + #Unlock - self.ui_test.execute_dialog_through_command(".uno:Protect") - xDialog = self.xUITest.getTopFocusWindow() - xpass1ed = xDialog.getChild("pass1ed") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Protect") as xDialog: + xpass1ed = xDialog.getChild("pass1ed") - xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) + xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #Verify - the sheet is unlocked enter_text_to_cell(gridwin, "B2", "A") self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "A") # test cancel button - self.ui_test.execute_dialog_through_command(".uno:Protect") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Protect", close_button="cancel"): + pass + enter_text_to_cell(gridwin, "B2", "B") self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "B") diff --git a/sc/qa/uitest/protect/protectSpreadsheet.py b/sc/qa/uitest/protect/protectSpreadsheet.py index c0b78943fa05..53424e415073 100644 --- a/sc/qa/uitest/protect/protectSpreadsheet.py +++ b/sc/qa/uitest/protect/protectSpreadsheet.py @@ -21,25 +21,19 @@ class protectSpreadsheet(UITestCase): gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #enter password - self.ui_test.execute_dialog_through_command(".uno:ToolProtectionDocument") - xDialog = self.xUITest.getTopFocusWindow() - xpass1ed = xDialog.getChild("pass1ed") - xconfirm1ed = xDialog.getChild("confirm1ed") + with self.ui_test.execute_dialog_through_command_guarded(".uno:ToolProtectionDocument") as xDialog: + xpass1ed = xDialog.getChild("pass1ed") + xconfirm1ed = xDialog.getChild("confirm1ed") - xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) - xconfirm1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) + xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) + xconfirm1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #Verify - self.ui_test.execute_dialog_through_command(".uno:ToolProtectionDocument") - xDialog = self.xUITest.getTopFocusWindow() - xpass1ed = xDialog.getChild("pass1ed") + with self.ui_test.execute_dialog_through_command_guarded(".uno:ToolProtectionDocument", close_button="cancel") as xDialog: + xpass1ed = xDialog.getChild("pass1ed") - xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) + xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) self.ui_test.close_doc() diff --git a/sc/qa/uitest/range_name/create_range_name.py b/sc/qa/uitest/range_name/create_range_name.py index 989532bf5643..0118aba85191 100644 --- a/sc/qa/uitest/range_name/create_range_name.py +++ b/sc/qa/uitest/range_name/create_range_name.py @@ -67,20 +67,17 @@ class CreateRangeNameTest(UITestCase): self.assertEqual(3.0, get_cell_by_position(document, 0, 0, 1).getValue()) # Change the name - self.ui_test.execute_dialog_through_command(".uno:DefineName") - xDialog = self.xUITest.getTopFocusWindow() - xNamesList = xDialog.getChild('names') - self.assertEqual(1, len(xNamesList.getChildren())) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DefineName") as xDialog: + xNamesList = xDialog.getChild('names') + self.assertEqual(1, len(xNamesList.getChildren())) - xName = xDialog.getChild('name') - self.assertEqual( 'RANGE1', get_state_as_dict(xName)["Text"]) + xName = xDialog.getChild('name') + self.assertEqual( 'RANGE1', get_state_as_dict(xName)["Text"]) - xName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xName.executeAction("TYPE", mkPropertyValues({"TEXT":"RANGE2"})) + xName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xName.executeAction("TYPE", mkPropertyValues({"TEXT":"RANGE2"})) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) # tdf#87474 check the formula is updated after changing the name self.assertEqual("=SUM(RANGE2)", get_cell_by_position(document, 0, 0, 1).getFormula()) @@ -123,16 +120,12 @@ class CreateRangeNameTest(UITestCase): # 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() + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertName", close_button="paste") as xDialog: - 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) + 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()) # use return key to paste the name range gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) @@ -142,24 +135,18 @@ class CreateRangeNameTest(UITestCase): 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()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"): + pass # 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()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertName", close_button="paste") as xDialog: - xPasteBtn = xDialog.getChild("paste") - self.ui_test.close_dialog_through_button(xPasteBtn) + 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()) # use return key to paste the name range gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) @@ -171,16 +158,13 @@ class CreateRangeNameTest(UITestCase): # and AssertionError: '=Sheet1.localRangeName' != '=localrangename' self.assertEqual("=Sheet1.localRangeName", get_cell_by_position(document, 0, 1, 0).getFormula()) - self.ui_test.execute_dialog_through_command(".uno:DefineName") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:DefineName") as xDialog: - # tdf#138851: Without the fix in place, this test would have failed with - # AssertionError: 'Sheet1' != 'Document (Global)' - xScope = xDialog.getChild("scope") - self.assertEqual("Sheet1", get_state_as_dict(xScope)['SelectEntryText']) + # tdf#138851: Without the fix in place, this test would have failed with + # AssertionError: 'Sheet1' != 'Document (Global)' + xScope = xDialog.getChild("scope") + self.assertEqual("Sheet1", get_state_as_dict(xScope)['SelectEntryText']) - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) self.ui_test.close_doc() diff --git a/sc/qa/uitest/range_name/tdf137617.py b/sc/qa/uitest/range_name/tdf137617.py index 54c458823fe6..c0a84ba8cb03 100644 --- a/sc/qa/uitest/range_name/tdf137617.py +++ b/sc/qa/uitest/range_name/tdf137617.py @@ -25,18 +25,15 @@ class tdf137617(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B2"})) - self.ui_test.execute_dialog_through_command(".uno:CreateNames") + with self.ui_test.execute_dialog_through_command_guarded(".uno:CreateNames") as xDialog: - xDialog = self.xUITest.getTopFocusWindow() - # Only left is selected - self.assertEqual('true', get_state_as_dict(xDialog.getChild('left'))['Selected']) - self.assertEqual('false', get_state_as_dict(xDialog.getChild('right'))['Selected']) - self.assertEqual('false', get_state_as_dict(xDialog.getChild('bottom'))['Selected']) - self.assertEqual('false', get_state_as_dict(xDialog.getChild('top'))['Selected']) + # Only left is selected + self.assertEqual('true', get_state_as_dict(xDialog.getChild('left'))['Selected']) + self.assertEqual('false', get_state_as_dict(xDialog.getChild('right'))['Selected']) + self.assertEqual('false', get_state_as_dict(xDialog.getChild('bottom'))['Selected']) + self.assertEqual('false', get_state_as_dict(xDialog.getChild('top'))['Selected']) - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) @@ -48,38 +45,32 @@ class tdf137617(UITestCase): self.assertEqual('Result2', get_state_as_dict(xPosWindow)['Text']) # Change formula syntax to "Excel R1C1" - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") - xDialogOpt = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xCalcEntry = xPages.getChild('3') - xCalcEntry.executeAction("EXPAND", tuple()) - xCalcFormulaEntry = xCalcEntry.getChild('4') - xCalcFormulaEntry.executeAction("SELECT", tuple()) + 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, "Excel R1C1") + xFormulaSyntax = xDialogOpt.getChild('formulasyntax') + select_by_text(xFormulaSyntax, "Excel R1C1") - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) enter_text_to_cell(gridwin, "C1", "Result3") enter_text_to_cell(gridwin, "D1", "Result4") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:D2"})) - self.ui_test.execute_dialog_through_command(".uno:CreateNames") + with self.ui_test.execute_dialog_through_command_guarded(".uno:CreateNames") as xDialog: - xDialog = self.xUITest.getTopFocusWindow() - # Only top is selected - self.assertEqual('false', get_state_as_dict(xDialog.getChild('left'))['Selected']) - self.assertEqual('false', get_state_as_dict(xDialog.getChild('right'))['Selected']) - self.assertEqual('false', get_state_as_dict(xDialog.getChild('bottom'))['Selected']) - self.assertEqual('true', get_state_as_dict(xDialog.getChild('top'))['Selected']) + # Only top is selected + self.assertEqual('false', get_state_as_dict(xDialog.getChild('left'))['Selected']) + self.assertEqual('false', get_state_as_dict(xDialog.getChild('right'))['Selected']) + self.assertEqual('false', get_state_as_dict(xDialog.getChild('bottom'))['Selected']) + self.assertEqual('true', get_state_as_dict(xDialog.getChild('top'))['Selected']) - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C2"})) @@ -92,20 +83,17 @@ class tdf137617(UITestCase): self.assertEqual('Result4', get_state_as_dict(xPosWindow)['Text']) # Change formula syntax back to "Calc A1" - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") - xDialogOpt = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xCalcEntry = xPages.getChild('3') - xCalcEntry.executeAction("EXPAND", tuple()) - xCalcFormulaEntry = xCalcEntry.getChild('4') - xCalcFormulaEntry.executeAction("SELECT", tuple()) + 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, "Calc A1") + xFormulaSyntax = xDialogOpt.getChild('formulasyntax') + select_by_text(xFormulaSyntax, "Calc A1") - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) self.ui_test.close_doc() diff --git a/sc/qa/uitest/search_replace/tdf39917.py b/sc/qa/uitest/search_replace/tdf39917.py index 456e4a4acf12..1f2445b5148b 100644 --- a/sc/qa/uitest/search_replace/tdf39917.py +++ b/sc/qa/uitest/search_replace/tdf39917.py @@ -23,46 +23,37 @@ class tdf39917(UITestCase): gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() #* Tools --> Options --> Calc --> Formula --> Syntax = Excel R1C1 - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".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 + 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") + formulasyntax = xDialogOpt.getChild("formulasyntax") + #Excel R1C1 + select_by_text(formulasyntax, "Excel R1C1") - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #1. Create a workbook with 3 sheets: Page1, Page2, Page3. # 2. Tools -> Options -> LibreOffice Calc -> Formula: Set syntax to Excel A1 # 5. Fill fields: - self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet - xDialog = self.xUITest.getTopFocusWindow() - 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"})) - xOKButton = xDialog.getChild("ok") - xOKButton.executeAction("CLICK", tuple()) - self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet - xDialog = self.xUITest.getTopFocusWindow() - 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"})) - xOKButton = xDialog.getChild("ok") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".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_guarded(".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") @@ -88,21 +79,18 @@ class tdf39917(UITestCase): 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 - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialogOpt = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".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 + 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") + formulasyntax = xDialogOpt.getChild("formulasyntax") + #Excel R1C1 + select_by_text(formulasyntax, "Calc A1") - xOKBtn = xDialogOpt.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/signatureLine/insertSignatureLine.py b/sc/qa/uitest/signatureLine/insertSignatureLine.py index 51a321b34a64..a668227e25da 100644 --- a/sc/qa/uitest/signatureLine/insertSignatureLine.py +++ b/sc/qa/uitest/signatureLine/insertSignatureLine.py @@ -21,34 +21,28 @@ class insertSignatureLineCalc(UITestCase): document = self.ui_test.get_component() # cancel the dialog without doing anything - self.ui_test.execute_dialog_through_command(".uno:InsertSignatureLine") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertSignatureLine", close_button="cancel") as xDialog: - xName = xDialog.getChild("edit_name") - xName.executeAction("TYPE", mkPropertyValues({"TEXT":"Name"})) #set the signature line + xName = xDialog.getChild("edit_name") + xName.executeAction("TYPE", mkPropertyValues({"TEXT":"Name"})) #set the signature line - xCloseBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCloseBtn) with self.assertRaises(IndexOutOfBoundsException): document.Sheets.getByIndex(0).DrawPage.getByIndex(0) # set the signature line - self.ui_test.execute_dialog_through_command(".uno:InsertSignatureLine") - xDialog = self.xUITest.getTopFocusWindow() - - xName = xDialog.getChild("edit_name") - xTitle = xDialog.getChild("edit_title") - xEmail = xDialog.getChild("edit_email") - xComment = xDialog.getChild("checkbox_can_add_comments") - xInstructions = xDialog.getChild("edit_instructions") - - xName.executeAction("TYPE", mkPropertyValues({"TEXT":"Name"})) #set the signature line - xTitle.executeAction("TYPE", mkPropertyValues({"TEXT":"Title"})) - xEmail.executeAction("TYPE", mkPropertyValues({"TEXT":"Email"})) - xComment.executeAction("CLICK", tuple()) - xInstructions.executeAction("TYPE", mkPropertyValues({"TEXT":"Instructions"})) - xOKBtn = xDialog.getChild("ok") - xOKBtn.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertSignatureLine") as xDialog: + + xName = xDialog.getChild("edit_name") + xTitle = xDialog.getChild("edit_title") + xEmail = xDialog.getChild("edit_email") + xComment = xDialog.getChild("checkbox_can_add_comments") + xInstructions = xDialog.getChild("edit_instructions") + + xName.executeAction("TYPE", mkPropertyValues({"TEXT":"Name"})) #set the signature line + xTitle.executeAction("TYPE", mkPropertyValues({"TEXT":"Title"})) + xEmail.executeAction("TYPE", mkPropertyValues({"TEXT":"Email"})) + xComment.executeAction("CLICK", tuple()) + xInstructions.executeAction("TYPE", mkPropertyValues({"TEXT":"Instructions"})) #check the signature Line in the document self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerName, "Name") @@ -67,24 +61,21 @@ class insertSignatureLineCalc(UITestCase): gridwin = xCalcDoc.getChild("grid_window") document = self.ui_test.get_component() - self.ui_test.execute_dialog_through_command(".uno:InsertSignatureLine") - xDialog = self.xUITest.getTopFocusWindow() - - xName = xDialog.getChild("edit_name") - xTitle = xDialog.getChild("edit_title") - xEmail = xDialog.getChild("edit_email") - xComment = xDialog.getChild("checkbox_can_add_comments") - xDate = xDialog.getChild("checkbox_show_sign_date") - xInstructions = xDialog.getChild("edit_instructions") - - xName.executeAction("TYPE", mkPropertyValues({"TEXT":"Name"})) #set the signature line - xTitle.executeAction("TYPE", mkPropertyValues({"TEXT":"Title"})) - xEmail.executeAction("TYPE", mkPropertyValues({"TEXT":"Email"})) - xDate.executeAction("CLICK", tuple()) - xComment.executeAction("CLICK", tuple()) - xInstructions.executeAction("TYPE", mkPropertyValues({"TEXT":"Instructions"})) - xOKBtn = xDialog.getChild("ok") - xOKBtn.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertSignatureLine") as xDialog: + + xName = xDialog.getChild("edit_name") + xTitle = xDialog.getChild("edit_title") + xEmail = xDialog.getChild("edit_email") + xComment = xDialog.getChild("checkbox_can_add_comments") + xDate = xDialog.getChild("checkbox_show_sign_date") + xInstructions = xDialog.getChild("edit_instructions") + + xName.executeAction("TYPE", mkPropertyValues({"TEXT":"Name"})) #set the signature line + xTitle.executeAction("TYPE", mkPropertyValues({"TEXT":"Title"})) + xEmail.executeAction("TYPE", mkPropertyValues({"TEXT":"Email"})) + xDate.executeAction("CLICK", tuple()) + xComment.executeAction("CLICK", tuple()) + xInstructions.executeAction("TYPE", mkPropertyValues({"TEXT":"Instructions"})) #check the signature Line in the document self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerName, "Name") diff --git a/sc/qa/uitest/sort/naturalSort.py b/sc/qa/uitest/sort/naturalSort.py index bd583a3c9a2c..d48755ac1cc0 100644 --- a/sc/qa/uitest/sort/naturalSort.py +++ b/sc/qa/uitest/sort/naturalSort.py @@ -29,14 +29,11 @@ class CalcNaturalSorting(UITestCase): enter_text_to_cell(gridwin, "A4", "MW180SSMOU456.994JIL4") enter_text_to_cell(gridwin, "A5", "MW101SSMOU456.996JIL4") #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xNatural = xDialog.getChild("naturalsort") - xNatural.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xNatural = xDialog.getChild("naturalsort") + xNatural.executeAction("CLICK", tuple()) #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW100SSMOU456.996JIL4") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "MW101SSMOU456.996JIL4") @@ -60,15 +57,12 @@ class CalcNaturalSorting(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "D1:D4"})) #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - if (get_state_as_dict(xNatural)["Selected"]) == "false": - xNatural.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "MW-1") self.assertEqual(get_cell_by_position(document, 0, 3, 1).getString(), "MW-2") @@ -91,17 +85,14 @@ class CalcNaturalSorting(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D1"})) #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - xleftright = xDialog.getChild("leftright") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - xleftright.executeAction("CLICK", tuple()) - if (get_state_as_dict(xNatural)["Selected"]) == "false": - xNatural.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xleftright.executeAction("CLICK", tuple()) + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW-1") diff --git a/sc/qa/uitest/sort/sorting.py b/sc/qa/uitest/sort/sorting.py index 59c00c7b258a..5529dbb7301d 100644 --- a/sc/qa/uitest/sort/sorting.py +++ b/sc/qa/uitest/sort/sorting.py @@ -54,16 +54,13 @@ class CalcSorting(UITestCase): #Select cell A3 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) #Open sort dialog by DATA - SORT /Switch to tabpage Options - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - #Verify that option "Range contains column labels" is set - xHeader = xDialog.getChild("header") - self.assertEqual(get_state_as_dict(xHeader)["Selected"], "true") - #Cancel dialog - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #Verify that option "Range contains column labels" is set + xHeader = xDialog.getChild("header") + self.assertEqual(get_state_as_dict(xHeader)["Selected"], "true") + #Cancel dialog #Select Range A1:B5 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) #Press toolbarbutton for descending sorting @@ -101,16 +98,13 @@ class CalcSorting(UITestCase): #Select cell B3 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) #Open sort dialog by DATA - SORT /Switch to tabpage Options - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - #Verify that option "Range contains column labels" is not set - xHeader = xDialog.getChild("header") - self.assertEqual(get_state_as_dict(xHeader)["Selected"], "false") - #Cancel dialog - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #Verify that option "Range contains column labels" is not set + xHeader = xDialog.getChild("header") + self.assertEqual(get_state_as_dict(xHeader)["Selected"], "false") + #Cancel dialog self.ui_test.close_doc() def test_Sorting_default_to_selected_column(self): @@ -236,68 +230,56 @@ class CalcSorting(UITestCase): #Select cell A3 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - #Verify that the first sort criteria is set to "Number(ascending)" - xSortKey1 = xDialog.getChild("sortlb") - xAsc = xDialog.getChild("up") - self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Number") - self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") - #Cancel dialog - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Number(ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Number") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog #Select cell B3 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - #Verify that the first sort criteria is set to "Misc (ascending)" - xSortKey1 = xDialog.getChild("sortlb") - xAsc = xDialog.getChild("up") - self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Misc") - self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") - #Cancel dialog - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Misc (ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Misc") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog #Select Range A1:B5 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) #Move the active cell inside the range to column A by using the TAB key gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - #Verify that the first sort criteria is set to "Number(ascending)" - xSortKey1 = xDialog.getChild("sortlb") - xAsc = xDialog.getChild("up") - self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Number") - self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") - #Cancel dialog - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Number(ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Number") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog #Select Range A1:B5 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) #Move the active cell inside the range to column B by using the TAB key gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - #Verify that the first sort criteria is set to "Misc (ascending)" - xSortKey1 = xDialog.getChild("sortlb") - xAsc = xDialog.getChild("up") - self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Misc") - self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") - #Cancel dialog - xCanc = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanc) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Misc (ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Misc") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/subtotals.py b/sc/qa/uitest/sort/subtotals.py index d8b9fcff9d32..63dd2675eacb 100644 --- a/sc/qa/uitest/sort/subtotals.py +++ b/sc/qa/uitest/sort/subtotals.py @@ -32,19 +32,15 @@ class Subtotals(UITestCase): enter_text_to_cell(gridwin, "A8", "1") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A9"})) - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSubTotals"): + pass - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 1) self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "") # check cancel button - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSubTotals", close_button="cancel"): + pass self.ui_test.close_doc() @@ -58,21 +54,18 @@ class Subtotals(UITestCase): # Select from the menu bar Data # Select option subtotal # Subtotal dialog displays - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - # Select group by: Category - xGroupBy = xDialog.getChild("group_by") - select_by_text(xGroupBy, "Category") - # Select calculate subtotals for the months - selected by default - # Select tab options - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "3") - # select option include formats - xformats = xDialog.getChild("formats") - xformats.executeAction("CLICK", tuple()) - # apply with OK - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSubTotals") as xDialog: + # Select group by: Category + xGroupBy = xDialog.getChild("group_by") + select_by_text(xGroupBy, "Category") + # Select calculate subtotals for the months - selected by default + # Select tab options + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") + # select option include formats + xformats = xDialog.getChild("formats") + xformats.executeAction("CLICK", tuple()) + # apply with OK self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 5).getValue(), 28000) @@ -83,17 +76,12 @@ class Subtotals(UITestCase): # 1 select all cells self.xUITest.executeCommand(".uno:SelectAll")#use uno command Menu Edit->Select All # 2 invoke sub-total menu and select none - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - xGroupBy = xDialog.getChild("group_by") - select_by_text(xGroupBy, "- none -") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSubTotals") as xDialog: + xGroupBy = xDialog.getChild("group_by") + select_by_text(xGroupBy, "- none -") # 2 invoke sort menu and... crash - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort", close_button="cancel"): + pass self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 8).getString(), "z") self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 8).getValue(), 8) @@ -104,45 +92,36 @@ class Subtotals(UITestCase): gridwin = XcalcDoc.getChild("grid_window") # 1. Open the test file # 2. Data->Subtotals - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - # 3. Group by->Trans date - xGroupBy = xDialog.getChild("group_by") - select_by_text(xGroupBy, "Trans Date") - # 4. Tick 'Calculate subtotals for' -> Amount (grid1) - xCheckListMenu = xDialog.getChild("grid1") - xTreeList = xCheckListMenu.getChild("columns") - xFirstEntry = xTreeList.getChild("2") - xFirstEntry.executeAction("CLICK", tuple()) - # 5. Click OK - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSubTotals") as xDialog: + # 3. Group by->Trans date + xGroupBy = xDialog.getChild("group_by") + select_by_text(xGroupBy, "Trans Date") + # 4. Tick 'Calculate subtotals for' -> Amount (grid1) + xCheckListMenu = xDialog.getChild("grid1") + xTreeList = xCheckListMenu.getChild("columns") + xFirstEntry = xTreeList.getChild("2") + xFirstEntry.executeAction("CLICK", tuple()) + # 5. Click OK # 6. Data->Subtotals - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - # 7. Group by->-none- - xGroupBy = xDialog.getChild("group_by") - select_by_text(xGroupBy, "- none -") - # 8. Untick 'Calculate subtotals for' -> Amount - xCheckListMenu = xDialog.getChild("grid1") - xTreeList = xCheckListMenu.getChild("columns") - xFirstEntry = xTreeList.getChild("2") - xFirstEntry.executeAction("CLICK", tuple()) - # 9. Click OK - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSubTotals") as xDialog: + # 7. Group by->-none- + xGroupBy = xDialog.getChild("group_by") + select_by_text(xGroupBy, "- none -") + # 8. Untick 'Calculate subtotals for' -> Amount + xCheckListMenu = xDialog.getChild("grid1") + xTreeList = xCheckListMenu.getChild("columns") + xFirstEntry = xTreeList.getChild("2") + xFirstEntry.executeAction("CLICK", tuple()) + # 9. Click OK # 10. Data->Sort - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - # 11. Sort key 1->Post Date. - sortkey1 = xDialog.getChild("sortlb") - select_by_text(sortkey1, "Post Date") - # 12. Sort key 2->-undefined- - sortkey2 = xDialog.getChild("sortuserlb") - select_by_text(sortkey2, "- undefined -") - # 13. Click OK - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + # 11. Sort key 1->Post Date. + sortkey1 = xDialog.getChild("sortlb") + select_by_text(sortkey1, "Post Date") + # 12. Sort key 2->-undefined- + sortkey2 = xDialog.getChild("sortuserlb") + select_by_text(sortkey2, "- undefined -") + # 13. Click OK self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 1).getValue(), -0.25) def test_tdf55734(self): @@ -153,14 +132,11 @@ class Subtotals(UITestCase): # 2. Place cursor in cell outside of subtotals range (e.g. B7) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B7"})) # 3. Data → Subtotals - self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") - xDialog = self.xUITest.getTopFocusWindow() - # 4. Group by: "- none -" - xGroupBy = xDialog.getChild("group_by") - select_by_text(xGroupBy, "- none -") - # 5. Press "OK" and watch LibreOffice crash. - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSubTotals") as xDialog: + # 4. Group by: "- none -" + xGroupBy = xDialog.getChild("group_by") + select_by_text(xGroupBy, "- none -") + # 5. Press "OK" and watch LibreOffice crash. self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getValue(), 1) self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 1).getValue(), 2) diff --git a/sc/qa/uitest/sort/tdf100517.py b/sc/qa/uitest/sort/tdf100517.py index defbb4a47cc6..b02f5a7a641f 100644 --- a/sc/qa/uitest/sort/tdf100517.py +++ b/sc/qa/uitest/sort/tdf100517.py @@ -16,18 +16,15 @@ class tdf100517(UITestCase): def execute_sort_dialog(self, gridwin, bIncludeNotes): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B3"})) - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") - xIncludeNotes = xDialog.getChild("includenotes") + xIncludeNotes = xDialog.getChild("includenotes") - if (get_state_as_dict(xIncludeNotes)["Selected"]) != bIncludeNotes: - xIncludeNotes.executeAction("CLICK", tuple()) + if (get_state_as_dict(xIncludeNotes)["Selected"]) != bIncludeNotes: + xIncludeNotes.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) def test_tdf100517(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") diff --git a/sc/qa/uitest/sort/tdf105301.py b/sc/qa/uitest/sort/tdf105301.py index 1dbdd84c0b0f..7e9aa32f4803 100644 --- a/sc/qa/uitest/sort/tdf105301.py +++ b/sc/qa/uitest/sort/tdf105301.py @@ -18,24 +18,21 @@ class tdf105301(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:R9"})) - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - self.assertEqual("Column B", get_state_as_dict(xDialog.getChild("sortlb"))['DisplayText']) - self.assertEqual("Column C", get_state_as_dict(xDialog.getChild("sortlb2"))['DisplayText']) - self.assertEqual("Column D", get_state_as_dict(xDialog.getChild("sortlb3"))['DisplayText']) - - # Without the fix in place, this test would have failed with - # AssertionError: 'Column E' != '- undefined -' - self.assertEqual("Column E", get_state_as_dict(xDialog.getChild("sortlb4"))['DisplayText']) - self.assertEqual("Column F", get_state_as_dict(xDialog.getChild("sortlb5"))['DisplayText']) - self.assertEqual("Column G", get_state_as_dict(xDialog.getChild("sortlb6"))['DisplayText']) - - # tdf#51828: Without the fix in place, this test would have failed here - self.assertEqual("- undefined -", get_state_as_dict(xDialog.getChild("sortlb7"))['DisplayText']) - - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + self.assertEqual("Column B", get_state_as_dict(xDialog.getChild("sortlb"))['DisplayText']) + self.assertEqual("Column C", get_state_as_dict(xDialog.getChild("sortlb2"))['DisplayText']) + self.assertEqual("Column D", get_state_as_dict(xDialog.getChild("sortlb3"))['DisplayText']) + + # Without the fix in place, this test would have failed with + # AssertionError: 'Column E' != '- undefined -' + self.assertEqual("Column E", get_state_as_dict(xDialog.getChild("sortlb4"))['DisplayText']) + self.assertEqual("Column F", get_state_as_dict(xDialog.getChild("sortlb5"))['DisplayText']) + self.assertEqual("Column G", get_state_as_dict(xDialog.getChild("sortlb6"))['DisplayText']) + + # tdf#51828: Without the fix in place, this test would have failed here + self.assertEqual("- undefined -", get_state_as_dict(xDialog.getChild("sortlb7"))['DisplayText']) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf126678.py b/sc/qa/uitest/sort/tdf126678.py index 0d63c8c35dd0..f6a13f2895bf 100644 --- a/sc/qa/uitest/sort/tdf126678.py +++ b/sc/qa/uitest/sort/tdf126678.py @@ -16,18 +16,15 @@ class tdf126678(UITestCase): def execute_sort_dialog(self, gridwin, bIncludeFormats): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B3"})) - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") - xIncludeFormats = xDialog.getChild("formats") + xIncludeFormats = xDialog.getChild("formats") - if (get_state_as_dict(xIncludeFormats)["Selected"]) != bIncludeFormats: - xIncludeFormats.executeAction("CLICK", tuple()) + if (get_state_as_dict(xIncludeFormats)["Selected"]) != bIncludeFormats: + xIncludeFormats.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) def test_tdf126678(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") diff --git a/sc/qa/uitest/sort/tdf49531.py b/sc/qa/uitest/sort/tdf49531.py index 6057f6e129d5..6dd77e6c7e13 100644 --- a/sc/qa/uitest/sort/tdf49531.py +++ b/sc/qa/uitest/sort/tdf49531.py @@ -25,25 +25,22 @@ class tdf49531(UITestCase): #Menu 'Data -> Sort -> Top to bottom - all otheroptions unchecked #Column B - Ascending' <ok> - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - xtopdown = xDialog.getChild("topdown") - xHeader = xDialog.getChild("header") - if (get_state_as_dict(xNatural)["Selected"]) == "true": - xNatural.executeAction("CLICK", tuple()) - if (get_state_as_dict(xHeader)["Selected"]) == "true": - xHeader.executeAction("CLICK", tuple()) - xtopdown.executeAction("CLICK", tuple()) - select_pos(xTabs, "0") - xSortKey1 = xDialog.getChild("sortlb") - xAsc = xDialog.getChild("up") - select_by_text(xSortKey1, "Column B") - xAsc.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xtopdown = xDialog.getChild("topdown") + xHeader = xDialog.getChild("header") + if (get_state_as_dict(xNatural)["Selected"]) == "true": + xNatural.executeAction("CLICK", tuple()) + if (get_state_as_dict(xHeader)["Selected"]) == "true": + xHeader.executeAction("CLICK", tuple()) + xtopdown.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + select_by_text(xSortKey1, "Column B") + xAsc.executeAction("CLICK", tuple()) #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "x") self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "0") diff --git a/sc/qa/uitest/sort/tdf53482.py b/sc/qa/uitest/sort/tdf53482.py index 5d9fb51ca031..01671558754a 100644 --- a/sc/qa/uitest/sort/tdf53482.py +++ b/sc/qa/uitest/sort/tdf53482.py @@ -23,24 +23,21 @@ class tdf53482(UITestCase): #1. Highlight cells to be sorted A8:J124 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A8:J124"})) #2. Click Data menu, Sort - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - #3. On Options tab, tick 'Range contains column labels' - xHeader = xDialog.getChild("header") - xHeader.executeAction("CLICK", tuple()) - if (get_state_as_dict(xHeader)["Selected"]) == "false": + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #3. On Options tab, tick 'Range contains column labels' + xHeader = xDialog.getChild("header") xHeader.executeAction("CLICK", tuple()) - #4. On Sort Criteria tab, set appropriate criteria - select_pos(xTabs, "0") - xDown = xDialog.getChild("down") - xDown.executeAction("CLICK", tuple()) - xSortKey1 = xDialog.getChild("sortlb") - select_by_text(xSortKey1, "Occupation") - #5. Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + if (get_state_as_dict(xHeader)["Selected"]) == "false": + xHeader.executeAction("CLICK", tuple()) + #4. On Sort Criteria tab, set appropriate criteria + select_pos(xTabs, "0") + xDown = xDialog.getChild("down") + xDown.executeAction("CLICK", tuple()) + xSortKey1 = xDialog.getChild("sortlb") + select_by_text(xSortKey1, "Occupation") + #5. Click Ok #6. Expected behavior: Ignore column labels when sorting self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 7).getString(), "Occupation") self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 8).getString(), "Travel Industry") @@ -60,22 +57,19 @@ class tdf53482(UITestCase): #1. Highlight cells to be sorted gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) #2. Click Data menu, Sort - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - #3. On Options tab, tick 'Range contains column labels' - xHeader = xDialog.getChild("header") - xHeader.executeAction("CLICK", tuple()) - if (get_state_as_dict(xHeader)["Selected"]) == "false": + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #3. On Options tab, tick 'Range contains column labels' + xHeader = xDialog.getChild("header") xHeader.executeAction("CLICK", tuple()) - #4. On Sort Criteria tab, set appropriate criteria - select_pos(xTabs, "0") - xDown = xDialog.getChild("down") - xDown.executeAction("CLICK", tuple()) - #5. Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + if (get_state_as_dict(xHeader)["Selected"]) == "false": + xHeader.executeAction("CLICK", tuple()) + #4. On Sort Criteria tab, set appropriate criteria + select_pos(xTabs, "0") + xDown = xDialog.getChild("down") + xDown.executeAction("CLICK", tuple()) + #5. Click Ok #6. Expected behavior: Ignore column labels when sorting self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Misc") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "s") diff --git a/sc/qa/uitest/sort/tdf54018.py b/sc/qa/uitest/sort/tdf54018.py index 77ce70266074..62cea8d2e961 100644 --- a/sc/qa/uitest/sort/tdf54018.py +++ b/sc/qa/uitest/sort/tdf54018.py @@ -23,16 +23,13 @@ class tdf54018(UITestCase): #click top left columns / rows heading field to select all cells self.xUITest.executeCommand(".uno:SelectAll") #Menu 'Data -> Sort -> Column D -> Descending' <ok> - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xSortKey1 = xDialog.getChild("sortlb") - xdown = xDialog.getChild("down") - select_by_text(xSortKey1, "Column B") - xdown.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xSortKey1 = xDialog.getChild("sortlb") + xdown = xDialog.getChild("down") + select_by_text(xSortKey1, "Column B") + xdown.executeAction("CLICK", tuple()) #Bug: When progress bar reaches 40% LibO Stops responding #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 0).getString(), "7") diff --git a/sc/qa/uitest/sort/tdf57465.py b/sc/qa/uitest/sort/tdf57465.py index b993c8b14771..8f40df5d704b 100644 --- a/sc/qa/uitest/sort/tdf57465.py +++ b/sc/qa/uitest/sort/tdf57465.py @@ -19,24 +19,21 @@ class tdf57465(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:G4"})) - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") - xHeader = xDialog.getChild("header") - if (get_state_as_dict(xHeader)["Selected"]) == 'true': - xHeader.executeAction("CLICK", tuple()) + xHeader = xDialog.getChild("header") + if (get_state_as_dict(xHeader)["Selected"]) == 'true': + xHeader.executeAction("CLICK", tuple()) - xLeftRight = xDialog.getChild("leftright") - xLeftRight.executeAction("CLICK", tuple()) + xLeftRight = xDialog.getChild("leftright") + xLeftRight.executeAction("CLICK", tuple()) - select_pos(xTabs, "0") + select_pos(xTabs, "0") - self.assertEqual("Row 1", get_state_as_dict(xDialog.getChild("sortlb"))['DisplayText']) + self.assertEqual("Row 1", get_state_as_dict(xDialog.getChild("sortlb"))['DisplayText']) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) self.assertEqual("a", get_cell_by_position(calc_doc, 0, 1, 1).getString()) diff --git a/sc/qa/uitest/sort/tdf91305.py b/sc/qa/uitest/sort/tdf91305.py index 340efdb3a531..e3699c05de6a 100644 --- a/sc/qa/uitest/sort/tdf91305.py +++ b/sc/qa/uitest/sort/tdf91305.py @@ -52,30 +52,24 @@ class tdf91305(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C1"})) #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - xleftright = xDialog.getChild("leftright") - select_pos(xTabs, "1") - xleftright.executeAction("CLICK", tuple()) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + select_pos(xTabs, "1") + xleftright.executeAction("CLICK", tuple()) #verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aa") self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "cc") self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "ff") #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - xleftright = xDialog.getChild("leftright") - xdown = xDialog.getChild("down") - select_pos(xTabs, "1") - xleftright.executeAction("CLICK", tuple()) - select_pos(xTabs, "0") - xdown.executeAction("CLICK", tuple()) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + xdown = xDialog.getChild("down") + select_pos(xTabs, "1") + xleftright.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xdown.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff") self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "cc") self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "aa") diff --git a/sc/qa/uitest/sort/tdf95192.py b/sc/qa/uitest/sort/tdf95192.py index 6b17aed1a93c..35dfd44f4183 100644 --- a/sc/qa/uitest/sort/tdf95192.py +++ b/sc/qa/uitest/sort/tdf95192.py @@ -21,14 +21,11 @@ class tdf95192(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - xNatural.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xNatural.executeAction("CLICK", tuple()) #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "Sal. Capra 1/17") self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "Sal. Capra 1/20") diff --git a/sc/qa/uitest/sort/tdf99208.py b/sc/qa/uitest/sort/tdf99208.py index d4511816465d..28cce8bb7a54 100644 --- a/sc/qa/uitest/sort/tdf99208.py +++ b/sc/qa/uitest/sort/tdf99208.py @@ -24,28 +24,25 @@ class tdf99208(UITestCase): #Menu 'Data -> Sort #Column A - Ascending' <ok> - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - xtopdown = xDialog.getChild("topdown") - xHeader = xDialog.getChild("header") - xFormats = xDialog.getChild("formats") - if (get_state_as_dict(xNatural)["Selected"]) == "false": - xNatural.executeAction("CLICK", tuple()) - if (get_state_as_dict(xHeader)["Selected"]) == "false": - xHeader.executeAction("CLICK", tuple()) - if (get_state_as_dict(xFormats)["Selected"]) == "false": - xFormats.executeAction("CLICK", tuple()) - xtopdown.executeAction("CLICK", tuple()) - select_pos(xTabs, "0") - xSortKey1 = xDialog.getChild("sortlb") - xAsc = xDialog.getChild("up") - select_by_text(xSortKey1, "FODMAP") - xAsc.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xtopdown = xDialog.getChild("topdown") + xHeader = xDialog.getChild("header") + xFormats = xDialog.getChild("formats") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + if (get_state_as_dict(xHeader)["Selected"]) == "false": + xHeader.executeAction("CLICK", tuple()) + if (get_state_as_dict(xFormats)["Selected"]) == "false": + xFormats.executeAction("CLICK", tuple()) + xtopdown.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + select_by_text(xSortKey1, "FODMAP") + xAsc.executeAction("CLICK", tuple()) #Verify Expected: Values column B sorted ascending, column "control" unsorted self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "FODMAP") self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "agave") diff --git a/sc/qa/uitest/sort/tdf99627.py b/sc/qa/uitest/sort/tdf99627.py index 08be9e20da35..5f40a2d00b99 100644 --- a/sc/qa/uitest/sort/tdf99627.py +++ b/sc/qa/uitest/sort/tdf99627.py @@ -22,17 +22,14 @@ class tdf99627(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - xdown = xDialog.getChild("down") - xNatural.executeAction("CLICK", tuple()) - select_pos(xTabs, "0") - xdown.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xdown = xDialog.getChild("down") + xNatural.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xdown.executeAction("CLICK", tuple()) #Verify self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 1).getString(), "2998") self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 2998).getString(), "1") diff --git a/sc/qa/uitest/sort/tdf99773.py b/sc/qa/uitest/sort/tdf99773.py index 099788fa1428..9647278a1f5b 100644 --- a/sc/qa/uitest/sort/tdf99773.py +++ b/sc/qa/uitest/sort/tdf99773.py @@ -31,15 +31,12 @@ class tdf99773(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A6"})) #Open sort dialog by DATA - SORT - self.ui_test.execute_dialog_through_command(".uno:DataSort") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - if (get_state_as_dict(xNatural)["Selected"]) == "false": - xNatural.executeAction("CLICK", tuple()) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A 2") self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "A 5") diff --git a/sc/qa/uitest/validity/tdf137945.py b/sc/qa/uitest/validity/tdf137945.py index 4885ab3d5f42..349bff23577e 100644 --- a/sc/qa/uitest/validity/tdf137945.py +++ b/sc/qa/uitest/validity/tdf137945.py @@ -13,19 +13,16 @@ class Tdf137945(UITestCase): def test_tdf137945(self): with self.ui_test.load_file(get_url_for_data_file("tdf137945.ods")) as calc_doc: - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xInput = xDialog.getChild("inputhelp") - xTitle = xDialog.getChild("title") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xInput = xDialog.getChild("inputhelp") + xTitle = xDialog.getChild("title") - self.assertEqual("test", get_state_as_dict(xTitle)['Text']) - # Without the fix in place, this test would have failed with - # '1 2 3 4 5 10 end' != '1 2 3 4 5 10 end' - self.assertEqual("1 2 3 4 5 10 end", get_state_as_dict(xInput)['Text']) + self.assertEqual("test", get_state_as_dict(xTitle)['Text']) + # Without the fix in place, this test would have failed with + # '1 2 3 4 5 10 end' != '1 2 3 4 5 10 end' + self.assertEqual("1 2 3 4 5 10 end", get_state_as_dict(xInput)['Text']) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/validity/tdf138134.py b/sc/qa/uitest/validity/tdf138134.py index 1bbdc443d60e..f104fc3bfc84 100644 --- a/sc/qa/uitest/validity/tdf138134.py +++ b/sc/qa/uitest/validity/tdf138134.py @@ -26,22 +26,19 @@ class DetectiveCircle(UITestCase): #Select the cells to be validated gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) #Apply Data > Validity ... > Whole Numbers - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xdata = xDialog.getChild("data") - xmin = xDialog.getChild("min") - xmax = xDialog.getChild("max") - - select_by_text(xallow, "Whole Numbers") - xallowempty.executeAction("CLICK", tuple()) - select_by_text(xdata, "equal") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"5"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xdata = xDialog.getChild("data") + xmin = xDialog.getChild("min") + xmax = xDialog.getChild("max") + + select_by_text(xallow, "Whole Numbers") + xallowempty.executeAction("CLICK", tuple()) + select_by_text(xdata, "equal") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"5"})) self.xUITest.executeCommand(".uno:ShowInvalid") diff --git a/sc/qa/uitest/validity/tdf53920.py b/sc/qa/uitest/validity/tdf53920.py index e1a4fc87efaa..ca651eb0cfbb 100644 --- a/sc/qa/uitest/validity/tdf53920.py +++ b/sc/qa/uitest/validity/tdf53920.py @@ -29,48 +29,36 @@ class tdf53920(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3", "EXTEND":"1"})) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A5", "EXTEND":"1"})) #Apply Data > Validity ... > Cell Range - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xmin = xDialog.getChild("min") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xmin = xDialog.getChild("min") - select_by_text(xallow, "Cell range") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$C$1:$C$3"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + select_by_text(xallow, "Cell range") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$C$1:$C$3"})) #Expected behavior: All selected cells validate data. gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xallow = xDialog.getChild("allow") - xmin = xDialog.getChild("min") - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Cell range") - self.assertEqual(get_state_as_dict(xmin)["Text"], "$Sheet1.$C$1:$C$3") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xmin = xDialog.getChild("min") + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Cell range") + self.assertEqual(get_state_as_dict(xmin)["Text"], "$Sheet1.$C$1:$C$3") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xallow = xDialog.getChild("allow") - xmin = xDialog.getChild("min") - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Cell range") - self.assertEqual(get_state_as_dict(xmin)["Text"], "$Sheet1.$C$1:$C$3") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xmin = xDialog.getChild("min") + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Cell range") + self.assertEqual(get_state_as_dict(xmin)["Text"], "$Sheet1.$C$1:$C$3") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A5"})) - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xallow = xDialog.getChild("allow") - xmin = xDialog.getChild("min") - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Cell range") - self.assertEqual(get_state_as_dict(xmin)["Text"], "$Sheet1.$C$1:$C$3") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xmin = xDialog.getChild("min") + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Cell range") + self.assertEqual(get_state_as_dict(xmin)["Text"], "$Sheet1.$C$1:$C$3") self.ui_test.close_doc() diff --git a/sc/qa/uitest/validity/tdf65686.py b/sc/qa/uitest/validity/tdf65686.py index 557701b1dd7f..83d691026968 100644 --- a/sc/qa/uitest/validity/tdf65686.py +++ b/sc/qa/uitest/validity/tdf65686.py @@ -23,35 +23,29 @@ class tdf65686(UITestCase): #- Select Allow List #- Enter Entries Aap Noot Mies #- OK - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - minlist = xDialog.getChild("minlist") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + minlist = xDialog.getChild("minlist") - select_by_text(xallow, "List") - minlist.executeAction("TYPE", mkPropertyValues({"TEXT":"Aap"})) - minlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - minlist.executeAction("TYPE", mkPropertyValues({"TEXT":"Noot"})) - minlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - minlist.executeAction("TYPE", mkPropertyValues({"TEXT":"Mies"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + select_by_text(xallow, "List") + minlist.executeAction("TYPE", mkPropertyValues({"TEXT":"Aap"})) + minlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + minlist.executeAction("TYPE", mkPropertyValues({"TEXT":"Noot"})) + minlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + minlist.executeAction("TYPE", mkPropertyValues({"TEXT":"Mies"})) #- again open Data > Validity #> there are empty lines in the list Entries - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - minlist = xDialog.getChild("minlist") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + minlist = xDialog.getChild("minlist") - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "List") - self.assertEqual(get_state_as_dict(minlist)["Text"], "Aap\nNoot\nMies") + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "List") + self.assertEqual(get_state_as_dict(minlist)["Text"], "Aap\nNoot\nMies") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) self.ui_test.close_doc() diff --git a/sc/qa/uitest/validity/tdf96698.py b/sc/qa/uitest/validity/tdf96698.py index a3bd19c2f3ef..007967410e49 100644 --- a/sc/qa/uitest/validity/tdf96698.py +++ b/sc/qa/uitest/validity/tdf96698.py @@ -22,108 +22,84 @@ class tdf96698(UITestCase): #A general validity check for the entered new content of the active cell - especially for text #with a custom formula like in Excel is not possible. gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") - - select_by_text(xallow, "Custom") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"ISERROR(FIND(\",\",B2))"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") + + select_by_text(xallow, "Custom") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"ISERROR(FIND(\",\",B2))"})) #verify - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") - self.assertEqual(get_state_as_dict(xmin)["Text"], "ISERROR(FIND(\",\",B2))") + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") + self.assertEqual(get_state_as_dict(xmin)["Text"], "ISERROR(FIND(\",\",B2))") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") - - select_by_text(xallow, "Custom") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"NOT(ISERROR(B3))"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") + + select_by_text(xallow, "Custom") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"NOT(ISERROR(B3))"})) #verify - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") - self.assertEqual(get_state_as_dict(xmin)["Text"], "NOT(ISERROR(B3))") + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") + self.assertEqual(get_state_as_dict(xmin)["Text"], "NOT(ISERROR(B3))") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A7"})) - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") - - select_by_text(xallow, "Custom") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"ISERROR(FIND(\",\",A7))"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") + + select_by_text(xallow, "Custom") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"ISERROR(FIND(\",\",A7))"})) #verify - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") - self.assertEqual(get_state_as_dict(xmin)["Text"], "ISERROR(FIND(\",\",A7))") + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") + self.assertEqual(get_state_as_dict(xmin)["Text"], "ISERROR(FIND(\",\",A7))") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A8"})) - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") - - select_by_text(xallow, "Custom") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"NOT(ISERROR(A8))"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") + + select_by_text(xallow, "Custom") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"NOT(ISERROR(A8))"})) #verify - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") - self.assertEqual(get_state_as_dict(xmin)["Text"], "NOT(ISERROR(A8))") + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") + self.assertEqual(get_state_as_dict(xmin)["Text"], "NOT(ISERROR(A8))") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) self.ui_test.close_doc() diff --git a/sc/qa/uitest/validity/validity.py b/sc/qa/uitest/validity/validity.py index dc36e96f87df..a10999c8a9fb 100644 --- a/sc/qa/uitest/validity/validity.py +++ b/sc/qa/uitest/validity/validity.py @@ -20,39 +20,33 @@ class validity(UITestCase): document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xdata = xDialog.getChild("data") - xmin = xDialog.getChild("min") - xmax = xDialog.getChild("max") - - select_by_text(xallow, "Whole Numbers") - xallowempty.executeAction("CLICK", tuple()) - select_by_text(xdata, "valid range") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - xmax.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xdata = xDialog.getChild("data") + xmin = xDialog.getChild("min") + xmax = xDialog.getChild("max") + + select_by_text(xallow, "Whole Numbers") + xallowempty.executeAction("CLICK", tuple()) + select_by_text(xdata, "valid range") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + xmax.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) #reopen and verify - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xdata = xDialog.getChild("data") - xmin = xDialog.getChild("min") - xmax = xDialog.getChild("max") - - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Whole Numbers") - self.assertEqual(get_state_as_dict(xallowempty)["Selected"], "false") - self.assertEqual(get_state_as_dict(xdata)["SelectEntryText"], "valid range") - self.assertEqual(get_state_as_dict(xmin)["Text"], "1") - self.assertEqual(get_state_as_dict(xmax)["Text"], "2") - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation", close_button="cancel") as xDialog: + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xdata = xDialog.getChild("data") + xmin = xDialog.getChild("min") + xmax = xDialog.getChild("max") + + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Whole Numbers") + self.assertEqual(get_state_as_dict(xallowempty)["Selected"], "false") + self.assertEqual(get_state_as_dict(xdata)["SelectEntryText"], "valid range") + self.assertEqual(get_state_as_dict(xmin)["Text"], "1") + self.assertEqual(get_state_as_dict(xmax)["Text"], "2") self.ui_test.close_doc() @@ -64,33 +58,27 @@ class validity(UITestCase): document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xtsbhelp = xDialog.getChild("tsbhelp") - xtitle = xDialog.getChild("title") - xinputhelp = xDialog.getChild("inputhelp") - - xtsbhelp.executeAction("CLICK", tuple()) - xtitle.executeAction("TYPE", mkPropertyValues({"TEXT":"A"})) - xinputhelp.executeAction("TYPE", mkPropertyValues({"TEXT":"B"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xtsbhelp = xDialog.getChild("tsbhelp") + xtitle = xDialog.getChild("title") + xinputhelp = xDialog.getChild("inputhelp") + + xtsbhelp.executeAction("CLICK", tuple()) + xtitle.executeAction("TYPE", mkPropertyValues({"TEXT":"A"})) + xinputhelp.executeAction("TYPE", mkPropertyValues({"TEXT":"B"})) #reopen and verify - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - xtsbhelp = xDialog.getChild("tsbhelp") - xtitle = xDialog.getChild("title") - xinputhelp = xDialog.getChild("inputhelp") - # print(get_state_as_dict(xtsbhelp)) - select_pos(xTabs, "1") - self.assertEqual(get_state_as_dict(xtsbhelp)["Selected"], "true") - self.assertEqual(get_state_as_dict(xtitle)["Text"], "A") - self.assertEqual(get_state_as_dict(xinputhelp)["Text"], "B") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + xtsbhelp = xDialog.getChild("tsbhelp") + xtitle = xDialog.getChild("title") + xinputhelp = xDialog.getChild("inputhelp") + # print(get_state_as_dict(xtsbhelp)) + select_pos(xTabs, "1") + self.assertEqual(get_state_as_dict(xtsbhelp)["Selected"], "true") + self.assertEqual(get_state_as_dict(xtitle)["Text"], "A") + self.assertEqual(get_state_as_dict(xinputhelp)["Text"], "B") self.ui_test.close_doc() @@ -102,35 +90,29 @@ class validity(UITestCase): document = self.ui_test.get_component() gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "2") + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") - xactionCB = xDialog.getChild("actionCB") - xerroralerttitle = xDialog.getChild("erroralert_title") - xerrorMsg = xDialog.getChild("errorMsg") + xactionCB = xDialog.getChild("actionCB") + xerroralerttitle = xDialog.getChild("erroralert_title") + xerrorMsg = xDialog.getChild("errorMsg") - select_by_text(xactionCB, "Warning") - xerroralerttitle.executeAction("TYPE", mkPropertyValues({"TEXT":"Warn"})) - xerrorMsg.executeAction("TYPE", mkPropertyValues({"TEXT":"Warn2"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + select_by_text(xactionCB, "Warning") + xerroralerttitle.executeAction("TYPE", mkPropertyValues({"TEXT":"Warn"})) + xerrorMsg.executeAction("TYPE", mkPropertyValues({"TEXT":"Warn2"})) #reopen and verify - self.ui_test.execute_dialog_through_command(".uno:Validation") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "2") - - xactionCB = xDialog.getChild("actionCB") - xerroralerttitle = xDialog.getChild("erroralert_title") - xerrorMsg = xDialog.getChild("errorMsg") - - self.assertEqual(get_state_as_dict(xactionCB)["SelectEntryText"], "Warning") - self.assertEqual(get_state_as_dict(xerroralerttitle)["Text"], "Warn") - self.assertEqual(get_state_as_dict(xerrorMsg)["Text"], "Warn2") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + + xactionCB = xDialog.getChild("actionCB") + xerroralerttitle = xDialog.getChild("erroralert_title") + xerrorMsg = xDialog.getChild("errorMsg") + + self.assertEqual(get_state_as_dict(xactionCB)["SelectEntryText"], "Warning") + self.assertEqual(get_state_as_dict(xerroralerttitle)["Text"], "Warn") + self.assertEqual(get_state_as_dict(xerrorMsg)["Text"], "Warn2") self.ui_test.close_doc() |