sc/qa/uitest/autofilter/colorfilter.py          |    6 ++----
 sc/qa/uitest/calc_tests/CellDropDownItems.py    |    3 ++-
 sc/qa/uitest/conditional_format/tdf105466.py    |    3 ++-
 sc/qa/uitest/csv_dialog/tdf92503.py             |    4 ++--
 sc/qa/uitest/manual_tests/calc.py               |    8 ++++----
 sc/qa/uitest/textToColumns/tdf143008.py         |    4 ++--
 sd/qa/uitest/impress_tests/slideShowSettings.py |    6 ++----
 sw/qa/uitest/table/tdf128593.py                 |    4 ++--
 sw/qa/uitest/writer_tests3/hyperlinkdialog.py   |   12 ++++++------
 sw/qa/uitest/writer_tests4/insertBreakDialog.py |    3 ++-
 uitest/uitest/uihelper/common.py                |    4 +---
 11 files changed, 27 insertions(+), 30 deletions(-)

New commits:
commit 5fc6d68e9e125b00dc16600543e516bd15fb3a64
Author:     Xisco Fauli <[email protected]>
AuthorDate: Wed Dec 15 11:50:47 2021 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Wed Dec 15 13:26:36 2021 +0100

    uitest: simplify code
    
    Change-Id: Id3355be0e763217a4915b53d22220c30536415e4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126852
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sc/qa/uitest/autofilter/colorfilter.py 
b/sc/qa/uitest/autofilter/colorfilter.py
index 176c627f3339..58f39227ee3d 100644
--- a/sc/qa/uitest/autofilter/colorfilter.py
+++ b/sc/qa/uitest/autofilter/colorfilter.py
@@ -8,7 +8,7 @@
 #
 
 from uitest.framework import UITestCase
-from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, 
select_pos
+from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, 
select_pos, select_by_text
 from libreoffice.uno.propertyvalue import mkPropertyValues
 from libreoffice.calc.document import is_row_hidden
 
@@ -117,9 +117,7 @@ class ColorFilterTest(UITestCase):
 
                 self.assertEqual("Another", 
get_state_as_dict(xField1)['DisplayText'])
 
-                props = {"TEXT": "Background color"}
-                actionProps = mkPropertyValues(props)
-                xCond1.executeAction("SELECT", actionProps)
+                select_by_text(xCond1, "Background color")
                 self.assertEqual("Background color", 
get_state_as_dict(xCond1)['DisplayText'])
 
                 xColor1 = xDialog.getChild("color1")
diff --git a/sc/qa/uitest/calc_tests/CellDropDownItems.py 
b/sc/qa/uitest/calc_tests/CellDropDownItems.py
index 3f16e0376470..86fceeca2f9a 100644
--- a/sc/qa/uitest/calc_tests/CellDropDownItems.py
+++ b/sc/qa/uitest/calc_tests/CellDropDownItems.py
@@ -9,6 +9,7 @@
 from uitest.framework import UITestCase
 from libreoffice.calc.document import get_cell_by_position
 from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import select_pos
 
 class CellDropDownItems(UITestCase):
 
@@ -27,7 +28,7 @@ class CellDropDownItems(UITestCase):
 
                 #Select List option
                 xallow = xDialog.getChild("allow")
-                xallow.executeAction("SELECT", mkPropertyValues({"POS": "6"}))
+                select_pos(xallow, "6")
 
                 #Add items to the List
                 xminlist = xDialog.getChild("minlist")
diff --git a/sc/qa/uitest/conditional_format/tdf105466.py 
b/sc/qa/uitest/conditional_format/tdf105466.py
index 27e7c1f40359..ead8a19313bb 100644
--- a/sc/qa/uitest/conditional_format/tdf105466.py
+++ b/sc/qa/uitest/conditional_format/tdf105466.py
@@ -9,6 +9,7 @@
 
 from uitest.framework import UITestCase
 from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import select_pos
 
 import unittest
 
