summaryrefslogtreecommitdiff
path: root/uitest
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-06-29 11:35:20 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-06-29 13:26:30 +0200
commit8fe4a2cb1ad3b4819e069179cc11430c5127613c (patch)
treef8265029a84d6a97b9abbe90ab66599749892fa0 /uitest
parent8b961addb7887a8b8dc8dbc6758c3dc7c1068ac4 (diff)
uitest: guard remaining execute_dialog_through_command
Mostly done with a script for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac < UITest: introduce guarded context managers > Change-Id: Ib8e7c5f5e2c9b8a7756fe533ea4f30349dd68761 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118076 Tested-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'uitest')
-rw-r--r--uitest/demo_ui/char_dialog.py9
-rw-r--r--uitest/demo_ui/checkbox.py9
-rw-r--r--uitest/demo_ui/hierarchy.py15
-rw-r--r--uitest/demo_ui/listbox.py14
-rw-r--r--uitest/demo_ui/radiobutton.py9
-rw-r--r--uitest/demo_ui/spinfield.py47
-rw-r--r--uitest/demo_ui/tabdialog.py14
-rw-r--r--uitest/impress_tests/backgrounds.py30
-rw-r--r--uitest/impress_tests/drawinglayer.py46
-rw-r--r--uitest/uitest/uihelper/common.py59
-rw-r--r--uitest/uitest/uihelper/testDialog.py28
11 files changed, 106 insertions, 174 deletions
diff --git a/uitest/demo_ui/char_dialog.py b/uitest/demo_ui/char_dialog.py
index 5dd0212ee719..3b7083b1dba1 100644
--- a/uitest/demo_ui/char_dialog.py
+++ b/uitest/demo_ui/char_dialog.py
@@ -13,15 +13,12 @@ class CharDialogText(UITestCase):
def test_select_char(self):
self.ui_test.create_doc_in_start_center("calc")
- self.ui_test.execute_dialog_through_command(".uno:InsertSymbol")
- xCharDialog = self.xUITest.getTopFocusWindow()
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertSymbol", close_button="cancel") as xCharDialog:
- xCharSet = xCharDialog.getChild("showcharset")
+ xCharSet = xCharDialog.getChild("showcharset")
- xCharSet.executeAction("SELECT", mkPropertyValues({"COLUMN": "2", "ROW": "2"}))
+ xCharSet.executeAction("SELECT", mkPropertyValues({"COLUMN": "2", "ROW": "2"}))
- xCancelBtn = xCharDialog.getChild("cancel")
- self.ui_test.close_dialog_through_button(xCancelBtn)
self.ui_test.close_doc()
diff --git a/uitest/demo_ui/checkbox.py b/uitest/demo_ui/checkbox.py
index 114473d53851..ffee343bf50b 100644
--- a/uitest/demo_ui/checkbox.py
+++ b/uitest/demo_ui/checkbox.py
@@ -15,13 +15,10 @@ class CheckBoxTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = self.xUITest.getTopFocusWindow()
- xNegativeNumRedCB = xCellsDlg.getChild("negnumred")
- xNegativeNumRedCB.executeAction("CLICK",tuple())
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xCellsDlg:
+ xNegativeNumRedCB = xCellsDlg.getChild("negnumred")
+ xNegativeNumRedCB.executeAction("CLICK",tuple())
- okBtn = xCellsDlg.getChild("ok")
- self.ui_test.close_dialog_through_button(okBtn)
self.ui_test.close_doc()
diff --git a/uitest/demo_ui/hierarchy.py b/uitest/demo_ui/hierarchy.py
index f5434366fda4..73c15bb607e1 100644
--- a/uitest/demo_ui/hierarchy.py
+++ b/uitest/demo_ui/hierarchy.py
@@ -17,18 +17,15 @@ class CheckBoxTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- self.ui_test.execute_dialog_through_command(".uno:About")
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:About", close_button="btnClose") as xAboutDlg:
- xAboutDlg = self.xUITest.getTopFocusWindow()
- json_string = xAboutDlg.getHierarchy()
- print(json_string)
- json_content = json.loads(json_string)
- print(json_content)
- print(json.dumps(json_content, indent=4))
+ json_string = xAboutDlg.getHierarchy()
+ print(json_string)
+ json_content = json.loads(json_string)
+ print(json_content)
+ print(json.dumps(json_content, indent=4))
- closeBtn = xAboutDlg.getChild("btnClose")
- self.ui_test.close_dialog_through_button(closeBtn)
self.ui_test.close_doc()
diff --git a/uitest/demo_ui/listbox.py b/uitest/demo_ui/listbox.py
index 7e9ae16e6543..9784178d20a7 100644
--- a/uitest/demo_ui/listbox.py
+++ b/uitest/demo_ui/listbox.py
@@ -16,11 +16,8 @@ class ListBoxTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = self.xUITest.getTopFocusWindow()
-
- xOkBtn = xCellsDlg.getChild("ok")
- self.ui_test.close_dialog_through_button(xOkBtn)
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog"):
+ pass
self.ui_test.close_doc()
@@ -28,11 +25,8 @@ class ListBoxTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = self.xUITest.getTopFocusWindow()
-
- xOkBtn = xCellsDlg.getChild("ok")
- self.ui_test.close_dialog_through_button(xOkBtn)
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog"):
+ pass
self.ui_test.close_doc()
diff --git a/uitest/demo_ui/radiobutton.py b/uitest/demo_ui/radiobutton.py
index bb2f5bd07440..f3331fa18863 100644
--- a/uitest/demo_ui/radiobutton.py
+++ b/uitest/demo_ui/radiobutton.py
@@ -27,13 +27,10 @@ class RadioButtonTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = self.xUITest.getTopFocusWindow()
- xNegativeNumRedCB = xCellsDlg.getChild("negnumred")
- xNegativeNumRedCB.executeAction("CLICK",tuple())
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xCellsDlg:
+ xNegativeNumRedCB = xCellsDlg.getChild("negnumred")
+ xNegativeNumRedCB.executeAction("CLICK",tuple())
- okBtn = xCellsDlg.getChild("ok")
- self.ui_test.close_dialog_through_button(okBtn)
self.ui_test.close_doc()
diff --git a/uitest/demo_ui/spinfield.py b/uitest/demo_ui/spinfield.py
index a74e47206274..a0e983ea81b6 100644
--- a/uitest/demo_ui/spinfield.py
+++ b/uitest/demo_ui/spinfield.py
@@ -16,17 +16,14 @@ class SpinFieldTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = self.xUITest.getTopFocusWindow()
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xCellsDlg:
- xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
- xDecimalPlaces.executeAction("UP", tuple())
+ xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
+ xDecimalPlaces.executeAction("UP", tuple())
- decimal_places_state = get_state_as_dict(xDecimalPlaces)
- assert(decimal_places_state["Text"] == "2")
+ decimal_places_state = get_state_as_dict(xDecimalPlaces)
+ assert(decimal_places_state["Text"] == "2")
- okBtn = xCellsDlg.getChild("ok")
- self.ui_test.close_dialog_through_button(okBtn)
self.ui_test.close_doc()
@@ -34,23 +31,20 @@ class SpinFieldTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = self.xUITest.getTopFocusWindow()
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xCellsDlg:
- xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
- xDecimalPlaces.executeAction("UP", tuple())
- xDecimalPlaces.executeAction("UP", tuple())
+ xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
+ xDecimalPlaces.executeAction("UP", tuple())
+ xDecimalPlaces.executeAction("UP", tuple())
- decimal_places_state = get_state_as_dict(xDecimalPlaces)
- assert(decimal_places_state["Text"] == "3")
+ decimal_places_state = get_state_as_dict(xDecimalPlaces)
+ assert(decimal_places_state["Text"] == "3")
- xDecimalPlaces.executeAction("DOWN", tuple())
+ xDecimalPlaces.executeAction("DOWN", tuple())
- decimal_places_state = get_state_as_dict(xDecimalPlaces)
- assert(decimal_places_state["Text"] == "2")
+ decimal_places_state = get_state_as_dict(xDecimalPlaces)
+ assert(decimal_places_state["Text"] == "2")
- okBtn = xCellsDlg.getChild("ok")
- self.ui_test.close_dialog_through_button(okBtn)
self.ui_test.close_doc()
@@ -58,17 +52,14 @@ class SpinFieldTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = self.xUITest.getTopFocusWindow()
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xCellsDlg:
- xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
- type_text(xDecimalPlaces, "4")
+ xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
+ type_text(xDecimalPlaces, "4")
- decimal_places_state = get_state_as_dict(xDecimalPlaces)
- assert(decimal_places_state["Text"] == "41")
+ decimal_places_state = get_state_as_dict(xDecimalPlaces)
+ assert(decimal_places_state["Text"] == "41")
- okBtn = xCellsDlg.getChild("ok")
- self.ui_test.close_dialog_through_button(okBtn)
self.ui_test.close_doc()
diff --git a/uitest/demo_ui/tabdialog.py b/uitest/demo_ui/tabdialog.py
index 861b270989d9..bfa6129f06de 100644
--- a/uitest/demo_ui/tabdialog.py
+++ b/uitest/demo_ui/tabdialog.py
@@ -16,11 +16,8 @@ class TabDialogTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = self.xUITest.getTopFocusWindow()
-
- xOkBtn = xCellsDlg.getChild("ok")
- self.ui_test.close_dialog_through_button(xOkBtn)
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog"):
+ pass
self.ui_test.close_doc()
@@ -28,11 +25,8 @@ class TabDialogTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = self.xUITest.getTopFocusWindow()
-
- xOkBtn = xCellsDlg.getChild("ok")
- self.ui_test.close_dialog_through_button(xOkBtn)
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog"):
+ pass
self.ui_test.close_doc()
diff --git a/uitest/impress_tests/backgrounds.py b/uitest/impress_tests/backgrounds.py
index 123c7ef81021..1ab001fea91f 100644
--- a/uitest/impress_tests/backgrounds.py
+++ b/uitest/impress_tests/backgrounds.py
@@ -113,33 +113,27 @@ class ImpressBackgrounds(UITestCase):
buttons = ['btnbitmap', 'btncolor', 'btngradient', 'btnhatch', 'btnpattern']
for index, button in enumerate(buttons):
- self.ui_test.execute_dialog_through_command(".uno:PageSetup")
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:PageSetup") as xPageSetupDlg:
- xPageSetupDlg = self.xUITest.getTopFocusWindow()
- tabcontrol = xPageSetupDlg.getChild("tabcontrol")
- select_pos(tabcontrol, "1")
+ tabcontrol = xPageSetupDlg.getChild("tabcontrol")
+ select_pos(tabcontrol, "1")
- xBtn = xPageSetupDlg.getChild(button)
- xBtn.executeAction("CLICK", tuple())
+ xBtn = xPageSetupDlg.getChild(button)
+ xBtn.executeAction("CLICK", tuple())
- # tdf#100024: Without the fix in place, this test would have crashed here
- # changing the background to bitmap
- xOkBtn = xPageSetupDlg.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
+ # tdf#100024: Without the fix in place, this test would have crashed here
+ # changing the background to bitmap
self.checkDefaultBackground(button)
- self.ui_test.execute_dialog_through_command(".uno:PageSetup")
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:PageSetup") as xPageSetupDlg:
- xPageSetupDlg = self.xUITest.getTopFocusWindow()
- tabcontrol = xPageSetupDlg.getChild("tabcontrol")
- select_pos(tabcontrol, "1")
+ tabcontrol = xPageSetupDlg.getChild("tabcontrol")
+ select_pos(tabcontrol, "1")
- xBtn = xPageSetupDlg.getChild('btnnone')
- xBtn.executeAction("CLICK", tuple())
+ xBtn = xPageSetupDlg.getChild('btnnone')
+ xBtn.executeAction("CLICK", tuple())
- xOkBtn = xPageSetupDlg.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
self.checkDefaultBackground('btnnone')
diff --git a/uitest/impress_tests/drawinglayer.py b/uitest/impress_tests/drawinglayer.py
index 7b33e369d2e6..ca09945aeaea 100644
--- a/uitest/impress_tests/drawinglayer.py
+++ b/uitest/impress_tests/drawinglayer.py
@@ -44,18 +44,12 @@ class ImpressDrawinglayerTest(UITestCase):
xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
self.assertEqual("com.sun.star.drawing.SvxShapeCollection", document.CurrentSelection.getImplementationName())
- self.ui_test.execute_dialog_through_command(".uno:Size")
-
- xDialog = self.xUITest.getTopFocusWindow()
-
- self.assertEqual('25.2', get_state_as_dict(xDialog.getChild('MTR_FLD_WIDTH'))['Value'])
- self.assertEqual('9.13', get_state_as_dict(xDialog.getChild('MTR_FLD_HEIGHT'))['Value'])
- self.assertEqual('2.4', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_X'))['Value'])
- self.assertEqual('4.69', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_Y'))['Value'])
- self.assertEqual('0', get_state_as_dict(xDialog.getChild('NF_ANGLE'))['Value'])
-
- xOK = xDialog.getChild("ok")
- self.ui_test.close_dialog_through_button(xOK)
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:Size") as xDialog:
+ self.assertEqual('25.2', get_state_as_dict(xDialog.getChild('MTR_FLD_WIDTH'))['Value'])
+ self.assertEqual('9.13', get_state_as_dict(xDialog.getChild('MTR_FLD_HEIGHT'))['Value'])
+ self.assertEqual('2.4', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_X'))['Value'])
+ self.assertEqual('4.69', 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("com.sun.star.drawing.SvxShapeCollection", document.CurrentSelection.getImplementationName())
xEditWin.executeAction("DESELECT", tuple())
@@ -95,18 +89,12 @@ class ImpressDrawinglayerTest(UITestCase):
xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
self.assertEqual("com.sun.star.drawing.SvxShapeCollection", document.CurrentSelection.getImplementationName())
- self.ui_test.execute_dialog_through_command(".uno:Size")
-
- xDialog = self.xUITest.getTopFocusWindow()
-
- self.assertEqual('12.6', get_state_as_dict(xDialog.getChild('MTR_FLD_WIDTH'))['Value'])
- self.assertEqual('4.57', get_state_as_dict(xDialog.getChild('MTR_FLD_HEIGHT'))['Value'])
- self.assertEqual('0.95', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_X'))['Value'])
- self.assertEqual('3.84', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_Y'))['Value'])
- self.assertEqual('0', get_state_as_dict(xDialog.getChild('NF_ANGLE'))['Value'])
-
- xOK = xDialog.getChild("ok")
- self.ui_test.close_dialog_through_button(xOK)
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:Size") as xDialog:
+ self.assertEqual('12.6', get_state_as_dict(xDialog.getChild('MTR_FLD_WIDTH'))['Value'])
+ self.assertEqual('4.57', get_state_as_dict(xDialog.getChild('MTR_FLD_HEIGHT'))['Value'])
+ self.assertEqual('0.95', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_X'))['Value'])
+ self.assertEqual('3.84', 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("com.sun.star.drawing.SvxShapeCollection", document.CurrentSelection.getImplementationName())
xEditWin.executeAction("DESELECT", tuple())
@@ -146,14 +134,8 @@ class ImpressDrawinglayerTest(UITestCase):
xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
self.assertEqual("com.sun.star.drawing.SvxShapeCollection", document.CurrentSelection.getImplementationName())
- self.ui_test.execute_dialog_through_command(".uno:Size")
-
- xDialog = self.xUITest.getTopFocusWindow()
-
- self.assertEqual('30', get_state_as_dict(xDialog.getChild('NF_ANGLE'))['Value'])
-
- xOK = xDialog.getChild("ok")
- self.ui_test.close_dialog_through_button(xOK)
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:Size") as xDialog:
+ self.assertEqual('30', get_state_as_dict(xDialog.getChild('NF_ANGLE'))['Value'])
self.assertEqual("com.sun.star.drawing.SvxShapeCollection", document.CurrentSelection.getImplementationName())
xEditWin.executeAction("DESELECT", tuple())
diff --git a/uitest/uitest/uihelper/common.py b/uitest/uitest/uihelper/common.py
index 0ce04dbe780a..726905bee28c 100644
--- a/uitest/uitest/uihelper/common.py
+++ b/uitest/uitest/uihelper/common.py
@@ -28,37 +28,32 @@ def get_url_for_data_file(file_name):
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
def change_measurement_unit(UITestCase, unit):
- UITestCase.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog")
- xDialogOpt = UITestCase.xUITest.getTopFocusWindow()
-
- xPages = xDialogOpt.getChild("pages")
- xAppEntry = xPages.getChild('3')
- xAppEntry.executeAction("EXPAND", tuple())
- xGeneralEntry = xAppEntry.getChild('0')
- xGeneralEntry.executeAction("SELECT", tuple())
-
- # Calc
- if 'unitlb' in xDialogOpt.getChildren():
- xUnit = xDialogOpt.getChild("unitlb")
-
- # Writer
- elif 'metric' in xDialogOpt.getChildren():
- xUnit = xDialogOpt.getChild("metric")
-
- # Impress
- elif 'units' in xDialogOpt.getChildren():
- xUnit = xDialogOpt.getChild("units")
-
- props = {"TEXT": unit}
- actionProps = mkPropertyValues(props)
- xUnit.executeAction("SELECT", actionProps)
-
- # tdf#137930: Check apply button doesn't reset the value
- xApplyBtn = xDialogOpt.getChild("apply")
- xApplyBtn.executeAction("CLICK", tuple())
- UITestCase.assertEqual(unit, get_state_as_dict(xUnit)['SelectEntryText'])
-
- xOKBtn = xDialogOpt.getChild("ok")
- UITestCase.ui_test.close_dialog_through_button(xOKBtn)
+ with UITestCase.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt:
+ xPages = xDialogOpt.getChild("pages")
+ xAppEntry = xPages.getChild('3')
+ xAppEntry.executeAction("EXPAND", tuple())
+ xGeneralEntry = xAppEntry.getChild('0')
+ xGeneralEntry.executeAction("SELECT", tuple())
+
+ # Calc
+ if 'unitlb' in xDialogOpt.getChildren():
+ xUnit = xDialogOpt.getChild("unitlb")
+
+ # Writer
+ elif 'metric' in xDialogOpt.getChildren():
+ xUnit = xDialogOpt.getChild("metric")
+
+ # Impress
+ elif 'units' in xDialogOpt.getChildren():
+ xUnit = xDialogOpt.getChild("units")
+
+ props = {"TEXT": unit}
+ actionProps = mkPropertyValues(props)
+ xUnit.executeAction("SELECT", actionProps)
+
+ # tdf#137930: Check apply button doesn't reset the value
+ xApplyBtn = xDialogOpt.getChild("apply")
+ xApplyBtn.executeAction("CLICK", tuple())
+ UITestCase.assertEqual(unit, get_state_as_dict(xUnit)['SelectEntryText'])
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/uitest/uitest/uihelper/testDialog.py b/uitest/uitest/uihelper/testDialog.py
index 43f0a5bc0794..9b63159c6148 100644
--- a/uitest/uitest/uihelper/testDialog.py
+++ b/uitest/uitest/uihelper/testDialog.py
@@ -13,27 +13,21 @@ from uitest.uihelper.common import get_state_as_dict
# the test only checks if LibreOffice crashes by opening the dialog
def testDialog(UITestCase, app, dialog):
doc = UITestCase.ui_test.create_doc_in_start_center(app)
- UITestCase.ui_test.execute_dialog_through_command(dialog['command'])
- xDialog = UITestCase.xUITest.getTopFocusWindow()
-
- xCloseBtn = xDialog.getChild(dialog['closeButton'])
- if 'skipTestOK' in dialog and dialog['skipTestOK'] == True:
- xOKBtn = None
- else:
- try:
- xOKBtn = xDialog.getChild("ok")
- if (get_state_as_dict(xOKBtn)["Enabled"] != "true"):
- xOKBtn = None
- except:
+ with UITestCase.ui_test.execute_dialog_through_command_guarded(dialog['command'], close_button=dialog['closeButton']) as xDialog:
+ if 'skipTestOK' in dialog and dialog['skipTestOK'] == True:
xOKBtn = None
+ else:
+ try:
+ xOKBtn = xDialog.getChild("ok")
+ if (get_state_as_dict(xOKBtn)["Enabled"] != "true"):
+ xOKBtn = None
+ except:
+ xOKBtn = None
- UITestCase.ui_test.close_dialog_through_button(xCloseBtn)
if (xOKBtn != None):
print("check also OK button")
- UITestCase.ui_test.execute_dialog_through_command(dialog['command'])
- xDialog = UITestCase.xUITest.getTopFocusWindow()
- xOKBtn = xDialog.getChild("ok")
- UITestCase.ui_test.close_dialog_through_button(xOKBtn)
+ with UITestCase.ui_test.execute_dialog_through_command_guarded(dialog['command']):
+ pass
UITestCase.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab: