[Libreoffice-commits] core.git: uitest/calc_tests uitest/demo_ui uitest/manual_tests uitest/math_tests uitest/uitest uitest/writer_tests

Markus Mohrhard markus.mohrhard at googlemail.com
Sat Dec 24 17:11:17 UTC 2016


 uitest/calc_tests/create_chart.py      |   20 +++++++-------------
 uitest/calc_tests/create_range_name.py |   12 ++++--------
 uitest/calc_tests/edit_chart.py        |   20 +++++++-------------
 uitest/demo_ui/edit.py                 |    5 ++---
 uitest/demo_ui/spinfield.py            |    4 ++--
 uitest/manual_tests/calc.py            |    4 ++--
 uitest/math_tests/start.py             |    8 ++++----
 uitest/uitest/uihelper/calc.py         |    3 ++-
 uitest/uitest/uihelper/common.py       |    5 ++++-
 uitest/writer_tests/start.py           |    7 +++----
 10 files changed, 37 insertions(+), 51 deletions(-)

New commits:
commit 57e785e1cf52e422ac60cb259a2f53b696d3c4cc
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Dec 22 03:38:34 2016 +0100

    uitest: add a helper method for typing text
    
    Change-Id: If450e3f0ff1e2a8f33db05e9512a13e5771115a8
    Reviewed-on: https://gerrit.libreoffice.org/32406
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/uitest/calc_tests/create_chart.py b/uitest/calc_tests/create_chart.py
index c43be5f..d98eeff 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 ee398ab..5f3b8c3 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 c5d85c0..a8aa36e 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 a40677c..5eff4e0 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 49952dc..c093cf5 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 2f7f5f4..2f45241 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 c8fbffd..2842c1f 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 29e8ce4..e34304c 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 e0314a2..b05bec7 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 26b75ce..c8cbcbb 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"}))
 


More information about the Libreoffice-commits mailing list