diff --git a/tests/uitests/snapshot.py b/tests/uitests/snapshot.py new file mode 100644 index 00000000..424fe9c5 --- /dev/null +++ b/tests/uitests/snapshot.py @@ -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) diff --git a/tests/uitests/utils.py b/tests/uitests/utils.py index 0d8e3703..69123237 100644 --- a/tests/uitests/utils.py +++ b/tests/uitests/utils.py @@ -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") diff --git a/ui/snapshots.ui b/ui/snapshots.ui index 289f1896..50b81de2 100644 --- a/ui/snapshots.ui +++ b/ui/snapshots.ui @@ -1,5 +1,5 @@ - + @@ -284,6 +284,9 @@ + + + 600 @@ -322,6 +325,11 @@ + + + snapshot-list + + @@ -606,6 +614,11 @@ True False error label + + + snapshot-error-label + + 1 @@ -662,6 +675,11 @@ gtk-add + + + snapshot-add + + False @@ -683,6 +701,11 @@ gtk-media-play + + + snapshot-start + + False @@ -704,6 +727,11 @@ gtk-refresh + + + snapshot-refresh + + False @@ -727,6 +755,11 @@ gtk-delete + + + snapshot-delete + + False @@ -758,6 +791,11 @@ Save updated snapshot metadata True + + + snapshot-apply + + False @@ -781,5 +819,8 @@ + + +