mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
uitests: Move helper functions into the Node wrapper class
This commit is contained in:
parent
9c4c9aeb8f
commit
a4e1b64f1a
@ -17,7 +17,7 @@ from tests.uitests import utils
|
||||
# Perform 5 search attempts if a widget lookup fails (default 20)
|
||||
dogtail.config.config.searchCutoffCount = 5
|
||||
|
||||
# Use .4 second delay between each action (default 1)
|
||||
# Use .1 second delay between each action (default 1)
|
||||
dogtail.config.config.actionDelay = .1
|
||||
|
||||
# Turn off needlessly noisy debugging
|
||||
|
@ -13,10 +13,10 @@ class VMMAbout(uiutils.UITestCase):
|
||||
##############
|
||||
|
||||
def testAbout(self):
|
||||
uiutils.find_pattern(self.app.root, "Help", "menu").click()
|
||||
uiutils.find_pattern(self.app.root, "About", "menu item").click()
|
||||
win = uiutils.find_fuzzy(self.app.root, "About", "dialog")
|
||||
l = uiutils.find_fuzzy(win, "Copyright", "label")
|
||||
self.app.root.find_pattern("Help", "menu").click()
|
||||
self.app.root.find_pattern("About", "menu item").click()
|
||||
win = self.app.root.find_fuzzy("About", "dialog")
|
||||
l = win.find_fuzzy("Copyright", "label")
|
||||
|
||||
curyear = datetime.datetime.today().strftime("%Y")
|
||||
if curyear not in l.text:
|
||||
|
@ -20,7 +20,7 @@ class VMMCLI(uiutils.UITestCase):
|
||||
self.assertEqual(self.app.topwin.name,
|
||||
"test testdriver.xml Connection Details")
|
||||
self.assertEqual(
|
||||
uiutils.find_fuzzy(self.app.topwin, None, "text", "Name:").text,
|
||||
self.app.topwin.find_fuzzy(None, "text", "Name:").text,
|
||||
"test testdriver.xml")
|
||||
|
||||
def testShowDetails(self):
|
||||
@ -28,10 +28,10 @@ class VMMCLI(uiutils.UITestCase):
|
||||
|
||||
self.assertTrue("test-clone-simple on" in self.app.topwin.name)
|
||||
self.assertFalse(
|
||||
uiutils.find_fuzzy(self.app.topwin,
|
||||
self.app.topwin.find_fuzzy(
|
||||
"Guest is not running", "label").showing)
|
||||
self.assertTrue(
|
||||
uiutils.find_fuzzy(self.app.topwin,
|
||||
self.app.topwin.find_fuzzy(
|
||||
"add-hardware", "button").showing)
|
||||
|
||||
def testShowPerformance(self):
|
||||
@ -40,18 +40,18 @@ class VMMCLI(uiutils.UITestCase):
|
||||
|
||||
self.assertTrue("test-clone-simple on" in self.app.topwin.name)
|
||||
self.assertFalse(
|
||||
uiutils.find_fuzzy(self.app.topwin,
|
||||
self.app.topwin.find_fuzzy(
|
||||
"Guest is not running", "label").showing)
|
||||
self.assertTrue(
|
||||
uiutils.find_fuzzy(self.app.topwin, "CPU usage", "label").showing)
|
||||
self.app.topwin.find_fuzzy("CPU usage", "label").showing)
|
||||
|
||||
def testShowConsole(self):
|
||||
self.app.open(extra_opts=["--show-domain-console", "test-clone-simple"])
|
||||
|
||||
self.assertTrue("test-clone-simple on" in self.app.topwin.name)
|
||||
self.assertTrue(
|
||||
uiutils.find_fuzzy(self.app.topwin,
|
||||
self.app.topwin.find_fuzzy(
|
||||
"Guest is not running", "label").showing)
|
||||
self.assertFalse(
|
||||
uiutils.find_fuzzy(self.app.topwin,
|
||||
self.app.topwin.find_fuzzy(
|
||||
"add-hardware", "button").showing)
|
||||
|
@ -13,11 +13,10 @@ class CloneVM(uiutils.UITestCase):
|
||||
|
||||
def _open_window(self, vmname):
|
||||
# Launch wizard via right click menu
|
||||
c = uiutils.find_fuzzy(self.app.root, vmname, "table cell")
|
||||
c = self.app.root.find_fuzzy(vmname, "table cell")
|
||||
c.click(button=3)
|
||||
uiutils.find_pattern(self.app.root, "Clone...", "menu item").click()
|
||||
return uiutils.find_pattern(
|
||||
self.app.root, "Clone Virtual Machine", "frame")
|
||||
self.app.root.find_pattern("Clone...", "menu item").click()
|
||||
return self.app.root.find_pattern("Clone Virtual Machine", "frame")
|
||||
|
||||
|
||||
##############
|
||||
@ -29,59 +28,54 @@ class CloneVM(uiutils.UITestCase):
|
||||
Clone test-clone, which is meant to hit many clone code paths
|
||||
"""
|
||||
win = self._open_window("test-clone")
|
||||
uiutils.find_pattern(win, "Clone", "push button").click()
|
||||
win.find_pattern("Clone", "push button").click()
|
||||
|
||||
# Verify the new VM popped up
|
||||
uiutils.find_pattern(
|
||||
self.app.root, "test-clone1", "table cell")
|
||||
self.app.root.find_pattern("test-clone1", "table cell")
|
||||
|
||||
def testCloneSimple(self):
|
||||
"""
|
||||
Clone test-clone-simple
|
||||
"""
|
||||
win = self._open_window("test-clone-simple")
|
||||
uiutils.find_pattern(win, "Clone", "push button").click()
|
||||
win.find_pattern("Clone", "push button").click()
|
||||
|
||||
# Verify the new VM popped up
|
||||
uiutils.find_pattern(
|
||||
self.app.root, "test-clone-simple-clone", "table cell")
|
||||
self.app.root.find_pattern("test-clone-simple-clone", "table cell")
|
||||
|
||||
def testFullClone(self):
|
||||
"""
|
||||
Clone test-full-clone, which should error due to lack of space
|
||||
"""
|
||||
win = self._open_window("test-clone-full")
|
||||
uiutils.find_pattern(win, "Clone", "push button").click()
|
||||
win.find_pattern("Clone", "push button").click()
|
||||
|
||||
# Verify error dialog popped up
|
||||
uiutils.find_pattern(
|
||||
self.app.root, ".*There is not enough free space.*", "label")
|
||||
self.app.root.find_pattern(
|
||||
".*There is not enough free space.*", "label")
|
||||
|
||||
def testCloneTweaks(self):
|
||||
"""
|
||||
Clone test-clone-simple, but tweak bits in the clone UI
|
||||
"""
|
||||
win = self._open_window("test-clone-simple")
|
||||
uiutils.find_fuzzy(win, None,
|
||||
win.find_fuzzy(None,
|
||||
"text", "Name").text = "test-new-vm"
|
||||
|
||||
uiutils.find_pattern(win, "Details...", "push button").click()
|
||||
macwin = uiutils.find_pattern(
|
||||
self.app.root, "Change MAC address", "dialog")
|
||||
uiutils.find_pattern(macwin, None,
|
||||
win.find_pattern("Details...", "push button").click()
|
||||
macwin = self.app.root.find_pattern("Change MAC address", "dialog")
|
||||
macwin.find_pattern(None,
|
||||
"text", "New MAC:").text = "00:16:3e:cc:cf:05"
|
||||
uiutils.find_pattern(macwin, "OK", "push button").click()
|
||||
macwin.find_pattern("OK", "push button").click()
|
||||
|
||||
uiutils.find_fuzzy(win, "Clone this disk.*", "combo box").click()
|
||||
uiutils.find_fuzzy(win, "Details...", "menu item").click()
|
||||
stgwin = uiutils.find_pattern(
|
||||
self.app.root, "Change storage path", "dialog")
|
||||
uiutils.find_pattern(stgwin, None, "text",
|
||||
win.find_fuzzy("Clone this disk.*", "combo box").click()
|
||||
win.find_fuzzy("Details...", "menu item").click()
|
||||
stgwin = self.app.root.find_pattern("Change storage path", "dialog")
|
||||
stgwin.find_pattern(None, "text",
|
||||
"New Path:").text = "/dev/default-pool/my-new-path"
|
||||
uiutils.find_pattern(stgwin, "OK", "push button").click()
|
||||
stgwin.find_pattern("OK", "push button").click()
|
||||
|
||||
uiutils.find_pattern(win, "Clone", "push button").click()
|
||||
win.find_pattern("Clone", "push button").click()
|
||||
|
||||
# Verify the new VM popped up
|
||||
uiutils.find_pattern(
|
||||
self.app.root, "test-new-vm", "table cell")
|
||||
self.app.root.find_pattern("test-new-vm", "table cell")
|
||||
|
@ -12,61 +12,59 @@ class VMMConnect(uiutils.UITestCase):
|
||||
|
||||
def testConnect(self):
|
||||
# Start with connection delete
|
||||
c = uiutils.find_pattern(self.app.root,
|
||||
"test testdriver.xml", "table cell")
|
||||
c = self.app.root.find_pattern("test testdriver.xml", "table cell")
|
||||
c.click(button=3)
|
||||
uiutils.find_pattern(self.app.root, "conn-disconnect",
|
||||
self.app.root.find_pattern("conn-disconnect",
|
||||
"menu item").click()
|
||||
uiutils.check_in_loop(lambda: "Not Connected" in c.text)
|
||||
c.click(button=3)
|
||||
uiutils.find_pattern(self.app.root, "conn-delete", "menu item").click()
|
||||
err = uiutils.find_pattern(self.app.root, "vmm simple dialog", "alert")
|
||||
uiutils.find_fuzzy(err, "will remove the connection", "label")
|
||||
uiutils.find_fuzzy(err, "Yes", "push button").click()
|
||||
self.app.root.find_pattern("conn-delete", "menu item").click()
|
||||
err = self.app.root.find_pattern("vmm simple dialog", "alert")
|
||||
err.find_fuzzy("will remove the connection", "label")
|
||||
err.find_fuzzy("Yes", "push button").click()
|
||||
uiutils.check_in_loop(lambda: c.dead)
|
||||
|
||||
# Launch the dialog, grab some UI pointers
|
||||
uiutils.find_pattern(self.app.root, "File", "menu").click()
|
||||
uiutils.find_pattern(self.app.root,
|
||||
"Add Connection...", "menu item").click()
|
||||
win = uiutils.find_fuzzy(self.app.root, "Add Connection", "dialog")
|
||||
self.app.root.find_pattern("File", "menu").click()
|
||||
self.app.root.find_pattern("Add Connection...", "menu item").click()
|
||||
win = self.app.root.find_fuzzy("Add Connection", "dialog")
|
||||
|
||||
connect = uiutils.find_pattern(win, "Connect", "push button")
|
||||
remote = uiutils.find_fuzzy(win, "Connect to remote", "check box")
|
||||
meth = uiutils.find_pattern(win, "Method", "combo box")
|
||||
user = uiutils.find_pattern(win, "Username", "text")
|
||||
host = uiutils.find_pattern(win, "Hostname", "text")
|
||||
urilabel = uiutils.find_pattern(win, "uri-label", "label")
|
||||
urientry = uiutils.find_pattern(win, "uri-entry", "text")
|
||||
connect = win.find_pattern("Connect", "push button")
|
||||
remote = win.find_fuzzy("Connect to remote", "check box")
|
||||
meth = win.find_pattern("Method", "combo box")
|
||||
user = win.find_pattern("Username", "text")
|
||||
host = win.find_pattern("Hostname", "text")
|
||||
urilabel = win.find_pattern("uri-label", "label")
|
||||
urientry = win.find_pattern("uri-entry", "text")
|
||||
self.assertTrue(meth.showing is user.showing is host.showing is True)
|
||||
|
||||
uiutils.find_fuzzy(win, "Hypervisor", "combo box").click()
|
||||
uiutils.find_fuzzy(win, "QEMU/KVM user session", "menu item").click()
|
||||
win.find_fuzzy("Hypervisor", "combo box").click()
|
||||
win.find_fuzzy("QEMU/KVM user session", "menu item").click()
|
||||
self.assertTrue(meth.showing is user.showing is host.showing is False)
|
||||
self.assertTrue(urilabel.text == "qemu:///session")
|
||||
|
||||
# Enter a failing URI, make sure error is raised, and we can
|
||||
# fall back to the dialog
|
||||
uiutils.find_fuzzy(win, "Hypervisor", "combo box").click()
|
||||
uiutils.find_fuzzy(win, "Xen", "menu item").click()
|
||||
win.find_fuzzy("Hypervisor", "combo box").click()
|
||||
win.find_fuzzy("Xen", "menu item").click()
|
||||
remote.click()
|
||||
meth.click()
|
||||
uiutils.find_fuzzy(win, "Kerberos", "menu item").click()
|
||||
win.find_fuzzy("Kerberos", "menu item").click()
|
||||
user.text = "fribuser"
|
||||
host.text = "redhat.com:12345"
|
||||
self.assertTrue(
|
||||
urilabel.text == "xen+tcp://fribuser@redhat.com:12345/")
|
||||
connect.click()
|
||||
|
||||
err = uiutils.find_fuzzy(self.app.root, "vmm error dialog", "alert")
|
||||
uiutils.find_fuzzy(err, "No", "push button").click()
|
||||
err = self.app.root.find_fuzzy("vmm error dialog", "alert")
|
||||
err.find_fuzzy("No", "push button").click()
|
||||
|
||||
# Test with custom test:///default connection
|
||||
uiutils.find_fuzzy(win, "Hypervisor", "combo box").click()
|
||||
uiutils.find_fuzzy(win, "Custom URI", "menu item").click()
|
||||
win.find_fuzzy("Hypervisor", "combo box").click()
|
||||
win.find_fuzzy("Custom URI", "menu item").click()
|
||||
urientry.text = "test:///default"
|
||||
connect.click()
|
||||
|
||||
uiutils.check_in_loop(lambda: win.showing is False)
|
||||
c = uiutils.find_pattern(self.app.root, "test default", "table cell")
|
||||
c = self.app.root.find_pattern("test default", "table cell")
|
||||
c.click()
|
||||
|
@ -14,11 +14,11 @@ class Details(uiutils.UITestCase):
|
||||
###################
|
||||
|
||||
def _open_details_window(self, vmname="test-many-devices"):
|
||||
uiutils.find_fuzzy(self.app.root, vmname, "table cell").click(button=3)
|
||||
uiutils.find_pattern(self.app.root, "Open", "menu item").click()
|
||||
self.app.root.find_fuzzy(vmname, "table cell").click(button=3)
|
||||
self.app.root.find_pattern("Open", "menu item").click()
|
||||
|
||||
win = uiutils.find_pattern(self.app.root, "%s on" % vmname, "frame")
|
||||
uiutils.find_pattern(win, "Details", "radio button").click()
|
||||
win = self.app.root.find_pattern("%s on" % vmname, "frame")
|
||||
win.find_pattern("Details", "radio button").click()
|
||||
return win
|
||||
|
||||
|
||||
@ -34,8 +34,8 @@ class Details(uiutils.UITestCase):
|
||||
win = self._open_details_window()
|
||||
|
||||
# Ensure the Overview page is the first selected
|
||||
uiutils.find_pattern(win, "Hypervisor Details", "label")
|
||||
uiutils.find_pattern(win, "Overview", "table cell").click()
|
||||
win.find_pattern("Hypervisor Details", "label")
|
||||
win.find_pattern("Overview", "table cell").click()
|
||||
|
||||
# After we hit this number of down presses, start checking for
|
||||
# widget focus to determine if we hit the end of the list. We
|
||||
@ -53,7 +53,7 @@ class Details(uiutils.UITestCase):
|
||||
|
||||
if not win.getState().contains(pyatspi.STATE_ACTIVE):
|
||||
# Should mean an error dialog popped up
|
||||
uiutils.find_pattern(self.app.root, "Error", "alert")
|
||||
self.app.root.find_pattern("Error", "alert")
|
||||
raise AssertionError(
|
||||
"One of the hardware pages raised an error")
|
||||
|
||||
@ -63,7 +63,7 @@ class Details(uiutils.UITestCase):
|
||||
|
||||
# pylint: disable=not-an-iterable
|
||||
old_focused = focused
|
||||
focused = uiutils.focused_nodes(win)
|
||||
focused = win.focused_nodes()
|
||||
if old_focused is None:
|
||||
continue
|
||||
|
||||
@ -79,16 +79,16 @@ class Details(uiutils.UITestCase):
|
||||
win = self._open_details_window(origname)
|
||||
|
||||
# Ensure the Overview page is the first selected
|
||||
uiutils.find_pattern(win, "Hypervisor Details", "label")
|
||||
uiutils.find_pattern(win, "Overview", "table cell").click()
|
||||
win.find_pattern("Hypervisor Details", "label")
|
||||
win.find_pattern("Overview", "table cell").click()
|
||||
|
||||
oldcell = uiutils.find_fuzzy(self.app.root, origname, "table cell")
|
||||
uiutils.find_pattern(win, None, "text", "Name:").text = newname
|
||||
uiutils.find_pattern(win, "config-apply", "push button").click()
|
||||
oldcell = self.app.root.find_fuzzy(origname, "table cell")
|
||||
win.find_pattern(None, "text", "Name:").text = newname
|
||||
win.find_pattern("config-apply", "push button").click()
|
||||
|
||||
# Confirm lists were updated
|
||||
uiutils.find_pattern(self.app.root, "%s on" % newname, "frame")
|
||||
uiutils.find_fuzzy(self.app.root, newname, "table cell")
|
||||
self.app.root.find_pattern("%s on" % newname, "frame")
|
||||
self.app.root.find_fuzzy(newname, "table cell")
|
||||
|
||||
# Make sure the old entry is gone
|
||||
uiutils.check_in_loop(lambda: origname not in oldcell.name)
|
||||
@ -105,8 +105,8 @@ class Details(uiutils.UITestCase):
|
||||
"""
|
||||
origname = "test-many-devices"
|
||||
# Shutdown the VM
|
||||
uiutils.find_fuzzy(self.app.root, origname, "table cell").click()
|
||||
b = uiutils.find_pattern(self.app.root, "Shut Down", "push button")
|
||||
self.app.root.find_fuzzy(origname, "table cell").click()
|
||||
b = self.app.root.find_pattern("Shut Down", "push button")
|
||||
b.click()
|
||||
# This insures the VM finished shutting down
|
||||
uiutils.check_in_loop(lambda: b.sensitive is False)
|
||||
|
@ -17,15 +17,12 @@ class Host(uiutils.UITestCase):
|
||||
|
||||
def _open_host_window(self, tab):
|
||||
conn_label = "test testdriver.xml"
|
||||
uiutils.find_fuzzy(self.app.root, conn_label,
|
||||
"table cell").click()
|
||||
uiutils.find_fuzzy(self.app.root, "Edit", "menu").click()
|
||||
uiutils.find_fuzzy(self.app.root, "Connection Details",
|
||||
"menu item").click()
|
||||
win = uiutils.find_fuzzy(self.app.root,
|
||||
"%s Connection Details" % conn_label,
|
||||
"frame")
|
||||
uiutils.find_fuzzy(win, tab, "page tab").click()
|
||||
self.app.root.find_fuzzy(conn_label, "table cell").click()
|
||||
self.app.root.find_fuzzy("Edit", "menu").click()
|
||||
self.app.root.find_fuzzy("Connection Details", "menu item").click()
|
||||
win = self.app.root.find_fuzzy(
|
||||
"%s Connection Details" % conn_label, "frame")
|
||||
win.find_fuzzy(tab, "page tab").click()
|
||||
return win
|
||||
|
||||
def _checkListEntrys(self, win, check_after):
|
||||
@ -41,7 +38,7 @@ class Host(uiutils.UITestCase):
|
||||
|
||||
if not win.getState().contains(pyatspi.STATE_ACTIVE):
|
||||
# Should mean an error dialog popped up
|
||||
uiutils.find_pattern(self.app.root, "Error", "alert")
|
||||
self.app.root.find_pattern("Error", "alert")
|
||||
raise AssertionError(
|
||||
"One of the pages raised an error")
|
||||
|
||||
@ -51,7 +48,7 @@ class Host(uiutils.UITestCase):
|
||||
|
||||
# pylint: disable=not-an-iterable
|
||||
old_focused = focused
|
||||
focused = uiutils.focused_nodes(win)
|
||||
focused = win.focused_nodes()
|
||||
if old_focused is None:
|
||||
continue
|
||||
|
||||
@ -73,7 +70,7 @@ class Host(uiutils.UITestCase):
|
||||
win = self._open_host_window("Virtual Networks")
|
||||
|
||||
# Make sure the first item is selected
|
||||
cell = uiutils.find_pattern(win, "default", "table cell")
|
||||
cell = win.find_pattern("default", "table cell")
|
||||
self.assertTrue(cell.getState().contains(pyatspi.STATE_SELECTED))
|
||||
|
||||
self._checkListEntrys(win, 13)
|
||||
@ -85,7 +82,7 @@ class Host(uiutils.UITestCase):
|
||||
win = self._open_host_window("Storage")
|
||||
|
||||
# Make sure the first item is selected
|
||||
cell = uiutils.find_pattern(win, "cross-pool", "table cell")
|
||||
cell = win.find_pattern("cross-pool", "table cell")
|
||||
self.assertTrue(cell.getState().contains(pyatspi.STATE_SELECTED))
|
||||
|
||||
self._checkListEntrys(win, 13)
|
||||
@ -97,7 +94,7 @@ class Host(uiutils.UITestCase):
|
||||
win = self._open_host_window("Network Interfaces")
|
||||
|
||||
# Make sure the first item is selected
|
||||
cell = uiutils.find_pattern(win, "bond0", "table cell")
|
||||
cell = win.find_pattern("bond0", "table cell")
|
||||
self.assertTrue(cell.getState().contains(pyatspi.STATE_SELECTED))
|
||||
|
||||
self._checkListEntrys(win, 18)
|
||||
|
@ -16,18 +16,18 @@ class NewVM(uiutils.UITestCase):
|
||||
###################
|
||||
|
||||
def _open_create_wizard(self):
|
||||
uiutils.find_pattern(self.app.root, "New", "push button").click()
|
||||
return uiutils.find_pattern(self.app.root, "New VM", "frame")
|
||||
self.app.root.find_pattern("New", "push button").click()
|
||||
return self.app.root.find_pattern("New VM", "frame")
|
||||
|
||||
def _do_simple_import(self, newvm):
|
||||
# Create default PXE VM
|
||||
uiutils.find_fuzzy(newvm, "Import", "radio").click()
|
||||
uiutils.find_fuzzy(newvm, None,
|
||||
newvm.find_fuzzy("Import", "radio").click()
|
||||
newvm.find_fuzzy(None,
|
||||
"text", "existing storage").text = "/dev/default-pool/testvol1.img"
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Finish", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Finish", "button").click()
|
||||
|
||||
|
||||
##############
|
||||
@ -42,23 +42,22 @@ class NewVM(uiutils.UITestCase):
|
||||
newvm = self._open_create_wizard()
|
||||
|
||||
# Create default PXE VM
|
||||
uiutils.find_fuzzy(newvm, "PXE", "radio").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Finish", "button").click()
|
||||
newvm.find_fuzzy("PXE", "radio").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Finish", "button").click()
|
||||
|
||||
# Delete it from the VM window
|
||||
vmwindow = uiutils.find_fuzzy(self.app.root, "generic on", "frame")
|
||||
uiutils.find_pattern(vmwindow, "Virtual Machine", "menu").click()
|
||||
uiutils.find_pattern(vmwindow, "Delete", "menu item").click()
|
||||
vmwindow = self.app.root.find_fuzzy("generic on", "frame")
|
||||
vmwindow.find_pattern("Virtual Machine", "menu").click()
|
||||
vmwindow.find_pattern("Delete", "menu item").click()
|
||||
|
||||
delete = uiutils.find_fuzzy(self.app.root, "Delete", "frame")
|
||||
uiutils.find_fuzzy(delete, "Delete", "button").click()
|
||||
alert = uiutils.find_pattern(self.app.root,
|
||||
"vmm error dialog", "alert")
|
||||
uiutils.find_fuzzy(alert, "Yes", "push button").click()
|
||||
delete = self.app.root.find_fuzzy("Delete", "frame")
|
||||
delete.find_fuzzy("Delete", "button").click()
|
||||
alert = self.app.root.find_pattern("vmm error dialog", "alert")
|
||||
alert.find_fuzzy("Yes", "push button").click()
|
||||
|
||||
# Verify delete dialog and VM dialog are now gone
|
||||
uiutils.check_in_loop(lambda: vmwindow.showing is False)
|
||||
@ -71,59 +70,58 @@ class NewVM(uiutils.UITestCase):
|
||||
"""
|
||||
newvm = self._open_create_wizard()
|
||||
|
||||
uiutils.find_fuzzy(newvm, "Local install media", "radio").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
newvm.find_fuzzy("Local install media", "radio").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
|
||||
# Select a fake iso
|
||||
uiutils.find_fuzzy(newvm, "Use ISO", "radio").click()
|
||||
uiutils.find_fuzzy(newvm, "install-iso-browse", "button").click()
|
||||
browser = uiutils.find_fuzzy(self.app.root, "Choose Storage", "frame")
|
||||
uiutils.find_fuzzy(browser, "default-pool", "table cell").click()
|
||||
uiutils.find_fuzzy(browser, "iso-vol", "table cell").click()
|
||||
uiutils.find_fuzzy(browser, "Choose Volume", "button").click()
|
||||
newvm.find_fuzzy("Use ISO", "radio").click()
|
||||
newvm.find_fuzzy("install-iso-browse", "button").click()
|
||||
browser = self.app.root.find_fuzzy("Choose Storage", "frame")
|
||||
browser.find_fuzzy("default-pool", "table cell").click()
|
||||
browser.find_fuzzy("iso-vol", "table cell").click()
|
||||
browser.find_fuzzy("Choose Volume", "button").click()
|
||||
|
||||
label = uiutils.find_fuzzy(newvm, "os-version-label", "label")
|
||||
label = newvm.find_fuzzy("os-version-label", "label")
|
||||
uiutils.check_in_loop(lambda: browser.showing is False)
|
||||
uiutils.check_in_loop(lambda: label.text == "Unknown")
|
||||
|
||||
# Change distro to win8
|
||||
uiutils.find_fuzzy(newvm, "Automatically detect", "check").click()
|
||||
version = uiutils.find_fuzzy(newvm,
|
||||
"install-os-version-entry", "text")
|
||||
newvm.find_fuzzy("Automatically detect", "check").click()
|
||||
version = newvm.find_fuzzy("install-os-version-entry", "text")
|
||||
self.assertEqual(version.text, "Generic")
|
||||
|
||||
ostype = uiutils.find_fuzzy(newvm, "install-os-type", "combo")
|
||||
ostype = newvm.find_fuzzy("install-os-type", "combo")
|
||||
ostype.click()
|
||||
uiutils.find_fuzzy(ostype, "Show all", "menu item").click()
|
||||
uiutils.find_fuzzy(newvm, "install-os-type", "combo").click()
|
||||
uiutils.find_fuzzy(newvm, "Windows", "menu item").click()
|
||||
uiutils.find_fuzzy(newvm, "install-os-version-entry",
|
||||
ostype.find_fuzzy("Show all", "menu item").click()
|
||||
newvm.find_fuzzy("install-os-type", "combo").click()
|
||||
newvm.find_fuzzy("Windows", "menu item").click()
|
||||
newvm.find_fuzzy("install-os-version-entry",
|
||||
"text").typeText("Microsoft Windows 8")
|
||||
uiutils.find_fuzzy(newvm, "install-os-version-entry", "text").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
newvm.find_fuzzy("install-os-version-entry", "text").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
|
||||
# Verify that CPU values are non-default
|
||||
cpus = uiutils.find_pattern(newvm, "cpus", "spin button")
|
||||
cpus = newvm.find_pattern("cpus", "spin button")
|
||||
uiutils.check_in_loop(lambda: int(cpus.text) > 1, timeout=5)
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
|
||||
# Select customize wizard
|
||||
uiutils.find_fuzzy(newvm, "Customize", "check").click()
|
||||
uiutils.find_fuzzy(newvm, "Finish", "button").click()
|
||||
newvm.find_fuzzy("Customize", "check").click()
|
||||
newvm.find_fuzzy("Finish", "button").click()
|
||||
|
||||
# Change to 'copy host CPU'
|
||||
vmwindow = uiutils.find_fuzzy(self.app.root, "win8 on", "frame")
|
||||
uiutils.find_fuzzy(vmwindow, "CPUs", "table cell").click()
|
||||
uiutils.find_fuzzy(vmwindow, "Copy host", "check").click()
|
||||
uiutils.find_fuzzy(vmwindow, "config-apply").click()
|
||||
vmwindow = self.app.root.find_fuzzy("win8 on", "frame")
|
||||
vmwindow.find_fuzzy("CPUs", "table cell").click()
|
||||
vmwindow.find_fuzzy("Copy host", "check").click()
|
||||
vmwindow.find_fuzzy("config-apply").click()
|
||||
|
||||
# Start the install, close via the VM window
|
||||
uiutils.find_fuzzy(vmwindow, "Begin Installation", "button").click()
|
||||
vmwindow.find_fuzzy("Begin Installation", "button").click()
|
||||
uiutils.check_in_loop(lambda: newvm.showing is False)
|
||||
vmwindow = uiutils.find_fuzzy(self.app.root, "win8 on", "frame")
|
||||
uiutils.find_fuzzy(vmwindow, "File", "menu").click()
|
||||
uiutils.find_fuzzy(vmwindow, "Quit", "menu item").click()
|
||||
vmwindow = self.app.root.find_fuzzy("win8 on", "frame")
|
||||
vmwindow.find_fuzzy("File", "menu").click()
|
||||
vmwindow.find_fuzzy("Quit", "menu item").click()
|
||||
uiutils.check_in_loop(lambda: self.app.is_running())
|
||||
|
||||
|
||||
@ -135,28 +133,28 @@ class NewVM(uiutils.UITestCase):
|
||||
self.app.uri = tests.utils.uri_kvm
|
||||
newvm = self._open_create_wizard()
|
||||
|
||||
uiutils.find_fuzzy(newvm, "Network Install", "radio").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
newvm.find_fuzzy("Network Install", "radio").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
|
||||
uiutils.find_pattern(newvm, None, "text", "URL").text = (
|
||||
newvm.find_pattern(None, "text", "URL").text = (
|
||||
"http://vault.centos.org/5.5/os/x86_64/")
|
||||
|
||||
version = uiutils.find_pattern(newvm, "install-os-version-label")
|
||||
version = newvm.find_pattern("install-os-version-label")
|
||||
uiutils.check_in_loop(lambda: "Detecting" in version.text)
|
||||
uiutils.check_in_loop(
|
||||
lambda: version.text == "Red Hat Enterprise Linux 5.5",
|
||||
timeout=10)
|
||||
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Finish", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Finish", "button").click()
|
||||
|
||||
progress = uiutils.find_fuzzy(self.app.root,
|
||||
progress = self.app.root.find_fuzzy(
|
||||
"Creating Virtual Machine", "frame")
|
||||
uiutils.check_in_loop(lambda: not progress.showing, timeout=120)
|
||||
|
||||
uiutils.find_fuzzy(self.app.root, "rhel5.5 on", "frame")
|
||||
self.app.root.find_fuzzy("rhel5.5 on", "frame")
|
||||
self.assertFalse(newvm.showing)
|
||||
|
||||
|
||||
@ -167,14 +165,14 @@ class NewVM(uiutils.UITestCase):
|
||||
self.app.uri = tests.utils.uri_kvm
|
||||
newvm = self._open_create_wizard()
|
||||
|
||||
uiutils.find_fuzzy(newvm, "Architecture options", "toggle").click()
|
||||
uiutils.find_fuzzy(newvm, None, "combo", "Architecture").click()
|
||||
uiutils.find_fuzzy(newvm, "ppc64", "menu item").click()
|
||||
uiutils.find_fuzzy(newvm, "pseries", "menu item")
|
||||
newvm.find_fuzzy("Architecture options", "toggle").click()
|
||||
newvm.find_fuzzy(None, "combo", "Architecture").click()
|
||||
newvm.find_fuzzy("ppc64", "menu item").click()
|
||||
newvm.find_fuzzy("pseries", "menu item")
|
||||
|
||||
self._do_simple_import(newvm)
|
||||
|
||||
uiutils.find_fuzzy(self.app.root, "generic-ppc64 on", "frame")
|
||||
self.app.root.find_fuzzy("generic-ppc64 on", "frame")
|
||||
self.assertFalse(newvm.showing)
|
||||
|
||||
|
||||
@ -185,44 +183,43 @@ class NewVM(uiutils.UITestCase):
|
||||
self.app.uri = tests.utils.uri_kvm_armv7l
|
||||
newvm = self._open_create_wizard()
|
||||
|
||||
uiutils.find_fuzzy(newvm, "Architecture options", "toggle").click()
|
||||
uiutils.find_fuzzy(newvm, None, "combo", "Virt Type").click()
|
||||
KVM = uiutils.find_fuzzy(newvm, "KVM", "menu item")
|
||||
TCG = uiutils.find_fuzzy(newvm, "TCG", "menu item")
|
||||
newvm.find_fuzzy("Architecture options", "toggle").click()
|
||||
newvm.find_fuzzy(None, "combo", "Virt Type").click()
|
||||
KVM = newvm.find_fuzzy("KVM", "menu item")
|
||||
TCG = newvm.find_fuzzy("TCG", "menu item")
|
||||
self.assertTrue(KVM.focused)
|
||||
self.assertTrue(TCG.showing)
|
||||
uiutils.find_fuzzy(newvm, None, "combo", "Virt Type").click()
|
||||
newvm.find_fuzzy(None, "combo", "Virt Type").click()
|
||||
|
||||
# Validate some initial defaults
|
||||
self.assertFalse(
|
||||
uiutils.find_fuzzy(newvm, "PXE", "radio").sensitive)
|
||||
uiutils.find_fuzzy(newvm, "vexpress-a15", "menu item")
|
||||
uiutils.find_pattern(newvm, "virt", "menu item")
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
newvm.find_fuzzy("PXE", "radio").sensitive)
|
||||
newvm.find_fuzzy("vexpress-a15", "menu item")
|
||||
newvm.find_pattern("virt", "menu item")
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
|
||||
# Set the import media details
|
||||
uiutils.find_fuzzy(newvm, None,
|
||||
newvm.find_fuzzy(None,
|
||||
"text", "existing storage").text = "/dev/default-pool/default-vol"
|
||||
uiutils.find_fuzzy(newvm, None,
|
||||
newvm.find_fuzzy(None,
|
||||
"text", "Kernel path").text = "/tmp/kernel"
|
||||
uiutils.find_fuzzy(newvm, None,
|
||||
newvm.find_fuzzy(None,
|
||||
"text", "Initrd").text = "/tmp/initrd"
|
||||
uiutils.find_fuzzy(newvm, None,
|
||||
newvm.find_fuzzy(None,
|
||||
"text", "DTB").text = "/tmp/dtb"
|
||||
uiutils.find_fuzzy(newvm, None,
|
||||
newvm.find_fuzzy(None,
|
||||
"text", "Kernel args").text = "console=ttyS0"
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
|
||||
# Disk collision box pops up, hit ok
|
||||
alert = uiutils.find_pattern(self.app.root,
|
||||
"vmm simple dialog", "alert")
|
||||
uiutils.find_fuzzy(alert, "Yes", "push button").click()
|
||||
alert = self.app.root.find_pattern("vmm simple dialog", "alert")
|
||||
alert.find_fuzzy("Yes", "push button").click()
|
||||
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Finish", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Finish", "button").click()
|
||||
|
||||
time.sleep(1)
|
||||
uiutils.find_fuzzy(self.app.root, "generic on", "frame")
|
||||
self.app.root.find_fuzzy("generic on", "frame")
|
||||
self.assertFalse(newvm.showing)
|
||||
|
||||
|
||||
@ -233,18 +230,18 @@ class NewVM(uiutils.UITestCase):
|
||||
self.app.uri = tests.utils.uri_lxc
|
||||
|
||||
newvm = self._open_create_wizard()
|
||||
uiutils.find_fuzzy(newvm, "Application", "radio").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
newvm.find_fuzzy("Application", "radio").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
|
||||
# Set custom init
|
||||
uiutils.find_fuzzy(newvm, None,
|
||||
newvm.find_fuzzy(None,
|
||||
"text", "application path").text = "/sbin/init"
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Finish", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Finish", "button").click()
|
||||
|
||||
time.sleep(1)
|
||||
uiutils.find_fuzzy(self.app.root, "container1 on", "frame")
|
||||
self.app.root.find_fuzzy("container1 on", "frame")
|
||||
self.assertFalse(newvm.showing)
|
||||
|
||||
|
||||
@ -255,18 +252,18 @@ class NewVM(uiutils.UITestCase):
|
||||
self.app.uri = tests.utils.uri_lxc
|
||||
|
||||
newvm = self._open_create_wizard()
|
||||
uiutils.find_fuzzy(newvm, "Operating system", "radio").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
newvm.find_fuzzy("Operating system", "radio").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
|
||||
# Set directory path
|
||||
uiutils.find_fuzzy(newvm, None,
|
||||
newvm.find_fuzzy(None,
|
||||
"text", "root directory").text = "/tmp"
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Finish", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Finish", "button").click()
|
||||
|
||||
time.sleep(1)
|
||||
uiutils.find_fuzzy(self.app.root, "container1 on", "frame")
|
||||
self.app.root.find_fuzzy("container1 on", "frame")
|
||||
self.assertFalse(newvm.showing)
|
||||
|
||||
|
||||
@ -277,17 +274,17 @@ class NewVM(uiutils.UITestCase):
|
||||
self.app.uri = tests.utils.uri_vz
|
||||
|
||||
newvm = self._open_create_wizard()
|
||||
uiutils.find_fuzzy(newvm, "Container", "radio").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
newvm.find_fuzzy("Container", "radio").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
|
||||
# Set directory path
|
||||
uiutils.find_fuzzy(newvm, None,
|
||||
newvm.find_fuzzy(None,
|
||||
"text", "container template").text = "centos-6-x86_64"
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||
uiutils.find_fuzzy(newvm, "Finish", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Forward", "button").click()
|
||||
newvm.find_fuzzy("Finish", "button").click()
|
||||
|
||||
uiutils.find_fuzzy(self.app.root, "container1 on", "frame")
|
||||
self.app.root.find_fuzzy("container1 on", "frame")
|
||||
self.assertFalse(newvm.showing)
|
||||
|
||||
|
||||
@ -298,8 +295,8 @@ class NewVM(uiutils.UITestCase):
|
||||
self.app.uri = tests.utils.uri_xen
|
||||
newvm = self._open_create_wizard()
|
||||
|
||||
uiutils.find_fuzzy(newvm, "Architecture options", "toggle").click()
|
||||
uiutils.find_fuzzy(newvm, None, "combo", "Xen Type").click()
|
||||
uiutils.find_fuzzy(newvm, "paravirt", "menu item").click()
|
||||
newvm.find_fuzzy("Architecture options", "toggle").click()
|
||||
newvm.find_fuzzy(None, "combo", "Xen Type").click()
|
||||
newvm.find_fuzzy("paravirt", "menu item").click()
|
||||
|
||||
self._do_simple_import(newvm)
|
||||
|
@ -25,40 +25,39 @@ class VMMPrefs(uiutils.UITestCase):
|
||||
##############
|
||||
|
||||
def testPrefs(self):
|
||||
uiutils.find_pattern(self.app.root, "Edit", "menu").click()
|
||||
uiutils.find_pattern(self.app.root, "Preferences", "menu item").click()
|
||||
self.app.root.find_pattern("Edit", "menu").click()
|
||||
self.app.root.find_pattern("Preferences", "menu item").click()
|
||||
|
||||
win = uiutils.find_fuzzy(self.app.root, "Preferences", "frame")
|
||||
win = self.app.root.find_fuzzy("Preferences", "frame")
|
||||
|
||||
uiutils.find_fuzzy(win, "Enable system tray", "check").click()
|
||||
win.find_fuzzy("Enable system tray", "check").click()
|
||||
|
||||
uiutils.find_pattern(win, "Polling", "page tab").click()
|
||||
uiutils.find_fuzzy(win, None, "check box",
|
||||
win.find_pattern("Polling", "page tab").click()
|
||||
win.find_fuzzy(None, "check box",
|
||||
labeller_text="Poll CPU").click()
|
||||
|
||||
uiutils.find_pattern(win, "New VM", "page tab").click()
|
||||
uiutils.find_pattern(win, "prefs-add-spice-usbredir",
|
||||
win.find_pattern("New VM", "page tab").click()
|
||||
win.find_pattern("prefs-add-spice-usbredir",
|
||||
"combo box").click()
|
||||
uiutils.find_pattern(win, "No", "menu item").click()
|
||||
win.find_pattern("No", "menu item").click()
|
||||
|
||||
uiutils.find_pattern(win, "Console", "page tab").click()
|
||||
uiutils.find_pattern(win, "Change...", "push button").click()
|
||||
keyframe = uiutils.find_fuzzy(self.app.root,
|
||||
"Configure grab", "dialog")
|
||||
win.find_pattern("Console", "page tab").click()
|
||||
win.find_pattern("Change...", "push button").click()
|
||||
keyframe = self.app.root.find_fuzzy("Configure grab", "dialog")
|
||||
_holdKey("Alt_L")
|
||||
_holdKey("Z")
|
||||
try:
|
||||
uiutils.find_fuzzy(keyframe, "OK", "push button").click()
|
||||
keyframe.find_fuzzy("OK", "push button").click()
|
||||
finally:
|
||||
_releaseKey("Z")
|
||||
_releaseKey("Alt_L")
|
||||
|
||||
uiutils.find_pattern(win, "Feedback", "page tab").click()
|
||||
uiutils.find_fuzzy(win, None, "check box",
|
||||
win.find_pattern("Feedback", "page tab").click()
|
||||
win.find_fuzzy(None, "check box",
|
||||
labeller_text="Force Poweroff").click()
|
||||
|
||||
uiutils.find_pattern(win, "General", "page tab").click()
|
||||
uiutils.find_fuzzy(win, "Enable system tray", "check").click()
|
||||
win.find_pattern("General", "page tab").click()
|
||||
win.find_fuzzy("Enable system tray", "check").click()
|
||||
|
||||
uiutils.find_fuzzy(win, "Close", "push button").click()
|
||||
win.find_fuzzy("Close", "push button").click()
|
||||
uiutils.check_in_loop(lambda: win.visible is False)
|
||||
|
@ -25,28 +25,6 @@ class UITestCase(unittest.TestCase):
|
||||
self.app.stop()
|
||||
|
||||
|
||||
class VMMDogtailNode(dogtail.tree.Node):
|
||||
"""
|
||||
Our extensions to the dogtail node wrapper class.
|
||||
"""
|
||||
# The class hackery means pylint can't figure this class out
|
||||
# pylint: disable=no-member
|
||||
|
||||
@property
|
||||
def active(self):
|
||||
"""
|
||||
If the window is the raised and active window or not
|
||||
"""
|
||||
return self.getState().contains(pyatspi.STATE_ACTIVE)
|
||||
|
||||
|
||||
# This is the same hack dogtail uses to extend the Accessible class.
|
||||
_bases = list(pyatspi.Accessibility.Accessible.__bases__)
|
||||
_bases.insert(_bases.index(dogtail.tree.Node), VMMDogtailNode)
|
||||
_bases.remove(dogtail.tree.Node)
|
||||
pyatspi.Accessibility.Accessible.__bases__ = tuple(_bases)
|
||||
|
||||
|
||||
class _FuzzyPredicate(dogtail.predicate.Predicate):
|
||||
"""
|
||||
Object dogtail/pyatspi want for node searching.
|
||||
@ -86,6 +64,123 @@ class _FuzzyPredicate(dogtail.predicate.Predicate):
|
||||
print("got predicate exception: %s" % e)
|
||||
|
||||
|
||||
def check_in_loop(func, timeout=2):
|
||||
"""
|
||||
Run the passed func in a loop every .1 seconds until timeout is hit or
|
||||
the func returns True.
|
||||
"""
|
||||
start_time = time.time()
|
||||
interval = 0.1
|
||||
while True:
|
||||
if func() is True:
|
||||
return
|
||||
if (time.time() - start_time) > timeout:
|
||||
raise RuntimeError("Loop condition wasn't met")
|
||||
time.sleep(interval)
|
||||
|
||||
|
||||
class VMMDogtailNode(dogtail.tree.Node):
|
||||
"""
|
||||
Our extensions to the dogtail node wrapper class.
|
||||
"""
|
||||
# The class hackery means pylint can't figure this class out
|
||||
# pylint: disable=no-member
|
||||
|
||||
@property
|
||||
def active(self):
|
||||
"""
|
||||
If the window is the raised and active window or not
|
||||
"""
|
||||
return self.getState().contains(pyatspi.STATE_ACTIVE)
|
||||
|
||||
|
||||
#########################
|
||||
# Widget search helpers #
|
||||
#########################
|
||||
|
||||
def find_pattern(self, name, roleName=None, labeller_text=None):
|
||||
"""
|
||||
Search root for any widget that contains the passed name/role regex
|
||||
strings.
|
||||
"""
|
||||
pred = _FuzzyPredicate(name, roleName, labeller_text)
|
||||
|
||||
try:
|
||||
ret = self.findChild(pred)
|
||||
except dogtail.tree.SearchError:
|
||||
raise dogtail.tree.SearchError("Didn't find widget with name='%s' "
|
||||
"roleName='%s' labeller_text='%s'" %
|
||||
(name, roleName, labeller_text))
|
||||
|
||||
# Wait for independent windows to become active in the window manager
|
||||
# before we return them. This ensures the window is actually onscreen
|
||||
# so it sidesteps a lot of race conditions
|
||||
if ret.roleName in ["frame", "dialog", "alert"]:
|
||||
check_in_loop(lambda: ret.active)
|
||||
return ret
|
||||
|
||||
def find_fuzzy(self, name, roleName=None, labeller_text=None):
|
||||
"""
|
||||
Search root for any widget that contains the passed name/role strings.
|
||||
"""
|
||||
name_pattern = None
|
||||
role_pattern = None
|
||||
labeller_pattern = None
|
||||
if name:
|
||||
name_pattern = ".*%s.*" % name
|
||||
if roleName:
|
||||
role_pattern = ".*%s.*" % roleName
|
||||
if labeller_text:
|
||||
labeller_pattern = ".*%s.*" % labeller_text
|
||||
|
||||
return self.find_pattern(name_pattern, role_pattern, labeller_pattern)
|
||||
|
||||
|
||||
#####################
|
||||
# Debugging helpers #
|
||||
#####################
|
||||
|
||||
def node_string(self):
|
||||
msg = "name='%s' roleName='%s'" % (self.name, self.roleName)
|
||||
if self.labeller:
|
||||
msg += " labeller.text='%s'" % self.labeller.text
|
||||
return msg
|
||||
|
||||
|
||||
def print_nodes(root):
|
||||
"""
|
||||
Helper to print the entire node tree for the passed root. Useful
|
||||
if to figure out the roleName for the object you are looking for
|
||||
"""
|
||||
def _walk(node):
|
||||
try:
|
||||
print(node.node_string())
|
||||
except Exception as e:
|
||||
print("got exception: %s" % e)
|
||||
|
||||
self.findChildren(_walk, isLambda=True)
|
||||
|
||||
def focused_nodes(self):
|
||||
"""
|
||||
Return a list of all focused nodes. Useful for debugging
|
||||
"""
|
||||
def _walk(node):
|
||||
try:
|
||||
if node.focused:
|
||||
return node
|
||||
except Exception as e:
|
||||
print("got exception: %s" % e)
|
||||
|
||||
return self.findChildren(_walk, isLambda=True)
|
||||
|
||||
|
||||
# This is the same hack dogtail uses to extend the Accessible class.
|
||||
_bases = list(pyatspi.Accessibility.Accessible.__bases__)
|
||||
_bases.insert(_bases.index(dogtail.tree.Node), VMMDogtailNode)
|
||||
_bases.remove(dogtail.tree.Node)
|
||||
pyatspi.Accessibility.Accessible.__bases__ = tuple(_bases)
|
||||
|
||||
|
||||
class VMMDogtailApp(object):
|
||||
"""
|
||||
Wrapper class to simplify dogtail app handling
|
||||
@ -132,7 +227,7 @@ class VMMDogtailApp(object):
|
||||
|
||||
self._proc = subprocess.Popen(cmd, stdout=stdout, stderr=stderr)
|
||||
self._root = dogtail.tree.root.application("virt-manager")
|
||||
self._topwin = find_pattern(self._root, None, "(frame|dialog|alert)")
|
||||
self._topwin = self._root.find_pattern(None, "(frame|dialog|alert)")
|
||||
|
||||
def stop(self):
|
||||
"""
|
||||
@ -158,101 +253,3 @@ class VMMDogtailApp(object):
|
||||
self._proc.kill()
|
||||
finally:
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
#########################
|
||||
# Widget search helpers #
|
||||
#########################
|
||||
|
||||
def find_pattern(root, name, roleName=None, labeller_text=None):
|
||||
"""
|
||||
Search root for any widget that contains the passed name/role regex
|
||||
strings.
|
||||
"""
|
||||
pred = _FuzzyPredicate(name, roleName, labeller_text)
|
||||
|
||||
try:
|
||||
ret = root.findChild(pred)
|
||||
except dogtail.tree.SearchError:
|
||||
raise dogtail.tree.SearchError("Didn't find widget with name='%s' "
|
||||
"roleName='%s' labeller_text='%s'" %
|
||||
(name, roleName, labeller_text))
|
||||
|
||||
# Wait for independent windows to become active in the window manager
|
||||
# before we return them. This ensures the window is actually onscreen
|
||||
# so it sidesteps a lot of race conditions
|
||||
if ret.roleName in ["frame", "dialog", "alert"]:
|
||||
check_in_loop(lambda: ret.active)
|
||||
return ret
|
||||
|
||||
|
||||
def find_fuzzy(root, name, roleName=None, labeller_text=None):
|
||||
"""
|
||||
Search root for any widget that contains the passed name/role strings.
|
||||
"""
|
||||
name_pattern = None
|
||||
role_pattern = None
|
||||
labeller_pattern = None
|
||||
if name:
|
||||
name_pattern = ".*%s.*" % name
|
||||
if roleName:
|
||||
role_pattern = ".*%s.*" % roleName
|
||||
if labeller_text:
|
||||
labeller_pattern = ".*%s.*" % labeller_text
|
||||
|
||||
return find_pattern(root, name_pattern, role_pattern,
|
||||
labeller_pattern)
|
||||
|
||||
|
||||
def check_in_loop(func, timeout=2):
|
||||
"""
|
||||
Run the passed func in a loop every .1 seconds until timeout is hit or
|
||||
the func returns True.
|
||||
"""
|
||||
start_time = time.time()
|
||||
interval = 0.1
|
||||
while True:
|
||||
if func() is True:
|
||||
return
|
||||
if (time.time() - start_time) > timeout:
|
||||
raise RuntimeError("Loop condition wasn't met")
|
||||
time.sleep(interval)
|
||||
|
||||
|
||||
#####################
|
||||
# Debugging helpers #
|
||||
#####################
|
||||
|
||||
def node_string(node):
|
||||
msg = "name='%s' roleName='%s'" % (node.name, node.roleName)
|
||||
if node.labeller:
|
||||
msg += " labeller.text='%s'" % node.labeller.text
|
||||
return msg
|
||||
|
||||
|
||||
def print_nodes(root):
|
||||
"""
|
||||
Helper to print the entire node tree for the passed root. Useful
|
||||
if to figure out the roleName for the object you are looking for
|
||||
"""
|
||||
def _walk(node):
|
||||
try:
|
||||
print(node_string(node))
|
||||
except Exception as e:
|
||||
print("got exception: %s" % e)
|
||||
|
||||
root.findChildren(_walk, isLambda=True)
|
||||
|
||||
|
||||
def focused_nodes(root):
|
||||
"""
|
||||
Return a list of all focused nodes. Useful for debugging
|
||||
"""
|
||||
def _walk(node):
|
||||
try:
|
||||
if node.focused:
|
||||
return node
|
||||
except Exception as e:
|
||||
print("got exception: %s" % e)
|
||||
|
||||
return root.findChildren(_walk, isLambda=True)
|
||||
|
Loading…
Reference in New Issue
Block a user