Kaydet (Commit) 57e785e1 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

uitest: add a helper method for typing text

Change-Id: If450e3f0ff1e2a8f33db05e9512a13e5771115a8
Reviewed-on: https://gerrit.libreoffice.org/32406Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 2dc82157
......@@ -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"}))
......
......@@ -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"}
......
......@@ -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"}))
......
......@@ -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())
......
......@@ -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")
......
......@@ -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)
......
......@@ -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"])
......
......@@ -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:
......@@ -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:
......@@ -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"}))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment