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

uitest: convert all calc demos to the unittest based approach

Change-Id: I6ad7898f92c74f37ed2936337d6570904860d535
üst 4fa28812
calc_tests.create_range_name.create_range_name
calc_tests.create_range_name.create_local_range_name
calc_tests.function_wizard.open_function_wizard
calc_tests.gridwindow.input
...@@ -9,6 +9,8 @@ from uitest_helper import UITest ...@@ -9,6 +9,8 @@ from uitest_helper import UITest
from helper import mkPropertyValues from helper import mkPropertyValues
from UITestCase import UITestCase
try: try:
import pyuno import pyuno
import uno import uno
...@@ -19,54 +21,48 @@ except ImportError: ...@@ -19,54 +21,48 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc") print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise raise
def create_range_name(xContext): class CreateRangeNameTest(UITestCase):
xUITest = xContext.ServiceManager.createInstanceWithContext(
"org.libreoffice.uitest.UITest", xContext)
ui_test = UITest(xUITest, xContext)
ui_test.create_doc_in_start_center("calc") def test_create_range_name(self):
ui_test.execute_modeless_dialog_through_command(".uno:AddName") self.ui_test.create_doc_in_start_center("calc")
xAddNameDlg = xUITest.getTopFocusWindow() self.ui_test.execute_modeless_dialog_through_command(".uno:AddName")
props = {"TEXT": "simpleRangeName"} xAddNameDlg = self.xUITest.getTopFocusWindow()
actionProps = mkPropertyValues(props)
xEdit = xAddNameDlg.getChild("edit") props = {"TEXT": "simpleRangeName"}
xEdit.executeAction("TYPE", actionProps) actionProps = mkPropertyValues(props)
xAddBtn = xAddNameDlg.getChild("add")
xAddBtn.executeAction("CLICK", tuple())
ui_test.close_doc() xEdit = xAddNameDlg.getChild("edit")
xEdit.executeAction("TYPE", actionProps)
xAddBtn = xAddNameDlg.getChild("add")
xAddBtn.executeAction("CLICK", tuple())
def create_local_range_name(xContext): self.ui_test.close_doc()
xUITest = xContext.ServiceManager.createInstanceWithContext(
"org.libreoffice.uitest.UITest", xContext)
ui_test = UITest(xUITest, xContext) def test_create_local_range_name(self):
ui_test.create_doc_in_start_center("calc") self.ui_test.create_doc_in_start_center("calc")
ui_test.execute_modeless_dialog_through_command(".uno:AddName") self.ui_test.execute_modeless_dialog_through_command(".uno:AddName")
xAddNameDlg = xUITest.getTopFocusWindow() xAddNameDlg = self.xUITest.getTopFocusWindow()
props = {"TEXT": "simpleRangeName"} props = {"TEXT": "simpleRangeName"}
actionProps = mkPropertyValues(props) actionProps = mkPropertyValues(props)
xEdit = xAddNameDlg.getChild("edit") xEdit = xAddNameDlg.getChild("edit")
xEdit.executeAction("TYPE", actionProps) xEdit.executeAction("TYPE", actionProps)
xScope = xAddNameDlg.getChild("scope") xScope = xAddNameDlg.getChild("scope")
props = {"POS": "1"} props = {"POS": "1"}
scopeProps = mkPropertyValues(props) scopeProps = mkPropertyValues(props)
xScope.executeAction("SELECT", scopeProps) xScope.executeAction("SELECT", scopeProps)
xAddBtn = xAddNameDlg.getChild("add") xAddBtn = xAddNameDlg.getChild("add")
xAddBtn.executeAction("CLICK", tuple()) xAddBtn.executeAction("CLICK", tuple())
ui_test.close_doc() self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */ # vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -10,6 +10,8 @@ from uitest_helper import UITest ...@@ -10,6 +10,8 @@ from uitest_helper import UITest
from helper import mkPropertyValues from helper import mkPropertyValues
import time import time
from UITestCase import UITestCase
try: try:
import pyuno import pyuno
import uno import uno
...@@ -20,25 +22,21 @@ except ImportError: ...@@ -20,25 +22,21 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc") print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise raise
# tdf#98427 class FunctionWizardTest(UITestCase):
def open_function_wizard(xContext): # tdf#98427
xUITest = xContext.ServiceManager.createInstanceWithContext( def test_open_function_wizard(self):
"org.libreoffice.uitest.UITest", xContext) self.ui_test.create_doc_in_start_center("calc")
ui_test = UITest(xUITest, xContext)
ui_test.create_doc_in_start_center("calc")
ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog") self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog")
xFunctionDlg = xUITest.getTopFocusWindow() xFunctionDlg = self.xUITest.getTopFocusWindow()
xArrayChkBox = xFunctionDlg.getChild("array") xArrayChkBox = xFunctionDlg.getChild("array")
xArrayChkBox.executeAction("CLICK", tuple()) xArrayChkBox.executeAction("CLICK", tuple())
xCancelBtn = xFunctionDlg.getChild("cancel") xCancelBtn = xFunctionDlg.getChild("cancel")
xCancelBtn.executeAction("CLICK", tuple()) xCancelBtn.executeAction("CLICK", tuple())
ui_test.close_doc() self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */ # vim:set shiftwidth=4 softtabstop=4 expandtab: */
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
from uitest_helper import UITest
from helper import mkPropertyValues
from UITestCase import UITestCase
import time
try:
import pyuno
import uno
import unohelper
except ImportError:
print("pyuno not found: try to set PYTHONPATH and URE_BOOTSTRAP variables")
print("PYTHONPATH=/installation/opt/program")
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
class GridWinTest(UITestCase):
def test_select_object(self):
self.ui_test.create_doc_in_start_center("calc")
xCalcDoc = self.xUITest.getTopFocusWindow()
xGridWindow = xCalcDoc.getChild("grid_window")
selectProps = mkPropertyValues({"CELL": "B10"})
xGridWindow.executeAction("SELECT", selectProps)
xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
xGridWindow.executeAction("ACTIVATE", tuple())
xGridWindow.executeAction("DESELECT", tuple())
self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -11,6 +11,8 @@ from helper import mkPropertyValues ...@@ -11,6 +11,8 @@ from helper import mkPropertyValues
from uihelper.calc import enter_text_to_cell from uihelper.calc import enter_text_to_cell
from UITestCase import UITestCase
import time import time
try: try:
...@@ -23,43 +25,37 @@ except ImportError: ...@@ -23,43 +25,37 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc") print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise raise
def input(xContext): class GridWindowTest(UITestCase):
xUITest = xContext.ServiceManager.createInstanceWithContext(
"org.libreoffice.uitest.UITest", xContext)
ui_test = UITest(xUITest, xContext)
ui_test.create_doc_in_start_center("calc") def test_input(self):
xTopWindow = xUITest.getTopFocusWindow()
xGridWindow = xTopWindow.getChild("grid_window") self.ui_test.create_doc_in_start_center("calc")
xTopWindow = self.xUITest.getTopFocusWindow()
enter_text_to_cell(xGridWindow, "C3", "=A1") xGridWindow = xTopWindow.getChild("grid_window")
enter_text_to_cell(xGridWindow, "A1", "2")
time.sleep(2) enter_text_to_cell(xGridWindow, "C3", "=A1")
enter_text_to_cell(xGridWindow, "A1", "2")
ui_test.close_doc() time.sleep(2)
def special_keys(xContext): self.ui_test.close_doc()
xUITest = xContext.ServiceManager.createInstanceWithContext(
"org.libreoffice.uitest.UITest", xContext)
ui_test = UITest(xUITest, xContext) def test_special_keys(self):
ui_test.create_doc_in_start_center("calc") self.ui_test.create_doc_in_start_center("calc")
xTopWindow = xUITest.getTopFocusWindow() xTopWindow = self.xUITest.getTopFocusWindow()
xGridWindow = xTopWindow.getChild("grid_window") xGridWindow = xTopWindow.getChild("grid_window")
selectProps = mkPropertyValues({"CELL": "C3"}) selectProps = mkPropertyValues({"CELL": "C3"})
xGridWindow.executeAction("SELECT", selectProps) xGridWindow.executeAction("SELECT", selectProps)
typeProps = mkPropertyValues({"KEYCODE": "CTRL+DOWN"}) typeProps = mkPropertyValues({"KEYCODE": "CTRL+DOWN"})
xGridWindow.executeAction("TYPE", typeProps) xGridWindow.executeAction("TYPE", typeProps)
time.sleep(2) time.sleep(2)
ui_test.close_doc() self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */ # vim:set shiftwidth=4 softtabstop=4 expandtab: */
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