uitests: Add snapshot tests
This commit is contained in:
parent
2f12823cb5
commit
be03382e25
|
@ -0,0 +1,92 @@
|
|||
from tests.uitests import utils as uiutils
|
||||
|
||||
|
||||
class Snapshots(uiutils.UITestCase):
|
||||
"""
|
||||
UI tests for virt-manager's VM snapshots
|
||||
"""
|
||||
|
||||
###################
|
||||
# Private helpers #
|
||||
###################
|
||||
|
||||
def _open_snapshots_window(self, vmname="test-snapshots"):
|
||||
self.app.root.find_fuzzy(vmname, "table cell").click(button=3)
|
||||
self.app.root.find_pattern("Open", "menu item").click()
|
||||
|
||||
win = self.app.root.find_pattern("%s on" % vmname, "frame")
|
||||
win.find_pattern("Snapshots", "radio button").click()
|
||||
return win
|
||||
|
||||
|
||||
##############
|
||||
# Test cases #
|
||||
##############
|
||||
|
||||
def testSnapshotsSmokeTest(self):
|
||||
"""
|
||||
Smoke test to ensure all snapshots show correctly
|
||||
"""
|
||||
win = self._open_snapshots_window()
|
||||
errlabel = win.find_pattern("snapshot-error-label", "label")
|
||||
lst = win.find_pattern("snapshot-list", "table")
|
||||
self._walkUIList(win, lst, lambda: errlabel.showing)
|
||||
|
||||
def testSnapshotLifecycle(self):
|
||||
"""
|
||||
Create/delete/start/stop snapshots
|
||||
"""
|
||||
win = self._open_snapshots_window()
|
||||
vmrun = win.find_pattern("Run", "push button")
|
||||
vmpause = win.find_pattern("Pause", "toggle button")
|
||||
snaprun = win.find_pattern("snapshot-start", "push button")
|
||||
|
||||
# Start offline snapshot
|
||||
snapname = "offline-root"
|
||||
win.find_pattern(snapname, "table cell").click()
|
||||
snaprun.click()
|
||||
alert = self.app.root.find_fuzzy("vmm dialog", "alert")
|
||||
alert.find_fuzzy(
|
||||
"sure you want to run snapshot '%s'" % snapname, "label")
|
||||
alert.find_pattern("Yes", "push button").click()
|
||||
uiutils.check_in_loop(lambda: vmrun.sensitive)
|
||||
|
||||
# Start paused snapshot
|
||||
snapname = "snap-paused"
|
||||
win.find_pattern(snapname, "table cell").click()
|
||||
snaprun.click()
|
||||
alert = self.app.root.find_fuzzy("vmm dialog", "alert")
|
||||
alert.find_fuzzy(
|
||||
"sure you want to run snapshot '%s'" % snapname, "label")
|
||||
alert.find_pattern("Yes", "push button").click()
|
||||
uiutils.check_in_loop(lambda: vmpause.checked)
|
||||
|
||||
# Edit snapshot
|
||||
desc = win.find_pattern(None, "text", "Description:")
|
||||
desc.text = "Test description foofoo"
|
||||
win.find_pattern("snapshot-apply", "push button").click()
|
||||
win.find_pattern("snapshot-refresh", "push button").click()
|
||||
self.assertTrue("foofoo" in desc.text)
|
||||
|
||||
# Create new snapshot
|
||||
win.find_pattern("snapshot-add", "push button").click()
|
||||
newwin = self.app.root.find_pattern("Create snapshot", "frame")
|
||||
newwin.print_nodes()
|
||||
snapname = "testnewsnap"
|
||||
newwin.find_pattern(None, "text", "Name:").text = snapname
|
||||
newwin.find_pattern(None, "text", "Description:").text = "testdesc"
|
||||
newwin.find_pattern("Finish", "push button").click()
|
||||
uiutils.check_in_loop(lambda: not newwin.showing)
|
||||
newc = win.find_pattern(snapname, "table cell")
|
||||
uiutils.check_in_loop(lambda: newc.state_selected)
|
||||
|
||||
# Delete it
|
||||
win.find_pattern("snapshot-delete", "push button").click()
|
||||
alert = self.app.root.find_fuzzy("vmm dialog", "alert")
|
||||
alert.find_fuzzy("permanently delete", "label")
|
||||
alert.find_pattern("Yes", "push button").click()
|
||||
uiutils.check_in_loop(lambda: newc.dead)
|
||||
|
||||
# Switch out of window
|
||||
win.find_pattern("Details", "radio button").click()
|
||||
uiutils.check_in_loop(lambda: not snaprun.showing)
|
|
@ -53,6 +53,13 @@ class UITestCase(unittest.TestCase):
|
|||
idx = 0
|
||||
while idx < len(all_cells):
|
||||
cell = all_cells[idx]
|
||||
if not cell.state_selected:
|
||||
# Could be a separator table cell. Try to figure it out
|
||||
if not any([c.name for c in
|
||||
all_cells[idx:(idx + cells_per_selection)]]):
|
||||
idx += cells_per_selection
|
||||
continue
|
||||
|
||||
self.assertTrue(cell.state_selected)
|
||||
dogtail.rawinput.pressKey("Down")
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.20.0 -->
|
||||
<!-- Generated with glade 3.20.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.14"/>
|
||||
<object class="GtkImage" id="image3">
|
||||
|
@ -284,6 +284,9 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkWindow" id="snapshot-top-window">
|
||||
<property name="width_request">600</property>
|
||||
|
@ -322,6 +325,11 @@
|
|||
<signal name="changed" handler="on_snapshot_list_changed" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="snapshot-list-atkobject">
|
||||
<property name="AtkObject::accessible-name">snapshot-list</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -606,6 +614,11 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label">error label</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="snapshot-error-label-atkobject">
|
||||
<property name="AtkObject::accessible-name">snapshot-error-label</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
|
@ -662,6 +675,11 @@
|
|||
<property name="stock">gtk-add</property>
|
||||
</object>
|
||||
</child>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="snapshot-add-atkobject">
|
||||
<property name="AtkObject::accessible-name">snapshot-add</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -683,6 +701,11 @@
|
|||
<property name="stock">gtk-media-play</property>
|
||||
</object>
|
||||
</child>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="snapshot-start-atkobject">
|
||||
<property name="AtkObject::accessible-name">snapshot-start</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -704,6 +727,11 @@
|
|||
<property name="stock">gtk-refresh</property>
|
||||
</object>
|
||||
</child>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="snapshot-refresh-atkobject">
|
||||
<property name="AtkObject::accessible-name">snapshot-refresh</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -727,6 +755,11 @@
|
|||
<property name="stock">gtk-delete</property>
|
||||
</object>
|
||||
</child>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="snapshot-delete-atkobject">
|
||||
<property name="AtkObject::accessible-name">snapshot-delete</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -758,6 +791,11 @@
|
|||
<property name="tooltip_text" translatable="yes">Save updated snapshot metadata</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="clicked" handler="on_snapshot_apply_clicked" swapped="no"/>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="snapshot-apply-atkobject">
|
||||
<property name="AtkObject::accessible-name">snapshot-apply</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -781,5 +819,8 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
Loading…
Reference in New Issue