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>
This commit is contained in:
@@ -8,29 +8,23 @@
|
|||||||
from libreoffice.uno.propertyvalue import mkPropertyValues
|
from libreoffice.uno.propertyvalue import mkPropertyValues
|
||||||
|
|
||||||
from uitest.framework import UITestCase
|
from uitest.framework import UITestCase
|
||||||
|
from uitest.uihelper.calc import enter_text_to_cell
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class CalcChartUIDemo(UITestCase):
|
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):
|
def fill_spreadsheet(self):
|
||||||
xCalcDoc = self.xUITest.getTopFocusWindow()
|
xCalcDoc = self.xUITest.getTopFocusWindow()
|
||||||
xGridWindow = xCalcDoc.getChild("grid_window")
|
xGridWindow = xCalcDoc.getChild("grid_window")
|
||||||
|
|
||||||
self.add_content_to_cell(xGridWindow, "A1", "col1")
|
enter_text_to_cell(xGridWindow, "A1", "col1")
|
||||||
self.add_content_to_cell(xGridWindow, "B1", "col2")
|
enter_text_to_cell(xGridWindow, "B1", "col2")
|
||||||
self.add_content_to_cell(xGridWindow, "C1", "col3")
|
enter_text_to_cell(xGridWindow, "C1", "col3")
|
||||||
self.add_content_to_cell(xGridWindow, "A2", "1")
|
enter_text_to_cell(xGridWindow, "A2", "1")
|
||||||
self.add_content_to_cell(xGridWindow, "B2", "3")
|
enter_text_to_cell(xGridWindow, "B2", "3")
|
||||||
self.add_content_to_cell(xGridWindow, "C2", "5")
|
enter_text_to_cell(xGridWindow, "C2", "5")
|
||||||
|
|
||||||
xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C2"}))
|
xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C2"}))
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
from libreoffice.uno.propertyvalue import mkPropertyValues
|
from libreoffice.uno.propertyvalue import mkPropertyValues
|
||||||
|
|
||||||
from uitest.framework import UITestCase
|
from uitest.framework import UITestCase
|
||||||
|
from uitest.uihelper.common import type_text
|
||||||
|
|
||||||
class CreateRangeNameTest(UITestCase):
|
class CreateRangeNameTest(UITestCase):
|
||||||
|
|
||||||
@@ -19,11 +20,9 @@ class CreateRangeNameTest(UITestCase):
|
|||||||
|
|
||||||
xAddNameDlg = self.xUITest.getTopFocusWindow()
|
xAddNameDlg = self.xUITest.getTopFocusWindow()
|
||||||
|
|
||||||
props = {"TEXT": "simpleRangeName"}
|
|
||||||
actionProps = mkPropertyValues(props)
|
|
||||||
|
|
||||||
xEdit = xAddNameDlg.getChild("edit")
|
xEdit = xAddNameDlg.getChild("edit")
|
||||||
xEdit.executeAction("TYPE", actionProps)
|
type_text(xEdit, "simpleRangeName")
|
||||||
|
|
||||||
xAddBtn = xAddNameDlg.getChild("add")
|
xAddBtn = xAddNameDlg.getChild("add")
|
||||||
xAddBtn.executeAction("CLICK", tuple())
|
xAddBtn.executeAction("CLICK", tuple())
|
||||||
|
|
||||||
@@ -37,11 +36,8 @@ class CreateRangeNameTest(UITestCase):
|
|||||||
|
|
||||||
xAddNameDlg = self.xUITest.getTopFocusWindow()
|
xAddNameDlg = self.xUITest.getTopFocusWindow()
|
||||||
|
|
||||||
props = {"TEXT": "simpleRangeName"}
|
|
||||||
actionProps = mkPropertyValues(props)
|
|
||||||
|
|
||||||
xEdit = xAddNameDlg.getChild("edit")
|
xEdit = xAddNameDlg.getChild("edit")
|
||||||
xEdit.executeAction("TYPE", actionProps)
|
type_text(xEdit, "simpleRangeName")
|
||||||
|
|
||||||
xScope = xAddNameDlg.getChild("scope")
|
xScope = xAddNameDlg.getChild("scope")
|
||||||
props = {"POS": "1"}
|
props = {"POS": "1"}
|
||||||
|
@@ -8,28 +8,22 @@
|
|||||||
from libreoffice.uno.propertyvalue import mkPropertyValues
|
from libreoffice.uno.propertyvalue import mkPropertyValues
|
||||||
|
|
||||||
from uitest.framework import UITestCase
|
from uitest.framework import UITestCase
|
||||||
|
from uitest.uihelper.calc import enter_text_to_cell
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class CalcChartEditUIDemo(UITestCase):
|
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):
|
def fill_spreadsheet(self):
|
||||||
xCalcDoc = self.xUITest.getTopFocusWindow()
|
xCalcDoc = self.xUITest.getTopFocusWindow()
|
||||||
xGridWindow = xCalcDoc.getChild("grid_window")
|
xGridWindow = xCalcDoc.getChild("grid_window")
|
||||||
|
|
||||||
self.add_content_to_cell(xGridWindow, "A1", "col1")
|
enter_text_to_cell(xGridWindow, "A1", "col1")
|
||||||
self.add_content_to_cell(xGridWindow, "B1", "col2")
|
enter_text_to_cell(xGridWindow, "B1", "col2")
|
||||||
self.add_content_to_cell(xGridWindow, "C1", "col3")
|
enter_text_to_cell(xGridWindow, "C1", "col3")
|
||||||
self.add_content_to_cell(xGridWindow, "A2", "1")
|
enter_text_to_cell(xGridWindow, "A2", "1")
|
||||||
self.add_content_to_cell(xGridWindow, "B2", "3")
|
enter_text_to_cell(xGridWindow, "B2", "3")
|
||||||
self.add_content_to_cell(xGridWindow, "C2", "5")
|
enter_text_to_cell(xGridWindow, "C2", "5")
|
||||||
|
|
||||||
xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C2"}))
|
xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C2"}))
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
from libreoffice.uno.propertyvalue import mkPropertyValues
|
from libreoffice.uno.propertyvalue import mkPropertyValues
|
||||||
|
|
||||||
from uitest.framework import UITestCase
|
from uitest.framework import UITestCase
|
||||||
|
from uitest.uihelper.common import type_text
|
||||||
|
|
||||||
class EditTest(UITestCase):
|
class EditTest(UITestCase):
|
||||||
|
|
||||||
@@ -20,9 +21,7 @@ class EditTest(UITestCase):
|
|||||||
|
|
||||||
xEdit = xAddNameDlg.getChild("edit")
|
xEdit = xAddNameDlg.getChild("edit")
|
||||||
|
|
||||||
props = {"TEXT": "simpleRangeName"}
|
type_text(xEdit, "simpleRangeName")
|
||||||
actionProps = mkPropertyValues(props)
|
|
||||||
xEdit.executeAction("TYPE", actionProps)
|
|
||||||
|
|
||||||
xAddBtn = xAddNameDlg.getChild("cancel")
|
xAddBtn = xAddNameDlg.getChild("cancel")
|
||||||
xAddBtn.executeAction("CLICK", tuple())
|
xAddBtn.executeAction("CLICK", tuple())
|
||||||
|
@@ -6,9 +6,9 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from libreoffice.uno.propertyvalue import mkPropertyValues
|
from libreoffice.uno.propertyvalue import mkPropertyValues
|
||||||
from uitest.uihelper.common import get_state_as_dict
|
|
||||||
|
|
||||||
from uitest.framework import UITestCase
|
from uitest.framework import UITestCase
|
||||||
|
from uitest.uihelper.common import get_state_as_dict, type_text
|
||||||
|
|
||||||
class SpinFieldTest(UITestCase):
|
class SpinFieldTest(UITestCase):
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class SpinFieldTest(UITestCase):
|
|||||||
xCellsDlg = self.xUITest.getTopFocusWindow()
|
xCellsDlg = self.xUITest.getTopFocusWindow()
|
||||||
|
|
||||||
xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
|
xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
|
||||||
xDecimalPlaces.executeAction("TYPE", mkPropertyValues({"TEXT": "4"}))
|
type_text(xDecimalPlaces, "4")
|
||||||
|
|
||||||
decimal_places_state = get_state_as_dict(xDecimalPlaces)
|
decimal_places_state = get_state_as_dict(xDecimalPlaces)
|
||||||
assert(decimal_places_state["Text"] == "41")
|
assert(decimal_places_state["Text"] == "41")
|
||||||
|
@@ -10,7 +10,7 @@ from uitest.framework import UITestCase
|
|||||||
from libreoffice.uno.propertyvalue import mkPropertyValues
|
from libreoffice.uno.propertyvalue import mkPropertyValues
|
||||||
from libreoffice.calc.document import get_cell_by_position
|
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.uihelper.calc import enter_text_to_cell
|
||||||
from uitest.path import get_srcdir_url
|
from uitest.path import get_srcdir_url
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ class ManualCalcTests(UITestCase):
|
|||||||
xDefineNameDlg = self.xUITest.getTopFocusWindow()
|
xDefineNameDlg = self.xUITest.getTopFocusWindow()
|
||||||
|
|
||||||
xEntryBox = xDefineNameDlg.getChild("entry")
|
xEntryBox = xDefineNameDlg.getChild("entry")
|
||||||
xEntryBox.executeAction("TYPE", mkPropertyValues({"TEXT": "my_database"}))
|
type_text(xEntryBox, "my_database")
|
||||||
|
|
||||||
xOkBtn = xDefineNameDlg.getChild("ok")
|
xOkBtn = xDefineNameDlg.getChild("ok")
|
||||||
self.ui_test.close_dialog_through_button(xOkBtn)
|
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 libreoffice.uno.propertyvalue import mkPropertyValues
|
||||||
|
|
||||||
from uitest.framework import UITestCase
|
from uitest.framework import UITestCase
|
||||||
|
from uitest.uihelper.common import type_text
|
||||||
from uitest.debug import sleep
|
from uitest.debug import sleep
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
@@ -47,7 +47,7 @@ class SimpleMathTest(UITestCase):
|
|||||||
|
|
||||||
xMathEdit = xMathDoc.getChild("math_edit")
|
xMathEdit = xMathDoc.getChild("math_edit")
|
||||||
|
|
||||||
xMathEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "E=mc^2"}))
|
type_text(xMathEdit, "E=mc^2")
|
||||||
|
|
||||||
self.ui_test.close_doc()
|
self.ui_test.close_doc()
|
||||||
|
|
||||||
@@ -80,9 +80,9 @@ class SimpleMathTest(UITestCase):
|
|||||||
xElement.executeAction("SELECT", tuple())
|
xElement.executeAction("SELECT", tuple())
|
||||||
|
|
||||||
xMathEdit = xMathDoc.getChild("math_edit")
|
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({"KEYCODE":"F4"}))
|
||||||
xMathEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"2"}))
|
type_text(xMathEdit, "2")
|
||||||
|
|
||||||
edit_state = get_state_as_dict(xMathEdit)
|
edit_state = get_state_as_dict(xMathEdit)
|
||||||
self.assertEqual("1 <> 2 ", edit_state["Text"])
|
self.assertEqual("1 <> 2 ", edit_state["Text"])
|
||||||
|
@@ -6,10 +6,11 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from libreoffice.uno.propertyvalue import mkPropertyValues
|
from libreoffice.uno.propertyvalue import mkPropertyValues
|
||||||
|
from uitest.uihelper.common import type_text
|
||||||
|
|
||||||
def enter_text_to_cell(gridwin, cell, text):
|
def enter_text_to_cell(gridwin, cell, text):
|
||||||
gridwin.executeAction("SELECT", mkPropertyValues({"CELL": cell}))
|
gridwin.executeAction("SELECT", mkPropertyValues({"CELL": cell}))
|
||||||
gridwin.executeAction("TYPE", mkPropertyValues({"TEXT": text}))
|
type_text(gridwin, text)
|
||||||
gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
|
gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
|
||||||
|
|
||||||
# vim: set shiftwidth=4 softtabstop=4 expandtab:
|
# vim: set shiftwidth=4 softtabstop=4 expandtab:
|
||||||
|
@@ -5,9 +5,12 @@
|
|||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# 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):
|
def get_state_as_dict(ui_object):
|
||||||
return convert_property_values_to_dict(ui_object.getState())
|
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:
|
# vim: set shiftwidth=4 softtabstop=4 expandtab:
|
||||||
|
@@ -5,11 +5,10 @@
|
|||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# 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 libreoffice.uno.propertyvalue import mkPropertyValues
|
||||||
|
|
||||||
from uitest.framework import UITestCase
|
from uitest.framework import UITestCase
|
||||||
|
from uitest.uihelper.common import get_state_as_dict, type_text
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ class SimpleWriterTest(UITestCase):
|
|||||||
xWriterDoc = self.xUITest.getTopFocusWindow()
|
xWriterDoc = self.xUITest.getTopFocusWindow()
|
||||||
xWriterEdit = xWriterDoc.getChild("writer_edit")
|
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()
|
self.ui_test.close_doc()
|
||||||
|
|
||||||
@@ -62,7 +61,7 @@ class SimpleWriterTest(UITestCase):
|
|||||||
xWriterDoc = self.xUITest.getTopFocusWindow()
|
xWriterDoc = self.xUITest.getTopFocusWindow()
|
||||||
xWriterEdit = xWriterDoc.getChild("writer_edit")
|
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"}))
|
xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "0", "END_POS": "4"}))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user