summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-12-22 03:38:34 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-12-24 17:10:56 +0000
commit57e785e1cf52e422ac60cb259a2f53b696d3c4cc (patch)
treeff5adff271b61d0eb8e2c20839cf1a5a146ba47c
parent2dc821572e23dd0ac553e49244179e1e19d0df37 (diff)
uitest: add a helper method for typing text
Change-Id: If450e3f0ff1e2a8f33db05e9512a13e5771115a8 Reviewed-on: https://gerrit.libreoffice.org/32406 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--uitest/calc_tests/create_chart.py20
-rw-r--r--uitest/calc_tests/create_range_name.py12
-rw-r--r--uitest/calc_tests/edit_chart.py20
-rw-r--r--uitest/demo_ui/edit.py5
-rw-r--r--uitest/demo_ui/spinfield.py4
-rw-r--r--uitest/manual_tests/calc.py4
-rw-r--r--uitest/math_tests/start.py8
-rw-r--r--uitest/uitest/uihelper/calc.py3
-rw-r--r--uitest/uitest/uihelper/common.py5
-rw-r--r--uitest/writer_tests/start.py7
10 files changed, 37 insertions, 51 deletions
diff --git a/uitest/calc_tests/create_chart.py b/uitest/calc_tests/create_chart.py
index c43be5f2150c..d98eeffc4e67 100644
--- a/uitest/calc_tests/create_chart.py
+++ b/uitest/calc_tests/create_chart.py
@@ -8,29 +8,23 @@
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.framework import UITestCase
+from uitest.uihelper.calc import enter_text_to_cell
import time
import unittest
class CalcChartUIDemo(UITestCase):
- def add_content_to_cell(self, gridwin, cell, content):
- selectProps = mkPropertyValues({"CELL": cell})
- gridwin.executeAction("SELECT", selectProps)
-
- contentProps = mkPropertyValues({"TEXT": content})
- gridwin.executeAction("TYPE", contentProps)
-
def fill_spreadsheet(self):
xCalcDoc = self.xUITest.getTopFocusWindow()
xGridWindow = xCalcDoc.getChild("grid_window")
- self.add_content_to_cell(xGridWindow, "A1", "col1")
- self.add_content_to_cell(xGridWindow, "B1", "col2")
- self.add_content_to_cell(xGridWindow, "C1", "col3")
- self.add_content_to_cell(xGridWindow, "A2", "1")
- self.add_content_to_cell(xGridWindow, "B2", "3")
- self.add_content_to_cell(xGridWindow, "C2", "5")
+ enter_text_to_cell(xGridWindow, "A1", "col1")
+ enter_text_to_cell(xGridWindow, "B1", "col2")
+ enter_text_to_cell(xGridWindow, "C1", "col3")
+ enter_text_to_cell(xGridWindow, "A2", "1")
+ enter_text_to_cell(xGridWindow, "B2", "3")
+ enter_text_to_cell(xGridWindow, "C2", "5")
xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C2"}))
diff --git a/uitest/calc_tests/create_range_name.py b/uitest/calc_tests/create_range_name.py
index ee398ab6eb95..5f3b8c381d61 100644
--- a/uitest/calc_tests/create_range_name.py
+++ b/uitest/calc_tests/create_range_name.py
@@ -8,6 +8,7 @@
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.framework import UITestCase
+from uitest.uihelper.common import type_text
class CreateRangeNameTest(UITestCase):
@@ -19,11 +20,9 @@ class CreateRangeNameTest(UITestCase):
xAddNameDlg = self.xUITest.getTopFocusWindow()
- props = {"TEXT": "simpleRangeName"}
- actionProps = mkPropertyValues(props)
-
xEdit = xAddNameDlg.getChild("edit")
- xEdit.executeAction("TYPE", actionProps)
+ type_text(xEdit, "simpleRangeName")
+
xAddBtn = xAddNameDlg.getChild("add")
xAddBtn.executeAction("CLICK", tuple())
@@ -37,11 +36,8 @@ class CreateRangeNameTest(UITestCase):
xAddNameDlg = self.xUITest.getTopFocusWindow()
- props = {"TEXT": "simpleRangeName"}
- actionProps = mkPropertyValues(props)
-
xEdit = xAddNameDlg.getChild("edit")
- xEdit.executeAction("TYPE", actionProps)
+ type_text(xEdit, "simpleRangeName")
xScope = xAddNameDlg.getChild("scope")
props = {"POS": "1"}
diff --git a/uitest/calc_tests/edit_chart.py b/uitest/calc_tests/edit_chart.py
index c5d85c0678ed..a8aa36e70c03 100644
--- a/uitest/calc_tests/edit_chart.py
+++ b/uitest/calc_tests/edit_chart.py
@@ -8,28 +8,22 @@
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.framework import UITestCase
+from uitest.uihelper.calc import enter_text_to_cell
import unittest
class CalcChartEditUIDemo(UITestCase):
- def add_content_to_cell(self, gridwin, cell, content):
- selectProps = mkPropertyValues({"CELL": cell})
- gridwin.executeAction("SELECT", selectProps)
-
- contentProps = mkPropertyValues({"TEXT": content})
- gridwin.executeAction("TYPE", contentProps)
-
def fill_spreadsheet(self):
xCalcDoc = self.xUITest.getTopFocusWindow()
xGridWindow = xCalcDoc.getChild("grid_window")
- self.add_content_to_cell(xGridWindow, "A1", "col1")
- self.add_content_to_cell(xGridWindow, "B1", "col2")
- self.add_content_to_cell(xGridWindow, "C1", "col3")
- self.add_content_to_cell(xGridWindow, "A2", "1")
- self.add_content_to_cell(xGridWindow, "B2", "3")
- self.add_content_to_cell(xGridWindow, "C2", "5")
+ enter_text_to_cell(xGridWindow, "A1", "col1")
+ enter_text_to_cell(xGridWindow, "B1", "col2")
+ enter_text_to_cell(xGridWindow, "C1", "col3")
+ enter_text_to_cell(xGridWindow, "A2", "1")
+ enter_text_to_cell(xGridWindow, "B2", "3")
+ enter_text_to_cell(xGridWindow, "C2", "5")
xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C2"}))
diff --git a/uitest/demo_ui/edit.py b/uitest/demo_ui/edit.py
index a40677c5d8ae..5eff4e0fad90 100644
--- a/uitest/demo_ui/edit.py
+++ b/uitest/demo_ui/edit.py
@@ -8,6 +8,7 @@
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.framework import UITestCase
+from uitest.uihelper.common import type_text
class EditTest(UITestCase):
@@ -20,9 +21,7 @@ class EditTest(UITestCase):
xEdit = xAddNameDlg.getChild("edit")
- props = {"TEXT": "simpleRangeName"}
- actionProps = mkPropertyValues(props)
- xEdit.executeAction("TYPE", actionProps)
+ type_text(xEdit, "simpleRangeName")
xAddBtn = xAddNameDlg.getChild("cancel")
xAddBtn.executeAction("CLICK", tuple())
diff --git a/uitest/demo_ui/spinfield.py b/uitest/demo_ui/spinfield.py
index 49952dcb4cfa..c093cf5d4d7c 100644
--- a/uitest/demo_ui/spinfield.py
+++ b/uitest/demo_ui/spinfield.py
@@ -6,9 +6,9 @@
#
from libreoffice.uno.propertyvalue import mkPropertyValues
-from uitest.uihelper.common import get_state_as_dict
from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict, type_text
class SpinFieldTest(UITestCase):
@@ -68,7 +68,7 @@ class SpinFieldTest(UITestCase):
xCellsDlg = self.xUITest.getTopFocusWindow()
xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
- xDecimalPlaces.executeAction("TYPE", mkPropertyValues({"TEXT": "4"}))
+ type_text(xDecimalPlaces, "4")
decimal_places_state = get_state_as_dict(xDecimalPlaces)
assert(decimal_places_state["Text"] == "41")
diff --git a/uitest/manual_tests/calc.py b/uitest/manual_tests/calc.py
index 2f7f5f41cab2..2f4524134f77 100644
--- a/uitest/manual_tests/calc.py
+++ b/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
+from uitest.uihelper.common import get_state_as_dict, type_text
from uitest.uihelper.calc import enter_text_to_cell
from uitest.path import get_srcdir_url
@@ -36,7 +36,7 @@ class ManualCalcTests(UITestCase):
xDefineNameDlg = self.xUITest.getTopFocusWindow()
xEntryBox = xDefineNameDlg.getChild("entry")
- xEntryBox.executeAction("TYPE", mkPropertyValues({"TEXT": "my_database"}))
+ type_text(xEntryBox, "my_database")
xOkBtn = xDefineNameDlg.getChild("ok")
self.ui_test.close_dialog_through_button(xOkBtn)
diff --git a/uitest/math_tests/start.py b/uitest/math_tests/start.py
index c8fbffd8dbb4..2842c1f1ef71 100644
--- a/uitest/math_tests/start.py
+++ b/uitest/math_tests/start.py
@@ -10,7 +10,7 @@ from uitest.uihelper.common import get_state_as_dict
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.framework import UITestCase
-
+from uitest.uihelper.common import type_text
from uitest.debug import sleep
import unittest
@@ -47,7 +47,7 @@ class SimpleMathTest(UITestCase):
xMathEdit = xMathDoc.getChild("math_edit")
- xMathEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "E=mc^2"}))
+ type_text(xMathEdit, "E=mc^2")
self.ui_test.close_doc()
@@ -80,9 +80,9 @@ class SimpleMathTest(UITestCase):
xElement.executeAction("SELECT", tuple())
xMathEdit = xMathDoc.getChild("math_edit")
- xMathEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
+ type_text(xMathEdit, "1")
xMathEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"F4"}))
- xMathEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"2"}))
+ type_text(xMathEdit, "2")
edit_state = get_state_as_dict(xMathEdit)
self.assertEqual("1 <> 2 ", edit_state["Text"])
diff --git a/uitest/uitest/uihelper/calc.py b/uitest/uitest/uihelper/calc.py
index 29e8ce44df38..e34304c69082 100644
--- a/uitest/uitest/uihelper/calc.py
+++ b/uitest/uitest/uihelper/calc.py
@@ -6,10 +6,11 @@
#
from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import type_text
def enter_text_to_cell(gridwin, cell, text):
gridwin.executeAction("SELECT", mkPropertyValues({"CELL": cell}))
- gridwin.executeAction("TYPE", mkPropertyValues({"TEXT": text}))
+ type_text(gridwin, text)
gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/uitest/uitest/uihelper/common.py b/uitest/uitest/uihelper/common.py
index e0314a22c93a..b05bec7167f6 100644
--- a/uitest/uitest/uihelper/common.py
+++ b/uitest/uitest/uihelper/common.py
@@ -5,9 +5,12 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-from libreoffice.uno.propertyvalue import convert_property_values_to_dict
+from libreoffice.uno.propertyvalue import convert_property_values_to_dict, mkPropertyValues
def get_state_as_dict(ui_object):
return convert_property_values_to_dict(ui_object.getState())
+def type_text(ui_object, text):
+ ui_object.executeAction("TYPE", mkPropertyValues({"TEXT": text}))
+
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/uitest/writer_tests/start.py b/uitest/writer_tests/start.py
index 26b75ce0751e..c8cbcbba4884 100644
--- a/uitest/writer_tests/start.py
+++ b/uitest/writer_tests/start.py
@@ -5,11 +5,10 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-from uitest.uihelper.common import get_state_as_dict
-
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict, type_text
import time
@@ -34,7 +33,7 @@ class SimpleWriterTest(UITestCase):
xWriterDoc = self.xUITest.getTopFocusWindow()
xWriterEdit = xWriterDoc.getChild("writer_edit")
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "This is my first writer text written through the UI testing"}))
+ type_text(xWriterEdit, "This is my first writer text written through the UI testing")
self.ui_test.close_doc()
@@ -62,7 +61,7 @@ class SimpleWriterTest(UITestCase):
xWriterDoc = self.xUITest.getTopFocusWindow()
xWriterEdit = xWriterDoc.getChild("writer_edit")
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "This is my first writer text written through the UI testing"}))
+ type_text(xWriterEdit, "This is my first writer text written through the UI testing")
xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "0", "END_POS": "4"}))