summaryrefslogtreecommitdiff
path: root/uitest
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-06-29 11:44:54 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-06-29 15:10:03 +0200
commit5b8a13486d3809066e663549879c209992d5479d (patch)
tree8c2701d8827e24eb7f36eb707c20905c41653485 /uitest
parentd0172f785a5973dbe5ea585eabfa7a4671b38775 (diff)
uitest: combine execute_dialog_through_command methods
Change-Id: Iaa03d37a9ac3862b8cb08a81e37a611632433880 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118077 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'uitest')
-rw-r--r--uitest/demo_ui/char_dialog.py2
-rw-r--r--uitest/demo_ui/checkbox.py2
-rw-r--r--uitest/demo_ui/hierarchy.py2
-rw-r--r--uitest/demo_ui/listbox.py4
-rw-r--r--uitest/demo_ui/radiobutton.py2
-rw-r--r--uitest/demo_ui/spinfield.py6
-rw-r--r--uitest/demo_ui/tabdialog.py4
-rw-r--r--uitest/impress_tests/backgrounds.py4
-rw-r--r--uitest/impress_tests/drawinglayer.py6
-rw-r--r--uitest/uitest/test.py22
-rw-r--r--uitest/uitest/uihelper/common.py2
-rw-r--r--uitest/uitest/uihelper/testDialog.py4
12 files changed, 28 insertions, 32 deletions
diff --git a/uitest/demo_ui/char_dialog.py b/uitest/demo_ui/char_dialog.py
index 3b7083b1dba1..96028621a25a 100644
--- a/uitest/demo_ui/char_dialog.py
+++ b/uitest/demo_ui/char_dialog.py
@@ -13,7 +13,7 @@ class CharDialogText(UITestCase):
def test_select_char(self):
self.ui_test.create_doc_in_start_center("calc")
- with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertSymbol", close_button="cancel") as xCharDialog:
+ with self.ui_test.execute_dialog_through_command(".uno:InsertSymbol", close_button="cancel") as xCharDialog:
xCharSet = xCharDialog.getChild("showcharset")
diff --git a/uitest/demo_ui/checkbox.py b/uitest/demo_ui/checkbox.py
index ffee343bf50b..1d0c96902b44 100644
--- a/uitest/demo_ui/checkbox.py
+++ b/uitest/demo_ui/checkbox.py
@@ -15,7 +15,7 @@ class CheckBoxTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xCellsDlg:
+ with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xCellsDlg:
xNegativeNumRedCB = xCellsDlg.getChild("negnumred")
xNegativeNumRedCB.executeAction("CLICK",tuple())
diff --git a/uitest/demo_ui/hierarchy.py b/uitest/demo_ui/hierarchy.py
index 73c15bb607e1..1bfc85d7d99f 100644
--- a/uitest/demo_ui/hierarchy.py
+++ b/uitest/demo_ui/hierarchy.py
@@ -17,7 +17,7 @@ class CheckBoxTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- with self.ui_test.execute_dialog_through_command_guarded(".uno:About", close_button="btnClose") as xAboutDlg:
+ with self.ui_test.execute_dialog_through_command(".uno:About", close_button="btnClose") as xAboutDlg:
json_string = xAboutDlg.getHierarchy()
diff --git a/uitest/demo_ui/listbox.py b/uitest/demo_ui/listbox.py
index 9784178d20a7..3a61d5f9717e 100644
--- a/uitest/demo_ui/listbox.py
+++ b/uitest/demo_ui/listbox.py
@@ -16,7 +16,7 @@ class ListBoxTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog"):
+ with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog"):
pass
self.ui_test.close_doc()
@@ -25,7 +25,7 @@ class ListBoxTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog"):
+ with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog"):
pass
self.ui_test.close_doc()
diff --git a/uitest/demo_ui/radiobutton.py b/uitest/demo_ui/radiobutton.py
index f3331fa18863..f76192b4ffb0 100644
--- a/uitest/demo_ui/radiobutton.py
+++ b/uitest/demo_ui/radiobutton.py
@@ -27,7 +27,7 @@ class RadioButtonTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xCellsDlg:
+ with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xCellsDlg:
xNegativeNumRedCB = xCellsDlg.getChild("negnumred")
xNegativeNumRedCB.executeAction("CLICK",tuple())
diff --git a/uitest/demo_ui/spinfield.py b/uitest/demo_ui/spinfield.py
index a0e983ea81b6..d29ce33141ab 100644
--- a/uitest/demo_ui/spinfield.py
+++ b/uitest/demo_ui/spinfield.py
@@ -16,7 +16,7 @@ class SpinFieldTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xCellsDlg:
+ with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xCellsDlg:
xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
xDecimalPlaces.executeAction("UP", tuple())
@@ -31,7 +31,7 @@ class SpinFieldTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xCellsDlg:
+ with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xCellsDlg:
xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
xDecimalPlaces.executeAction("UP", tuple())
@@ -52,7 +52,7 @@ class SpinFieldTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xCellsDlg:
+ with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xCellsDlg:
xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
type_text(xDecimalPlaces, "4")
diff --git a/uitest/demo_ui/tabdialog.py b/uitest/demo_ui/tabdialog.py
index bfa6129f06de..95eb3b1e81be 100644
--- a/uitest/demo_ui/tabdialog.py
+++ b/uitest/demo_ui/tabdialog.py
@@ -16,7 +16,7 @@ class TabDialogTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog"):
+ with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog"):
pass
self.ui_test.close_doc()
@@ -25,7 +25,7 @@ class TabDialogTest(UITestCase):
self.ui_test.create_doc_in_start_center("calc")
- with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog"):
+ with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog"):
pass
self.ui_test.close_doc()
diff --git a/uitest/impress_tests/backgrounds.py b/uitest/impress_tests/backgrounds.py
index 1ab001fea91f..f37ef2a22a44 100644
--- a/uitest/impress_tests/backgrounds.py
+++ b/uitest/impress_tests/backgrounds.py
@@ -113,7 +113,7 @@ class ImpressBackgrounds(UITestCase):
buttons = ['btnbitmap', 'btncolor', 'btngradient', 'btnhatch', 'btnpattern']
for index, button in enumerate(buttons):
- with self.ui_test.execute_dialog_through_command_guarded(".uno:PageSetup") as xPageSetupDlg:
+ with self.ui_test.execute_dialog_through_command(".uno:PageSetup") as xPageSetupDlg:
tabcontrol = xPageSetupDlg.getChild("tabcontrol")
select_pos(tabcontrol, "1")
@@ -126,7 +126,7 @@ class ImpressBackgrounds(UITestCase):
self.checkDefaultBackground(button)
- with self.ui_test.execute_dialog_through_command_guarded(".uno:PageSetup") as xPageSetupDlg:
+ with self.ui_test.execute_dialog_through_command(".uno:PageSetup") as xPageSetupDlg:
tabcontrol = xPageSetupDlg.getChild("tabcontrol")
select_pos(tabcontrol, "1")
diff --git a/uitest/impress_tests/drawinglayer.py b/uitest/impress_tests/drawinglayer.py
index ca09945aeaea..bc1e785f65e3 100644
--- a/uitest/impress_tests/drawinglayer.py
+++ b/uitest/impress_tests/drawinglayer.py
@@ -44,7 +44,7 @@ class ImpressDrawinglayerTest(UITestCase):
xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
self.assertEqual("com.sun.star.drawing.SvxShapeCollection", document.CurrentSelection.getImplementationName())
- with self.ui_test.execute_dialog_through_command_guarded(".uno:Size") as xDialog:
+ with self.ui_test.execute_dialog_through_command(".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'])
@@ -89,7 +89,7 @@ class ImpressDrawinglayerTest(UITestCase):
xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
self.assertEqual("com.sun.star.drawing.SvxShapeCollection", document.CurrentSelection.getImplementationName())
- with self.ui_test.execute_dialog_through_command_guarded(".uno:Size") as xDialog:
+ with self.ui_test.execute_dialog_through_command(".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'])
@@ -134,7 +134,7 @@ class ImpressDrawinglayerTest(UITestCase):
xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
self.assertEqual("com.sun.star.drawing.SvxShapeCollection", document.CurrentSelection.getImplementationName())
- with self.ui_test.execute_dialog_through_command_guarded(".uno:Size") as xDialog:
+ with self.ui_test.execute_dialog_through_command(".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())
diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index dbb2a7c046d5..1e3ddc85747f 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -108,27 +108,23 @@ class UITest(object):
finally:
self.close_doc()
- def execute_dialog_through_command(self, command, printNames=False):
+ # Calls UITest.close_dialog_through_button at exit
+ @contextmanager
+ def execute_dialog_through_command(self, command, printNames=False, close_button = "ok"):
with EventListener(self._xContext, "DialogExecute", printNames=printNames) as event:
if not self._xUITest.executeDialog(command):
raise Exception("Dialog not executed for: " + command)
while True:
if event.executed:
- time.sleep(DEFAULT_SLEEP)
+ xDialog = self._xUITest.getTopFocusWindow()
+ try:
+ yield xDialog
+ finally:
+ if close_button:
+ self.close_dialog_through_button(xDialog.getChild(close_button))
return
time.sleep(DEFAULT_SLEEP)
- # Calls UITest.close_dialog_through_button at exit
- @contextmanager
- def execute_dialog_through_command_guarded(self, command, printNames=False, close_button = "ok"):
- self.execute_dialog_through_command(command, printNames)
- xDialog = self._xUITest.getTopFocusWindow()
- try:
- yield xDialog
- finally:
- if close_button:
- self.close_dialog_through_button(xDialog.getChild(close_button))
-
def execute_modeless_dialog_through_command(self, command, printNames=False):
with EventListener(self._xContext, "ModelessDialogVisible", printNames = printNames) as event:
if not self._xUITest.executeCommand(command):
diff --git a/uitest/uitest/uihelper/common.py b/uitest/uitest/uihelper/common.py
index 726905bee28c..f6146c5e7729 100644
--- a/uitest/uitest/uihelper/common.py
+++ b/uitest/uitest/uihelper/common.py
@@ -28,7 +28,7 @@ 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):
- with UITestCase.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt:
+ with UITestCase.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt:
xPages = xDialogOpt.getChild("pages")
xAppEntry = xPages.getChild('3')
xAppEntry.executeAction("EXPAND", tuple())
diff --git a/uitest/uitest/uihelper/testDialog.py b/uitest/uitest/uihelper/testDialog.py
index 9b63159c6148..d1bb47856acf 100644
--- a/uitest/uitest/uihelper/testDialog.py
+++ b/uitest/uitest/uihelper/testDialog.py
@@ -13,7 +13,7 @@ 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)
- with UITestCase.ui_test.execute_dialog_through_command_guarded(dialog['command'], close_button=dialog['closeButton']) as xDialog:
+ with UITestCase.ui_test.execute_dialog_through_command(dialog['command'], close_button=dialog['closeButton']) as xDialog:
if 'skipTestOK' in dialog and dialog['skipTestOK'] == True:
xOKBtn = None
else:
@@ -26,7 +26,7 @@ def testDialog(UITestCase, app, dialog):
if (xOKBtn != None):
print("check also OK button")
- with UITestCase.ui_test.execute_dialog_through_command_guarded(dialog['command']):
+ with UITestCase.ui_test.execute_dialog_through_command(dialog['command']):
pass
UITestCase.ui_test.close_doc()