@@ -24,6 +25,6 @@ class tdf105466(UITestCase):
                 for i in range(0,4):
                     with self.subTest(i = i):
                         xTypeLstBox = xCondFormatDlg.getChild("type")
-                        xTypeLstBox.executeAction("SELECT", 
mkPropertyValues({"POS": str(i)}))
+                        select_pos(xTypeLstBox, str(i))
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/csv_dialog/tdf92503.py 
b/sc/qa/uitest/csv_dialog/tdf92503.py
index 679c76586130..9774b03c35e3 100644
--- a/sc/qa/uitest/csv_dialog/tdf92503.py
+++ b/sc/qa/uitest/csv_dialog/tdf92503.py
@@ -7,7 +7,7 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
 from uitest.framework import UITestCase
-from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import get_state_as_dict, select_by_text
 from libreoffice.uno.propertyvalue import mkPropertyValues
 from libreoffice.calc.document import get_cell_by_position
 from libreoffice.calc.csv_dialog import load_csv_file
@@ -28,7 +28,7 @@ class Tdf92503(UITestCase):
 
             self.assertEqual('true', get_state_as_dict(xColumnType)['Enabled'])
 
-            xColumnType.executeAction("SELECT", mkPropertyValues({"TEXT": 
"Date (DMY)"}))
+            select_by_text(xColumnType, "Date (DMY)")
 
             self.assertEqual('Date (DMY)', 
get_state_as_dict(xColumnType)['SelectEntryText'])
 
diff --git a/sc/qa/uitest/manual_tests/calc.py 
b/sc/qa/uitest/manual_tests/calc.py
index 4d26437c6f1c..374bd6f93820 100644
--- a/sc/qa/uitest/manual_tests/calc.py
+++ b/sc/qa/uitest/manual_tests/calc.py
@@ -10,7 +10,7 @@
 from uitest.framework import UITestCase
 from libreoffice.uno.propertyvalue import mkPropertyValues
 from libreoffice.calc.document import get_cell_by_position
-from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, 
type_text
+from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, 
type_text, select_pos
 from uitest.uihelper.calc import enter_text_to_cell
 
 class ManualCalcTests(UITestCase):
@@ -94,10 +94,10 @@ class ManualCalcTests(UITestCase):
             with 
self.ui_test.execute_dialog_through_command(".uno:Validation") as 
xValidationDlg:
 
                 xAllowList = xValidationDlg.getChild("allow")
-                xAllowList.executeAction("SELECT", mkPropertyValues({"POS": 
"1"}))
+                select_pos(xAllowList, "1")
 
                 xData = xValidationDlg.getChild("data")
-                xData.executeAction("SELECT", mkPropertyValues({"POS": "5"}))
+                select_pos(xData, "5")
 
                 xVal = xValidationDlg.getChild("max")
                 xVal.executeAction("TYPE", mkPropertyValues({"TEXT":"0"}))
@@ -171,7 +171,7 @@ class ManualCalcTests(UITestCase):
 
             with 
self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog")
 as xRandomNumberDlg:
                 xDistributionLstBox = 
xRandomNumberDlg.getChild("distribution-combo")
-                xDistributionLstBox.executeAction("SELECT", 
mkPropertyValues({"POS": "1"}))
+                select_pos(xDistributionLstBox, "1")
 
                 xMin = xRandomNumberDlg.getChild("parameter1-spin")
                 xMin.executeAction("TYPE", mkPropertyValues({"KEYCODE": 
"CTRL+A"}))
diff --git a/sc/qa/uitest/textToColumns/tdf143008.py 
b/sc/qa/uitest/textToColumns/tdf143008.py
index e6e80396ab99..087a7b5a8fd5 100644
--- a/sc/qa/uitest/textToColumns/tdf143008.py
+++ b/sc/qa/uitest/textToColumns/tdf143008.py
@@ -8,7 +8,7 @@
 #
 from uitest.framework import UITestCase
 from uitest.uihelper.calc import enter_text_to_cell
