virt-manager/tests/uitests/details.py

123 lines
4.1 KiB
Python
Raw Normal View History

import time
import dogtail.rawinput
import pyatspi
2016-04-18 23:42:12 +03:00
from tests.uitests import utils as uiutils
2018-01-09 18:01:56 +03:00
class Details(uiutils.UITestCase):
"""
UI tests for virt-manager's VM details window
"""
###################
# Private helpers #
###################
def _open_details_window(self, vmname="test-many-devices"):
c = uiutils.find_fuzzy(self.app.root, vmname, "table cell",
wait_for_focus=True)
c.doubleClick()
win = uiutils.find_pattern(self.app.root, "%s on" % vmname, "frame")
uiutils.find_pattern(win, "Details", "radio button").click()
return win
##############
# Test cases #
##############
def testDetailsHardwareSmokeTest(self):
"""
Open the VM with all the crazy hardware and just verify that each
HW panel shows itself without raising any error.
"""
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()
# After we hit this number of down presses, start checking for
# widget focus to determine if we hit the end of the list. We
# don't check for widget focus unconditionally because it's slow.
# The seemingly arbitrary number here is because it matches the
# number of devices in test-many-devices at the time of this writing.
check_after = 88
focused = None
old_focused = None
count = 0
while True:
count += 1
dogtail.rawinput.pressKey("Down")
if not win.getState().contains(pyatspi.STATE_ACTIVE):
# Should mean an error dialog popped up
uiutils.find_pattern(self.app.root, "Error", "alert")
raise AssertionError(
"One of the hardware pages raised an error")
if count < check_after:
time.sleep(.1)
continue
2016-04-18 23:42:12 +03:00
# pylint: disable=not-an-iterable
old_focused = focused
focused = uiutils.focused_nodes(win)
if old_focused is None:
continue
overlap = [w for w in old_focused if w in focused]
if len(overlap) == len(old_focused):
# Focus didn't change, meaning we hit the end of the HW list,
# so our testing is done
break
return
2017-03-08 21:08:22 +03:00
def _testRename(self, origname, newname):
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()
uiutils.find_pattern(win, None, "text", "Name:").text = newname
uiutils.find_pattern(win, "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")
# Ensure old VM entry is gone
try:
uiutils.find_fuzzy(self.app.root, origname, "table cell",
retry=False)
raise AssertionError("Still found manager row for %s" % origname)
except dogtail.tree.SearchError:
# We want this
pass
def testDetailsRenameSimple(self):
"""
Rename a simple VM
"""
self._testRename("test-clone-simple", "test-new-name")
def testDetailsRenameNVRAM(self):
"""
Rename a VM that will trigger the nvram behavior
"""
origname = "test-many-devices"
# Shutdown the VM
uiutils.find_fuzzy(self.app.root, origname, "table cell",
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)
2017-03-08 21:08:22 +03:00
self._testRename(origname, "test-new-name")