uitests: prefs: Move helper functions to util

This commit is contained in:
Cole Robinson 2018-01-21 11:58:11 -05:00
parent 2bfd2f28c1
commit 2fdf0c7ebe
2 changed files with 25 additions and 18 deletions

View File

@ -1,20 +1,6 @@
import dogtail
import pyatspi
from tests.uitests import utils as uiutils
# From dogtail 9.9.0 which isn't widely distributed yet
def _holdKey(keyName):
code = dogtail.rawinput.keyNameToKeyCode(keyName)
pyatspi.Registry().generateKeyboardEvent(code, None, pyatspi.KEY_PRESS)
def _releaseKey(keyName):
code = dogtail.rawinput.keyNameToKeyCode(keyName)
pyatspi.Registry().generateKeyboardEvent(code, None, pyatspi.KEY_RELEASE)
class VMMPrefs(uiutils.UITestCase):
"""
UI tests for the preferences dialog
@ -44,13 +30,13 @@ class VMMPrefs(uiutils.UITestCase):
win.find("Console", "page tab").click()
win.find("Change...", "push button").click()
keyframe = self.app.root.find_fuzzy("Configure grab", "dialog")
_holdKey("Alt_L")
_holdKey("Z")
self.holdKey("Alt_L")
self.holdKey("Z")
try:
keyframe.find_fuzzy("OK", "push button").click()
finally:
_releaseKey("Z")
_releaseKey("Alt_L")
self.releaseKey("Z")
self.releaseKey("Alt_L")
win.find("Feedback", "page tab").click()
win.find_fuzzy(None, "check box",

View File

@ -34,6 +34,27 @@ class UITestCase(unittest.TestCase):
def pressKey(*args, **kwargs):
return dogtail.rawinput.pressKey(*args, **kwargs)
def holdKey(self, keyName):
# From dogtail 9.9.0 which isn't widely distributed yet
code = dogtail.rawinput.keyNameToKeyCode(keyName)
pyatspi.Registry().generateKeyboardEvent(
code, None, pyatspi.KEY_PRESS)
def releaseKey(self, keyName):
# From dogtail 9.9.0 which isn't widely distributed yet
code = dogtail.rawinput.keyNameToKeyCode(keyName)
pyatspi.Registry().generateKeyboardEvent(
code, None, pyatspi.KEY_RELEASE)
def point(self, x, y):
# From dogtail 9.9.0 which isn't widely distributed yet
pyatspi.Registry().generateMouseEvent(x, y, 'abs')
#################################
# virt-manager specific helpers #
#################################
def _open_host_window(self, tab, conn_label="test testdriver.xml"):
"""
Helper to open host connection window and switch to a tab