mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
uitests: Drop sleeps from newvm tests
Adds a few new uiutils options to facilitate watching for the expected result, rather than depending on hardcoded sleeps
This commit is contained in:
parent
4fbffc4086
commit
0c615497b1
@ -13,8 +13,9 @@ class CloneVM(uiutils.UITestCase):
|
|||||||
|
|
||||||
def _open_window(self, vmname):
|
def _open_window(self, vmname):
|
||||||
# Launch wizard via right click menu
|
# Launch wizard via right click menu
|
||||||
uiutils.find_fuzzy(
|
c = uiutils.find_fuzzy(self.app.root, vmname, "table cell",
|
||||||
self.app.root, vmname, "table cell").click(button=3)
|
wait_for_focus=True)
|
||||||
|
c.click(button=3)
|
||||||
uiutils.find_pattern(self.app.root, "Clone...", "menu item").click()
|
uiutils.find_pattern(self.app.root, "Clone...", "menu item").click()
|
||||||
return uiutils.find_pattern(
|
return uiutils.find_pattern(
|
||||||
self.app.root, "Clone Virtual Machine", "frame")
|
self.app.root, "Clone Virtual Machine", "frame")
|
||||||
|
@ -16,8 +16,9 @@ class Details(uiutils.UITestCase):
|
|||||||
###################
|
###################
|
||||||
|
|
||||||
def _open_details_window(self, vmname="test-many-devices"):
|
def _open_details_window(self, vmname="test-many-devices"):
|
||||||
uiutils.find_fuzzy(
|
c = uiutils.find_fuzzy(self.app.root, vmname, "table cell",
|
||||||
self.app.root, vmname, "table cell").doubleClick()
|
wait_for_focus=True)
|
||||||
|
c.doubleClick()
|
||||||
win = uiutils.find_pattern(self.app.root, "%s on" % vmname, "frame")
|
win = uiutils.find_pattern(self.app.root, "%s on" % vmname, "frame")
|
||||||
uiutils.find_pattern(win, "Details", "radio button").click()
|
uiutils.find_pattern(win, "Details", "radio button").click()
|
||||||
return win
|
return win
|
||||||
@ -111,8 +112,11 @@ class Details(uiutils.UITestCase):
|
|||||||
"""
|
"""
|
||||||
origname = "test-many-devices"
|
origname = "test-many-devices"
|
||||||
# Shutdown the VM
|
# Shutdown the VM
|
||||||
uiutils.find_fuzzy(self.app.root, origname, "table cell").click()
|
uiutils.find_fuzzy(self.app.root, origname, "table cell",
|
||||||
uiutils.find_pattern(self.app.root, "Shut Down", "push button").click()
|
wait_for_focus=True).click()
|
||||||
|
b = uiutils.find_pattern(self.app.root, "Shut Down", "push button",
|
||||||
|
wait_for_focus=True)
|
||||||
|
b.click()
|
||||||
|
uiutils.check_in_loop(lambda: b.sensitive is False)
|
||||||
|
|
||||||
time.sleep(.5)
|
|
||||||
self._testRename(origname, "test-new-name")
|
self._testRename(origname, "test-new-name")
|
||||||
|
@ -16,7 +16,9 @@ class NewVM(uiutils.UITestCase):
|
|||||||
###################
|
###################
|
||||||
|
|
||||||
def _open_create_wizard(self):
|
def _open_create_wizard(self):
|
||||||
uiutils.find_pattern(self.app.root, "New", "push button").click()
|
b = uiutils.find_pattern(self.app.root, "New", "push button",
|
||||||
|
wait_for_focus=True)
|
||||||
|
b.click()
|
||||||
return uiutils.find_pattern(self.app.root, "New VM", "frame")
|
return uiutils.find_pattern(self.app.root, "New VM", "frame")
|
||||||
|
|
||||||
def _do_simple_import(self, newvm):
|
def _do_simple_import(self, newvm):
|
||||||
@ -28,7 +30,6 @@ class NewVM(uiutils.UITestCase):
|
|||||||
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()
|
uiutils.find_fuzzy(newvm, "Finish", "button").click()
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
|
|
||||||
##############
|
##############
|
||||||
@ -59,10 +60,9 @@ class NewVM(uiutils.UITestCase):
|
|||||||
uiutils.find_fuzzy(delete, "Delete", "button").click()
|
uiutils.find_fuzzy(delete, "Delete", "button").click()
|
||||||
alert = uiutils.find_pattern(self.app.root, "Warning", "alert")
|
alert = uiutils.find_pattern(self.app.root, "Warning", "alert")
|
||||||
uiutils.find_fuzzy(alert, "Yes", "push button").click()
|
uiutils.find_fuzzy(alert, "Yes", "push button").click()
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
# Verify delete dialog and VM dialog are now gone
|
# Verify delete dialog and VM dialog are now gone
|
||||||
self.assertFalse(vmwindow.showing)
|
uiutils.check_in_loop(lambda: vmwindow.showing is False)
|
||||||
|
|
||||||
|
|
||||||
def testNewVMCDROM(self):
|
def testNewVMCDROM(self):
|
||||||
@ -82,12 +82,10 @@ class NewVM(uiutils.UITestCase):
|
|||||||
uiutils.find_fuzzy(browser, "default-pool", "table cell").click()
|
uiutils.find_fuzzy(browser, "default-pool", "table cell").click()
|
||||||
uiutils.find_fuzzy(browser, "iso-vol", "table cell").click()
|
uiutils.find_fuzzy(browser, "iso-vol", "table cell").click()
|
||||||
uiutils.find_fuzzy(browser, "Choose Volume", "button").click()
|
uiutils.find_fuzzy(browser, "Choose Volume", "button").click()
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
self.assertFalse(browser.showing)
|
label = uiutils.find_fuzzy(newvm, "os-version-label", "label")
|
||||||
self.assertEqual(
|
uiutils.check_in_loop(lambda: browser.showing is False)
|
||||||
uiutils.find_fuzzy(newvm, "os-version-label", "label").text,
|
uiutils.check_in_loop(lambda: label.text == "Unknown")
|
||||||
"Unknown")
|
|
||||||
|
|
||||||
# Change distro to win8
|
# Change distro to win8
|
||||||
uiutils.find_fuzzy(newvm, "Automatically detect", "check").click()
|
uiutils.find_fuzzy(newvm, "Automatically detect", "check").click()
|
||||||
@ -123,12 +121,11 @@ class NewVM(uiutils.UITestCase):
|
|||||||
|
|
||||||
# Start the install, close via the VM window
|
# Start the install, close via the VM window
|
||||||
uiutils.find_fuzzy(vmwindow, "Begin Installation", "button").click()
|
uiutils.find_fuzzy(vmwindow, "Begin Installation", "button").click()
|
||||||
time.sleep(1)
|
uiutils.check_in_loop(lambda: newvm.showing is False)
|
||||||
vmwindow = uiutils.find_fuzzy(self.app.root, "win8 on", "frame")
|
vmwindow = uiutils.find_fuzzy(self.app.root, "win8 on", "frame")
|
||||||
self.assertFalse(newvm.showing)
|
|
||||||
uiutils.find_fuzzy(vmwindow, "File", "menu").click()
|
uiutils.find_fuzzy(vmwindow, "File", "menu").click()
|
||||||
uiutils.find_fuzzy(vmwindow, "Quit", "menu item").click()
|
uiutils.find_fuzzy(vmwindow, "Quit", "menu item").click()
|
||||||
time.sleep(.5)
|
uiutils.check_in_loop(lambda: self.app.is_running())
|
||||||
|
|
||||||
|
|
||||||
def testNewVMURL(self):
|
def testNewVMURL(self):
|
||||||
@ -146,20 +143,19 @@ class NewVM(uiutils.UITestCase):
|
|||||||
"http://vault.centos.org/5.5/os/x86_64/")
|
"http://vault.centos.org/5.5/os/x86_64/")
|
||||||
|
|
||||||
version = uiutils.find_pattern(newvm, "install-os-version-label")
|
version = uiutils.find_pattern(newvm, "install-os-version-label")
|
||||||
time.sleep(1)
|
uiutils.check_in_loop(lambda: "Detecting" in version.text)
|
||||||
uiutils.check_in_loop(lambda: "Detecting" not in version.text)
|
uiutils.check_in_loop(
|
||||||
self.assertEqual(version.text, "Red Hat Enterprise Linux 5.5")
|
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, "Forward", "button").click()
|
||||||
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
uiutils.find_fuzzy(newvm, "Forward", "button").click()
|
||||||
uiutils.find_fuzzy(newvm, "Finish", "button").click()
|
uiutils.find_fuzzy(newvm, "Finish", "button").click()
|
||||||
time.sleep(.5)
|
|
||||||
|
|
||||||
progress = uiutils.find_fuzzy(self.app.root,
|
progress = uiutils.find_fuzzy(self.app.root,
|
||||||
"Creating Virtual Machine", "frame")
|
"Creating Virtual Machine", "frame")
|
||||||
uiutils.check_in_loop(lambda: not progress.showing)
|
uiutils.check_in_loop(lambda: not progress.showing, timeout=120)
|
||||||
time.sleep(.5)
|
|
||||||
|
|
||||||
uiutils.find_fuzzy(self.app.root, "rhel5.5 on", "frame")
|
uiutils.find_fuzzy(self.app.root, "rhel5.5 on", "frame")
|
||||||
self.assertFalse(newvm.showing)
|
self.assertFalse(newvm.showing)
|
||||||
@ -179,7 +175,6 @@ class NewVM(uiutils.UITestCase):
|
|||||||
|
|
||||||
self._do_simple_import(newvm)
|
self._do_simple_import(newvm)
|
||||||
|
|
||||||
time.sleep(1)
|
|
||||||
uiutils.find_fuzzy(self.app.root, "generic-ppc64 on", "frame")
|
uiutils.find_fuzzy(self.app.root, "generic-ppc64 on", "frame")
|
||||||
self.assertFalse(newvm.showing)
|
self.assertFalse(newvm.showing)
|
||||||
|
|
||||||
|
@ -76,6 +76,9 @@ class DogtailApp(object):
|
|||||||
self.open()
|
self.open()
|
||||||
return self._root
|
return self._root
|
||||||
|
|
||||||
|
def is_running(self):
|
||||||
|
return bool(self._proc and self._proc.poll() is None)
|
||||||
|
|
||||||
def open(self, extra_opts=None):
|
def open(self, extra_opts=None):
|
||||||
extra_opts = extra_opts or []
|
extra_opts = extra_opts or []
|
||||||
|
|
||||||
@ -125,7 +128,8 @@ class DogtailApp(object):
|
|||||||
# Widget search helpers #
|
# Widget search helpers #
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
def find_pattern(root, name, roleName=None, labeller_text=None, retry=True):
|
def find_pattern(root, name, roleName=None, labeller_text=None, retry=True,
|
||||||
|
wait_for_focus=False):
|
||||||
"""
|
"""
|
||||||
Search root for any widget that contains the passed name/role regex
|
Search root for any widget that contains the passed name/role regex
|
||||||
strings.
|
strings.
|
||||||
@ -133,14 +137,20 @@ def find_pattern(root, name, roleName=None, labeller_text=None, retry=True):
|
|||||||
pred = _FuzzyPredicate(name, roleName, labeller_text)
|
pred = _FuzzyPredicate(name, roleName, labeller_text)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return root.findChild(pred, retry=retry)
|
ret = root.findChild(pred, retry=retry)
|
||||||
except dogtail.tree.SearchError:
|
except dogtail.tree.SearchError:
|
||||||
raise dogtail.tree.SearchError("Didn't find widget with name='%s' "
|
raise dogtail.tree.SearchError("Didn't find widget with name='%s' "
|
||||||
"roleName='%s' labeller_text='%s'" %
|
"roleName='%s' labeller_text='%s'" %
|
||||||
(name, roleName, labeller_text))
|
(name, roleName, labeller_text))
|
||||||
|
|
||||||
|
if wait_for_focus:
|
||||||
|
ret.grabFocus()
|
||||||
|
check_in_loop(lambda: ret.focused)
|
||||||
|
return ret
|
||||||
|
|
||||||
def find_fuzzy(root, name, roleName=None, labeller_text=None, retry=True):
|
|
||||||
|
def find_fuzzy(root, name, roleName=None, labeller_text=None, retry=True,
|
||||||
|
wait_for_focus=False):
|
||||||
"""
|
"""
|
||||||
Search root for any widget that contains the passed name/role strings.
|
Search root for any widget that contains the passed name/role strings.
|
||||||
"""
|
"""
|
||||||
@ -155,23 +165,22 @@ def find_fuzzy(root, name, roleName=None, labeller_text=None, retry=True):
|
|||||||
labeller_pattern = ".*%s.*" % labeller_text
|
labeller_pattern = ".*%s.*" % labeller_text
|
||||||
|
|
||||||
return find_pattern(root, name_pattern, role_pattern,
|
return find_pattern(root, name_pattern, role_pattern,
|
||||||
labeller_pattern, retry=retry)
|
labeller_pattern, retry=retry, wait_for_focus=wait_for_focus)
|
||||||
|
|
||||||
|
|
||||||
def check_in_loop(func, timeout=-1):
|
def check_in_loop(func, timeout=1):
|
||||||
"""
|
"""
|
||||||
Run the passed func in a loop every .5 seconds until timeout is hit or
|
Run the passed func in a loop every .1 seconds until timeout is hit or
|
||||||
the func returns True.
|
the func returns True.
|
||||||
If timeout=-1, check indefinitely.
|
|
||||||
"""
|
"""
|
||||||
total_time = 0.0
|
start_time = time.time()
|
||||||
|
interval = 0.1
|
||||||
while True:
|
while True:
|
||||||
time.sleep(.5)
|
|
||||||
total_time += .5
|
|
||||||
if func() is True:
|
if func() is True:
|
||||||
return
|
return
|
||||||
if timeout > 0 and total_time >= timeout:
|
if (time.time() - start_time) > timeout:
|
||||||
raise RuntimeError("Loop condition wasn't met")
|
raise RuntimeError("Loop condition wasn't met")
|
||||||
|
time.sleep(interval)
|
||||||
|
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
|
Loading…
Reference in New Issue
Block a user