-from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import get_state_as_dict, select_by_text
 from libreoffice.calc.document import get_cell_by_position
 from libreoffice.uno.propertyvalue import mkPropertyValues
 
@@ -30,7 +30,7 @@ class tdf143008(UITestCase):
 
                 self.assertEqual('true', 
get_state_as_dict(xColumnType)['Enabled'])
 
-                xColumnType.executeAction("SELECT", mkPropertyValues({"TEXT": 
"Date (DMY)"}))
+                select_by_text(xColumnType, "Date (DMY)")
 
                 self.assertEqual('Date (DMY)', 
get_state_as_dict(xColumnType)['SelectEntryText'])
 
diff --git a/sd/qa/uitest/impress_tests/slideShowSettings.py 
b/sd/qa/uitest/impress_tests/slideShowSettings.py
index 83cb49f99eb7..16fbdc8405c9 100644
--- a/sd/qa/uitest/impress_tests/slideShowSettings.py
+++ b/sd/qa/uitest/impress_tests/slideShowSettings.py
@@ -9,9 +9,7 @@
 
 from uitest.framework import UITestCase
 from libreoffice.uno.propertyvalue import mkPropertyValues
-import importlib
-from uitest.debug import sleep
-from uitest.uihelper.common import get_state_as_dict, type_text
+from uitest.uihelper.common import get_state_as_dict, type_text, select_pos
 
 class slideShowSettings(UITestCase):
     def test_slideShowSettings(self):
@@ -26,7 +24,7 @@ class slideShowSettings(UITestCase):
                 xfrom = PresentationDialog.getChild("from")
                 xfrom.executeAction("CLICK",tuple())
                 from_cb = PresentationDialog.getChild("from_cb")
-                from_cb.executeAction("SELECT", mkPropertyValues({"POS": "0"}))
+                select_pos(from_cb, "0")
                 window = PresentationDialog.getChild("window")
                 window.executeAction("CLICK",tuple())
                 manualslides = PresentationDialog.getChild("manualslides")
diff --git a/sw/qa/uitest/table/tdf128593.py b/sw/qa/uitest/table/tdf128593.py
index e20f09e8470f..19158f6e4908 100755
--- a/sw/qa/uitest/table/tdf128593.py
+++ b/sw/qa/uitest/table/tdf128593.py
@@ -9,7 +9,7 @@
 
 from uitest.framework import UITestCase
 from libreoffice.uno.propertyvalue import mkPropertyValues
-from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import get_state_as_dict, select_pos
 
 #https://bugs.documentfoundation.org/show_bug.cgi?id=128593
 #Bug 128593 - Writer table cell's background color is always black
@@ -27,7 +27,7 @@ class tdf128593(UITestCase):
                 writer_edit = MainWindow.getChild("writer_edit")
                 writer_edit.executeAction("SELECT", 
mkPropertyValues({"END_POS": "0", "START_POS": "0"}))
                 tabcontrol = TablePropertiesDialog.getChild("tabcontrol")
-                tabcontrol.executeAction("SELECT", mkPropertyValues({"POS": 
"4"}))
+                select_pos(tabcontrol, "4")
                 Rcustom = TablePropertiesDialog.getChild("R_custom")  #255
                 self.assertEqual(get_state_as_dict(Rcustom)["Text"], "255")
                 Gcustom = TablePropertiesDialog.getChild("G_custom")  #255
diff --git a/sw/qa/uitest/writer_tests3/hyperlinkdialog.py 
b/sw/qa/uitest/writer_tests3/hyperlinkdialog.py
index 37c9c3990267..c20a39b48f2a 100644
--- a/sw/qa/uitest/writer_tests3/hyperlinkdialog.py
+++ b/sw/qa/uitest/writer_tests3/hyperlinkdialog.py
@@ -10,7 +10,7 @@
 from uitest.framework import UITestCase
 import os
 import re
