utils: Have find 'name' match labeller text too

Simplifies API callers
This commit is contained in:
Cole Robinson 2018-01-19 11:16:09 -05:00
parent d3b6df8e9a
commit 72f006ae8b
10 changed files with 88 additions and 69 deletions

View File

@ -45,21 +45,21 @@ class Details(uiutils.UITestCase):
# VNC example
tab = self._select_hw(addhw, "Graphics", "graphics-tab")
tab.find(None, "combo box", "Type:").click_combo_entry()
tab.find("Type:", "combo box").click_combo_entry()
tab.find_fuzzy("VNC", "menu item").click()
tab.find(None, "combo box", "Listen type:").click_combo_entry()
tab.find("Listen type:", "combo box").click_combo_entry()
tab.find_fuzzy("Address", "menu item").click()
tab.find(None, "combo box", "Address:").click_combo_entry()
tab.find("Address:", "combo box").click_combo_entry()
tab.find_fuzzy("All interfaces", "menu item").click()
tab.find("graphics-port-auto", "check").click()
tab.find("graphics-port", "spin button").text = "1234"
tab.find(None, "check", "Password:").click()
tab.find("Password:", "check").click()
passwd = tab.find_fuzzy("graphics-password", "text")
newpass = "foobar"
passwd.typeText(newpass)
tab.find("Show password", "check").click()
self.assertEqual(passwd.text, newpass)
tab.find(None, "combo box", "Keymap:").click()
tab.find("Keymap:", "combo box").click()
self.pressKey("Down")
self.pressKey("Down")
self.pressKey("Down")
@ -75,7 +75,7 @@ class Details(uiutils.UITestCase):
# Spice regular example
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Graphics", "graphics-tab")
tab.find(None, "combo box", "Type:").click_combo_entry()
tab.find("Type:", "combo box").click_combo_entry()
tab.find_fuzzy("Spice", "menu item").click()
tab.find("graphics-tlsport-auto", "check").click()
tab.find("graphics-tlsport", "spin button").text = "5999"
@ -85,11 +85,11 @@ class Details(uiutils.UITestCase):
# Spice GL example
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Graphics", "graphics-tab")
tab.find(None, "combo box", "Type:").click_combo_entry()
tab.find("Type:", "combo box").click_combo_entry()
tab.find_fuzzy("Spice", "menu item").click()
tab.find(None, "combo box", "Listen type:").click_combo_entry()
tab.find("Listen type:", "combo box").click_combo_entry()
tab.find_fuzzy("None", "menu item").click()
tab.find(None, "check box", "OpenGL:").click()
tab.find("OpenGL:", "check box").click()
render = tab.find("graphics-rendernode", "combo box")
m = tab.find_fuzzy("Intel Corp", "menu item")
render.click_combo_entry()
@ -153,9 +153,9 @@ class Details(uiutils.UITestCase):
# Add console device
tab = self._select_hw(addhw, "Console", "char-tab")
tab.find(None, "combo box", "Device Type:").click()
tab.find("Device Type:", "combo box").click()
tab.find_fuzzy("Pseudo TTY", "menu item").click()
tab.find(None, "combo box", "Type:").click()
tab.find("Type:", "combo box").click()
tab.find_fuzzy("Hypervisor default", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
@ -163,16 +163,16 @@ class Details(uiutils.UITestCase):
# Add serial+file
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Serial", "char-tab")
tab.find(None, "combo box", "Device Type:").click()
tab.find("Device Type:", "combo box").click()
tab.find_fuzzy("Output to a file", "menu item").click()
tab.find(None, "text", "Path:").text = "/tmp/foo.log"
tab.find("Path:", "text").text = "/tmp/foo.log"
finish.click()
uiutils.check_in_loop(lambda: details.active)
# Add udp serial
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Serial", "char-tab")
tab.find(None, "combo box", "Device Type:").click()
tab.find("Device Type:", "combo box").click()
tab.find_fuzzy("UDP", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
@ -180,9 +180,9 @@ class Details(uiutils.UITestCase):
# Add parallel+device
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Parallel", "char-tab")
tab.find(None, "combo box", "Device Type:").click()
tab.find("Device Type:", "combo box").click()
tab.find_fuzzy("Physical host character", "menu item").click()
tab.find(None, "text", "Path:").text = "/dev/parallel0"
tab.find("Path:", "text").text = "/dev/parallel0"
finish.click()
uiutils.check_in_loop(lambda: details.active)
@ -207,11 +207,11 @@ class Details(uiutils.UITestCase):
# Add File+nbd share
tab = self._select_hw(addhw, "Filesystem", "filesystem-tab")
tab.find(None, "combo box", "Type:").click()
tab.find("Type:", "combo box").click()
tab.find("File", "menu item").click()
tab.find(None, "combo box", "Driver:").click()
tab.find("Driver:", "combo box").click()
tab.find("Nbd", "menu item").click()
tab.find(None, "combo box", "Format:").click()
tab.find("Format:", "combo box").click()
tab.find("qcow2", "menu item").click()
tab.find("Browse...", "push button").click()
@ -220,8 +220,8 @@ class Details(uiutils.UITestCase):
browsewin.find("Cancel", "push button").click()
uiutils.check_in_loop(lambda: addhw.active)
tab.find_fuzzy(None, "text", "Source path:").text = "/foo/source"
tab.find_fuzzy(None, "text", "Target path:").text = "/foo/target"
tab.find("Source path:", "text").text = "/foo/source"
tab.find("Target path:", "text").text = "/foo/target"
tab.find_fuzzy("Export filesystem", "check").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
@ -229,10 +229,10 @@ class Details(uiutils.UITestCase):
# Add RAM type
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Filesystem", "filesystem-tab")
tab.find(None, "combo box", "Type:").click()
tab.find("Type:", "combo box").click()
tab.find("Ram", "menu item").click()
tab.find(None, "spin button", "Usage:").text = "12345"
tab.find_fuzzy(None, "text", "Target path:").text = "/mem"
tab.find("Usage:", "spin button").text = "12345"
tab.find("Target path:", "text").text = "/mem"
finish.click()
uiutils.check_in_loop(lambda: details.active)
@ -247,7 +247,7 @@ class Details(uiutils.UITestCase):
# Add input
tab = self._select_hw(addhw, "Input", "input-tab")
tab.find(None, "combo box", "Type:").click()
tab.find("Type:", "combo box").click()
tab.find("EvTouch", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
@ -255,7 +255,7 @@ class Details(uiutils.UITestCase):
# Add sound
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Sound", "sound-tab")
tab.find(None, "combo box", "Model:").click()
tab.find("Model:", "combo box").click()
tab.find("ich6", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
@ -263,7 +263,7 @@ class Details(uiutils.UITestCase):
# Add video
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Video", "video-tab")
tab.find(None, "combo box", "Model:").click()
tab.find("Model:", "combo box").click()
tab.find("QXL", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
@ -271,9 +271,9 @@ class Details(uiutils.UITestCase):
# Add watchdog
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Watchdog", "watchdog-tab")
tab.find(None, "combo box", "Model:").click()
tab.find("Model:", "combo box").click()
tab.find("i6300esb", "menu item").click()
tab.find(None, "combo box", "Action:").click()
tab.find("Action:", "combo box").click()
tab.find("Pause the guest", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
@ -281,7 +281,7 @@ class Details(uiutils.UITestCase):
# Add smartcard
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Smartcard", "smartcard-tab")
tab.find(None, "combo box", "Mode:").click()
tab.find("Mode:", "combo box").click()
tab.find("Passthrough", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
@ -289,29 +289,29 @@ class Details(uiutils.UITestCase):
# Add basic filesystem
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Filesystem", "filesystem-tab")
tab.find_fuzzy(None, "text", "Source path:").text = "/foo/source"
tab.find_fuzzy(None, "text", "Target path:").text = "/foo/target"
tab.find("Source path:", "text").text = "/foo/source"
tab.find("Target path:", "text").text = "/foo/target"
finish.click()
uiutils.check_in_loop(lambda: details.active)
# Add TPM
self._open_addhw_window(details)
tab = self._select_hw(addhw, "TPM", "tpm-tab")
tab.find(None, "text", "Device Path:").text = "/tmp/foo"
tab.find("Device Path:", "text").text = "/tmp/foo"
finish.click()
uiutils.check_in_loop(lambda: details.active)
# Add RNG
self._open_addhw_window(details)
tab = self._select_hw(addhw, "RNG", "rng-tab")
tab.find(None, "text", "Device:").text = "/dev/random"
tab.find("Device:", "text").text = "/dev/random"
finish.click()
uiutils.check_in_loop(lambda: details.active)
# Add Panic
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Panic", "panic-tab")
tab.find(None, "combo box", "Model:").click()
tab.find("Model:", "combo box").click()
tab.find("Hyper-V", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)

View File

@ -20,7 +20,7 @@ class VMMCLI(uiutils.UITestCase):
self.assertEqual(self.app.topwin.name,
"test testdriver.xml Connection Details")
self.assertEqual(
self.app.topwin.find_fuzzy(None, "text", "Name:").text,
self.app.topwin.find_fuzzy("Name:", "text").text,
"test testdriver.xml")
def testShowDetails(self):

View File

@ -28,7 +28,7 @@ class CreateInterface(uiutils.UITestCase):
bridgewin.find(None,
"spin button", "Forward delay:").text = "0.05"
bridgewin.find("OK", "push button").click()
name = win.find(None, "text", "Name:")
name = win.find("Name:", "text")
name.text = newname
finish.click()
@ -67,7 +67,7 @@ class CreateInterface(uiutils.UITestCase):
# figure out clicking checked cell renderers for bond interfaces...
hostwin.find("interface-add", "push button").click()
uiutils.check_in_loop(lambda: win.active)
typ = win.find(None, "combo box", "Interface type:")
typ = win.find("Interface type:", "combo box")
typ.click()
typ.find("Bond", "menu item").click()
forward.click()
@ -81,7 +81,7 @@ class CreateInterface(uiutils.UITestCase):
win.find("bond-configure", "push button").click()
bondwin = self.app.root.find("Bonding configuration", "dialog")
combo = bondwin.find(None, "combo box", "Bond monitor mode:")
combo = bondwin.find("Bond monitor mode:", "combo box")
combo.click()
combo.find("miimon", "menu item").click()
bondwin.find("OK", "push button").click()

View File

@ -21,7 +21,7 @@ class CreateNet(uiutils.UITestCase):
newname = "a-test-new-net"
forward = win.find("Forward", "push button")
finish = win.find("Finish", "push button")
name = win.find(None, "text", "Network Name:")
name = win.find("Network Name:", "text")
name.text = newname
forward.click()
forward.click()

View File

@ -21,7 +21,7 @@ class CreatePool(uiutils.UITestCase):
newname = "a-test-new-pool"
forward = win.find("Forward", "push button")
finish = win.find("Finish", "push button")
name = win.find(None, "text", "Name:")
name = win.find("Name:", "text")
name.text = newname
forward.click()
finish.click()
@ -55,7 +55,7 @@ class CreatePool(uiutils.UITestCase):
# Test a scsi pool
hostwin.find("pool-add", "push button").click()
uiutils.check_in_loop(lambda: win.active)
typ = win.find(None, "combo box", "Type:")
typ = win.find("Type:", "combo box")
newname = "a-scsi-pool"
name.text = "a-scsi-pool"
typ.click()
@ -72,8 +72,8 @@ class CreatePool(uiutils.UITestCase):
typ.click()
win.find_fuzzy("RADOS Block", "menu item").click()
forward.click()
win.find_fuzzy(None, "text", "Host Name:").text = "example.com:1234"
win.find_fuzzy(None, "text", "Source Name:").typeText("frob")
win.find_fuzzy("Host Name:", "text").text = "example.com:1234"
win.find_fuzzy("Source Name:", "text").typeText("frob")
finish.click()
hostwin.find(newname, "table cell")

View File

@ -22,9 +22,9 @@ class CreateVol(uiutils.UITestCase):
# Create a default qcow2 volume
newname = "a-newvol"
finish = win.find("Finish", "push button")
name = win.find(None, "text", "Name:")
name = win.find("Name:", "text")
name.text = newname
win.find(None, "spin button", "Max Capacity:").text = "10.5"
win.find("Max Capacity:", "spin button").text = "10.5"
finish.click()
# Delete it
@ -44,10 +44,10 @@ class CreateVol(uiutils.UITestCase):
uiutils.check_in_loop(lambda: win.active)
newname = "a-newvol.raw"
name.text = newname
combo = win.find(None, "combo box", "Format:")
combo = win.find("Format:", "combo box")
combo.click()
combo.find("raw", "menu item").click()
win.find(None, "spin button", "Allocation:").text = "0.5"
win.find("Allocation:", "spin button").text = "0.5"
finish.click()
vollist.find(newname)

View File

@ -40,7 +40,7 @@ class Details(uiutils.UITestCase):
win.find("Overview", "table cell").click()
oldcell = self.app.root.find_fuzzy(origname, "table cell")
win.find(None, "text", "Name:").text = newname
win.find("Name:", "text").text = newname
win.find("config-apply", "push button").click()
# Confirm lists were updated

View File

@ -136,7 +136,7 @@ class NewVM(uiutils.UITestCase):
newvm.find_fuzzy("Network Install", "radio").click()
newvm.find_fuzzy("Forward", "button").click()
newvm.find(None, "text", "URL").text = (
newvm.find("URL", "text").text = (
"http://vault.centos.org/5.5/os/x86_64/")
version = newvm.find("install-os-version-label")
@ -166,7 +166,7 @@ class NewVM(uiutils.UITestCase):
newvm = self._open_create_wizard()
newvm.find_fuzzy("Architecture options", "toggle").click()
newvm.find_fuzzy(None, "combo", "Architecture").click()
newvm.find_fuzzy("Architecture", "combo").click()
newvm.find_fuzzy("ppc64", "menu item").click()
newvm.find_fuzzy("pseries", "menu item")
@ -184,12 +184,12 @@ class NewVM(uiutils.UITestCase):
newvm = self._open_create_wizard()
newvm.find_fuzzy("Architecture options", "toggle").click()
newvm.find_fuzzy(None, "combo", "Virt Type").click()
newvm.find_fuzzy("Virt Type", "combo").click()
KVM = newvm.find_fuzzy("KVM", "menu item")
TCG = newvm.find_fuzzy("TCG", "menu item")
self.assertTrue(KVM.focused)
self.assertTrue(TCG.showing)
newvm.find_fuzzy(None, "combo", "Virt Type").click()
newvm.find_fuzzy("Virt Type", "combo").click()
# Validate some initial defaults
self.assertFalse(
@ -296,7 +296,7 @@ class NewVM(uiutils.UITestCase):
newvm = self._open_create_wizard()
newvm.find_fuzzy("Architecture options", "toggle").click()
newvm.find_fuzzy(None, "combo", "Xen Type").click()
newvm.find_fuzzy("Xen Type", "combo").click()
newvm.find_fuzzy("paravirt", "menu item").click()
self._do_simple_import(newvm)

View File

@ -62,7 +62,7 @@ class Snapshots(uiutils.UITestCase):
uiutils.check_in_loop(lambda: vmpause.checked)
# Edit snapshot
desc = win.find(None, "text", "Description:")
desc = win.find("Description:", "text")
desc.text = "Test description foofoo"
win.find("snapshot-apply", "push button").click()
win.find("snapshot-refresh", "push button").click()
@ -71,10 +71,9 @@ class Snapshots(uiutils.UITestCase):
# Create new snapshot
win.find("snapshot-add", "push button").click()
newwin = self.app.root.find("Create snapshot", "frame")
newwin.print_nodes()
snapname = "testnewsnap"
newwin.find(None, "text", "Name:").text = snapname
newwin.find(None, "text", "Description:").text = "testdesc"
newwin.find("Name:", "text").text = snapname
newwin.find("Description:", "text").text = "testdesc"
newwin.find("Finish", "push button").click()
uiutils.check_in_loop(lambda: not newwin.showing)
newc = win.find(snapname, "table cell")

View File

@ -88,10 +88,25 @@ class _FuzzyPredicate(dogtail.predicate.Predicate):
Object dogtail/pyatspi want for node searching.
"""
def __init__(self, name=None, roleName=None, labeller_text=None):
self._name_pattern = re.compile(name or ".*")
self._role_pattern = re.compile(roleName or ".*")
self._labeller_text = bool(labeller_text)
self._labeller_pattern = re.compile(labeller_text or ".*")
"""
:param name: Match node.name or node.labeller.text if
labeller_text not specified
:param roleName: Match node.roleName
:param labeller_text: Match node.labeller.text
"""
self._name = name
self._roleName = roleName
self._labeller_text = labeller_text
self._name_pattern = None
self._role_pattern = None
self._labeller_pattern = None
if self._name:
self._name_pattern = re.compile(self._name)
if self._roleName:
self._role_pattern = re.compile(self._roleName)
if self._labeller_text:
self._labeller_pattern = re.compile(self._labeller_text)
def makeScriptMethodCall(self, isRecursive):
ignore = isRecursive
@ -108,15 +123,20 @@ class _FuzzyPredicate(dogtail.predicate.Predicate):
The actual search routine
"""
try:
if not self._name_pattern.match(node.name):
if self._roleName and not self._role_pattern.match(node.roleName):
return
if not self._role_pattern.match(node.roleName):
labeller = ""
if node.labeller:
labeller = node.labeller.text
if (self._name and
not self._name_pattern.match(node.name) and
not self._name_pattern.match(labeller)):
return
if (self._labeller_text and
not self._labeller_pattern.match(labeller)):
return
if self._labeller_text:
if not node.labeller:
return
if not self._labeller_pattern.match(node.labeller.text):
return
return True
except Exception as e:
print("got predicate exception: %s" % e)