-from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import get_state_as_dict, select_pos
 from libreoffice.uno.propertyvalue import mkPropertyValues
 
 #test Hyperlink dialog
@@ -27,19 +27,19 @@ class HyperlinkDialog(UITestCase):
                 xtab=xDialog.getChild("tabcontrol")
                 self.assertEqual(get_state_as_dict(xtab)["PageCount"], "4")
 
-                xtab.executeAction("SELECT", mkPropertyValues({"POS": "0"}))
+                select_pos(xtab, "0")
                 self.assertEqual(get_state_as_dict(xtab)["CurrPageTitel"], 
"~Internet")
                 self.assertEqual(get_state_as_dict(xtab)["CurrPagePos"], "0")
 
-                xtab.executeAction("SELECT", mkPropertyValues({"POS": "1"}))
+                select_pos(xtab, "1")
                 self.assertEqual(get_state_as_dict(xtab)["CurrPageTitel"], 
"~Mail")
                 self.assertEqual(get_state_as_dict(xtab)["CurrPagePos"], "1")
 
-                xtab.executeAction("SELECT", mkPropertyValues({"POS": "2"}))
+                select_pos(xtab, "2")
                 self.assertEqual(get_state_as_dict(xtab)["CurrPageTitel"], 
"~Document")
                 self.assertEqual(get_state_as_dict(xtab)["CurrPagePos"], "2")
 
-                xtab.executeAction("SELECT", mkPropertyValues({"POS": "3"}))
+                select_pos(xtab, "3")
                 self.assertEqual(get_state_as_dict(xtab)["CurrPageTitel"], 
"~New Document")
                 self.assertEqual(get_state_as_dict(xtab)["CurrPagePos"], "3")
 
@@ -54,7 +54,7 @@ class HyperlinkDialog(UITestCase):
 
                 # insert link
                 xtab=xDialog.getChild("tabcontrol")
-                xtab.executeAction("SELECT", mkPropertyValues({"POS": "0"}))
+                select_pos(xtab, "0")
 
                 xtarget = xDialog.getChild("target")
                 xtarget.executeAction("TYPE", mkPropertyValues({"TEXT": 
"http://www.libreoffice.org/"}))
diff --git a/sw/qa/uitest/writer_tests4/insertBreakDialog.py 
b/sw/qa/uitest/writer_tests4/insertBreakDialog.py
index ffe37aaa69ca..9299d46aa737 100644
--- a/sw/qa/uitest/writer_tests4/insertBreakDialog.py
+++ b/sw/qa/uitest/writer_tests4/insertBreakDialog.py
@@ -9,6 +9,7 @@
 
 from uitest.framework import UITestCase
 from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import select_pos
 
 class WriterInsertBreakDialog(UITestCase):
 
@@ -51,7 +52,7 @@ class WriterInsertBreakDialog(UITestCase):
                         xOption.executeAction("CLICK", tuple())
 
                         xStyleList = xDialog.getChild("stylelb")
-                        xStyleList.executeAction("SELECT", 
mkPropertyValues({"POS": str(i)}))
+                        select_pos(xStyleList, str(i))
 
                     self.getPages(i + 2)
 
diff --git a/uitest/uitest/uihelper/common.py b/uitest/uitest/uihelper/common.py
index c1269038e523..2ae70399dfb1 100644
--- a/uitest/uitest/uihelper/common.py
+++ b/uitest/uitest/uihelper/common.py
@@ -48,9 +48,7 @@ def change_measurement_unit(UITestCase, unit):
         elif 'units' in xDialogOpt.getChildren():
             xUnit = xDialogOpt.getChild("units")
 
-        props = {"TEXT": unit}
-        actionProps = mkPropertyValues(props)
-        xUnit.executeAction("SELECT", actionProps)
+        select_by_text(xUnit, unit)
 
         # tdf#137930: Check apply button doesn't reset the value
         xApplyBtn = xDialogOpt.getChild("apply")

Reply via email to