From dc41f61e5ef4930868749d8c8d1deb332f848f20 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 25 Aug 2020 12:46:59 -0400 Subject: [PATCH] uitests: Add combo selection helpers and use them Signed-off-by: Cole Robinson --- tests/uitests/test_addhardware.py | 303 +++++++++++------------------- tests/uitests/test_clonevm.py | 3 +- tests/uitests/test_createconn.py | 27 ++- tests/uitests/test_createpool.py | 30 +-- tests/uitests/test_createvm.py | 31 +-- tests/uitests/test_createvol.py | 8 +- tests/uitests/test_details.py | 29 +-- tests/uitests/test_livetests.py | 3 +- tests/uitests/test_migrate.py | 3 +- tests/uitests/test_prefs.py | 46 ++--- tests/uitests/utils.py | 22 +++ ui/netlist.ui | 5 + 12 files changed, 201 insertions(+), 309 deletions(-) diff --git a/tests/uitests/test_addhardware.py b/tests/uitests/test_addhardware.py index d8bfcfed9..f105aedf5 100644 --- a/tests/uitests/test_addhardware.py +++ b/tests/uitests/test_addhardware.py @@ -62,6 +62,12 @@ class AddHardware(uiutils.UITestCase): uiutils.check(lambda: tab.showing) return tab + def _finish(self, addhw, check): + addhw.find("Finish", "push button").click() + uiutils.check(lambda: not addhw.active) + if check: + uiutils.check(lambda: check.active) + ############## # Test cases # @@ -73,44 +79,33 @@ class AddHardware(uiutils.UITestCase): """ details = self._open_details_window() addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") # Default SCSI tab = self._select_hw(addhw, "Controller", "controller-tab") - typ = tab.find("Type:", "combo box") - typ.click_combo_entry() - tab.find("SCSI", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Type:", "SCSI") + self._finish(addhw, check=details) # Virtio SCSI addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Controller", "controller-tab") - typ.click_combo_entry() - tab.find("SCSI", "menu item").click() - tab.find("Model:", "combo box").click_combo_entry() - tab.find("VirtIO SCSI", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Type:", "SCSI") + tab.combo_select("Model:", "VirtIO SCSI") + self._finish(addhw, check=details) # USB 2 addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Controller", "controller-tab") - typ.click_combo_entry() - tab.find("USB", "menu item").click() - tab.find("Model:", "combo box").click_combo_entry() - tab.find("USB 2", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Type:", "USB") + tab.combo_select("Model:", "USB 2") + self._finish(addhw, check=details) # USB 3 addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Controller", "controller-tab") - typ.click_combo_entry() - tab.find("^USB$", "menu item").click() - tab.find("Model:", "combo box").click_combo_entry() - tab.find("USB 3", "menu item").click() + tab.combo_select("Type:", "USB") + tab.combo_select("Model:", "USB 3") # Can't add more than 1 USB controller, so finish isn't sensitive + finish = addhw.find("Finish", "push button") uiutils.check(lambda: not finish.sensitive) def testAddCephDisk(self): @@ -119,7 +114,6 @@ class AddHardware(uiutils.UITestCase): """ details = self._open_details_window() addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") # Select ceph volume for disk tab = self._select_hw(addhw, "Storage", "storage-tab") @@ -129,8 +123,7 @@ class AddHardware(uiutils.UITestCase): browse.find_fuzzy("rbd-ceph", "table cell").bring_on_screen().click() browse.find_fuzzy("some-rbd-vol", "table cell").click() browse.find("Choose Volume", "push button").click() - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) # Check disk details, make sure it correctly selected volume details.find("IDE Disk 2", "table cell").click() @@ -145,34 +138,29 @@ class AddHardware(uiutils.UITestCase): """ details = self._open_details_window() addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") # Default disk tab = self._select_hw(addhw, "Storage", "storage-tab") - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) # Disk with some tweaks addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Storage", "storage-tab") - tab.find("Bus type:", "combo box").click() - tab.find("VirtIO", "menu item").click() + tab.combo_select("Bus type:", "VirtIO") tab.find("Advanced options", "toggle button").click_expander() - tab.find("Cache mode:", "combo box").click() - tab.find("none", "menu item").click() + tab.combo_select("Cache mode:", "none") # Size too big tab.find("GiB", "spin button").text = "2000" - finish.click() + self._finish(addhw, check=None) self._click_alert_button("not enough free space", "Close") tab.find("GiB", "spin button").text = "1.5" - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) # Managed storage tests addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Storage", "storage-tab") tab.find_fuzzy("Select or create", "radio").click() - finish.click() + self._finish(addhw, check=None) self._click_alert_button("storage path must be specified", "OK") tab.find("storage-browse", "push button").click() browse = self.app.root.find("vmm-storage-browser") @@ -218,9 +206,9 @@ class AddHardware(uiutils.UITestCase): browse.find("diskvol1", "table cell").click() browse.find("Choose Volume", "push button").click() uiutils.check(lambda: "/diskvol1" in storageent.text) - finish.click() + self._finish(addhw, check=None) self._click_alert_button("already in use by", "No") - finish.click() + self._finish(addhw, check=None) self._click_alert_button("already in use by", "Yes") uiutils.check(lambda: details.active) @@ -228,23 +216,18 @@ class AddHardware(uiutils.UITestCase): # choose file for floppy addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Storage", "storage-tab") - tab.find("Device type:", "combo box").click() - tab.find("Floppy device", "menu item").click() + tab.combo_select("Device type:", "Floppy device") diskradio = tab.find_fuzzy("Create a disk image", "radio") uiutils.check(lambda: not diskradio.sensitive) tab.find("storage-entry").text = "/dev/default-pool/bochs-vol" - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) # empty cdrom addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Storage", "storage-tab") - tab.find("Device type:", "combo box").click() - tab.find("CDROM device", "menu item").click() - tab.find("Bus type:", "combo box").click() - tab.find("SCSI", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Device type:", "CDROM device") + tab.combo_select("Bus type:", "SCSI") + self._finish(addhw, check=details) @_search_permissions_decorator def testAddDiskSearchPermsCheckbox(self, uri, tmpdir): @@ -256,12 +239,11 @@ class AddHardware(uiutils.UITestCase): # Say 'No' but path should still work due to test driver addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") tab = self._select_hw(addhw, "Storage", "storage-tab") tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo1.img" tab.find("storage-entry").text = path - finish.click() + self._finish(addhw, check=None) self._click_alert_button("emulator may not have", "No") uiutils.check(lambda: details.active) @@ -271,7 +253,7 @@ class AddHardware(uiutils.UITestCase): tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo2.img" tab.find("storage-entry").text = path - finish.click() + self._finish(addhw, check=None) alert = self.app.root.find_fuzzy("vmm dialog", "alert") alert.find_fuzzy("Don't ask", "check box").click() self._click_alert_button("emulator may not have", "No") @@ -283,8 +265,7 @@ class AddHardware(uiutils.UITestCase): tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo3.img" tab.find("storage-entry").text = path - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) @_search_permissions_decorator def testAddDiskSearchPermsSuccess(self, uri, tmpdir): @@ -296,12 +277,11 @@ class AddHardware(uiutils.UITestCase): # Say 'Yes' addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") tab = self._select_hw(addhw, "Storage", "storage-tab") tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo1.img" tab.find("storage-entry").text = path - finish.click() + self._finish(addhw, check=None) self._click_alert_button("emulator may not have", "Yes") uiutils.check(lambda: details.active) @@ -311,8 +291,7 @@ class AddHardware(uiutils.UITestCase): tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo3.img" tab.find("storage-entry").text = path - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) @_search_permissions_decorator def testAddDiskSearchPermsFail(self, uri, tmpdir): @@ -325,12 +304,11 @@ class AddHardware(uiutils.UITestCase): # Say 'Yes' and it should fail, then blacklist the paths addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") tab = self._select_hw(addhw, "Storage", "storage-tab") tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo1.img" tab.find("storage-entry").text = path - finish.click() + self._finish(addhw, check=None) self._click_alert_button("emulator may not have", "Yes") alert = self.app.root.find("vmm dialog", "alert") alert.find_fuzzy("Errors were encountered", "label") @@ -344,8 +322,7 @@ class AddHardware(uiutils.UITestCase): tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo2.img" tab.find("storage-entry").text = path - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) def testAddNetworks(self): """ @@ -353,46 +330,35 @@ class AddHardware(uiutils.UITestCase): """ details = self._open_details_window() addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") # Basic network + opts tab = self._select_hw(addhw, "Network", "network-tab") - src = tab.find(None, "combo box", "Network source:") - src.click() - tab.find_fuzzy("Virtual network 'default' : NAT", "menu item").click() + tab.combo_select("net-source", "Virtual network 'default'") tab.find("MAC Address Field", "text").text = "00:11:00:11:00:11" - tab.find("Device model:", "combo box").click_combo_entry() - tab.find("virtio", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Device model:", "virtio") + self._finish(addhw, check=details) # Manual macvtap self._open_addhw_window(details) tab = self._select_hw(addhw, "Network", "network-tab") - src.click() - tab.find_fuzzy("Macvtap device...", "menu item").click() + tab.combo_select("net-source", "Macvtap device...") tab.find("Device name:", "text").text = "macvtapfoo7" - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) # Manual bridge. Also trigger MAC collision self._open_addhw_window(details) tab = self._select_hw(addhw, "Network", "network-tab") tab.find("mac-address-enable", "check box").click() - src.click() - self.pressKey("End") - tab.find_fuzzy("Bridge device...", "menu item").click() + tab.combo_select("net-source", "Bridge device...") tab.find("Device name:", "text").text = "zbr0" - finish.click() - + self._finish(addhw, check=None) # Check MAC validation error self._click_alert_button("00:11:22:33:44:55", "Close") # Fix MAC tab.find("mac-address-enable", "check box").click() tab.find("MAC Address Field", "text").text = "00:11:0A:11:00:11" - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) def testAddGraphics(self): @@ -401,16 +367,12 @@ class AddHardware(uiutils.UITestCase): """ details = self._open_details_window() addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") # VNC example tab = self._select_hw(addhw, "Graphics", "graphics-tab") - tab.find("Type:", "combo box").click_combo_entry() - tab.find_fuzzy("VNC", "menu item").click() - tab.find("Listen type:", "combo box").click_combo_entry() - tab.find_fuzzy("Address", "menu item").click() - tab.find("Address:", "combo box").click_combo_entry() - tab.find_fuzzy("All interfaces", "menu item").click() + tab.combo_select("Type:", "VNC") + tab.combo_select("Listen type:", "Address") + tab.combo_select("Address:", "All interfaces") tab.find("graphics-port-auto", "check").click() tab.find("graphics-port", "spin button").text = "1234" tab.find("Password:", "check").click() @@ -421,37 +383,26 @@ class AddHardware(uiutils.UITestCase): uiutils.check(lambda: passwd.text == newpass) tab.find("Show password", "check").click() uiutils.check(lambda: passwd.text != newpass) - finish.click() - + self._finish(addhw, check=None) # Catch a port error self._click_alert_button("Port must be above 5900", "Close") tab.find("graphics-port", "spin button").text = "5920" - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) # Spice regular example self._open_addhw_window(details) tab = self._select_hw(addhw, "Graphics", "graphics-tab") - tab.find("Type:", "combo box").click_combo_entry() - tab.find_fuzzy("Spice", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Type:", "Spice") + self._finish(addhw, check=details) # Spice GL example self._open_addhw_window(details) tab = self._select_hw(addhw, "Graphics", "graphics-tab") - tab.find("Type:", "combo box").click_combo_entry() - tab.find_fuzzy("Spice", "menu item").click() - tab.find("Listen type:", "combo box").click_combo_entry() - tab.find_fuzzy("None", "menu item").click() + tab.combo_select("Type:", "Spice") + tab.combo_select("Listen type:", "None") tab.find("OpenGL:", "check box").click() - render = tab.find("graphics-rendernode", "combo box") - m = tab.find_fuzzy("Intel Corp", "menu item") - render.click_combo_entry() - uiutils.check(lambda: m.selected) - self.pressKey("Escape") - finish.click() - uiutils.check(lambda: details.active) + tab.combo_check_default("graphics-rendernode", "0000") + self._finish(addhw, check=details) def testAddHosts(self): """ @@ -459,20 +410,18 @@ class AddHardware(uiutils.UITestCase): """ details = self._open_details_window() addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") # Add USB device dup1 tab = self._select_hw(addhw, "USB Host Device", "host-tab") tab.find_fuzzy("HP Dup USB 1", "table cell").click() - finish.click() + self._finish(addhw, check=None) self._click_alert_button("device is already in use by", "Yes") - uiutils.check(lambda: details.active) # Add USB device dup2 self._open_addhw_window(details) tab = self._select_hw(addhw, "USB Host Device", "host-tab") tab.find_fuzzy("HP Dup USB 2", "table cell").click() - finish.click() + self._finish(addhw, check=None) self._click_alert_button("device is already in use by", "Yes") uiutils.check(lambda: details.active) @@ -480,14 +429,13 @@ class AddHardware(uiutils.UITestCase): self._open_addhw_window(details) tab = self._select_hw(addhw, "USB Host Device", "host-tab") tab.find_fuzzy("Cruzer Micro 256", "table cell").click() - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) # Add PCI device self._open_addhw_window(details) tab = self._select_hw(addhw, "PCI Host Device", "host-tab") tab.find_fuzzy("(Interface eth0)", "table cell").click() - finish.click() + self._finish(addhw, check=None) self._click_alert_button("device is already in use by", "Yes") uiutils.check(lambda: details.active) @@ -498,40 +446,30 @@ class AddHardware(uiutils.UITestCase): """ details = self._open_details_window() addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") # Add console device tab = self._select_hw(addhw, "Console", "char-tab") - tab.find("Device Type:", "combo box").click() - tab.find_fuzzy("Pseudo TTY", "menu item").click() - tab.find("Type:", "combo box").click_combo_entry() - tab.find_fuzzy("Hypervisor default", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Device Type:", "Pseudo TTY") + tab.combo_select("Type:", "Hypervisor default") + self._finish(addhw, check=details) # Add serial+file self._open_addhw_window(details) tab = self._select_hw(addhw, "Serial", "char-tab") - tab.find("Device Type:", "combo box").click() - tab.find_fuzzy("Output to a file", "menu item").click() + tab.combo_select("Device Type:", "Output to a file") tab.find("Path:", "text").text = "/tmp/foo.log" - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) self._open_addhw_window(details) tab = self._select_hw(addhw, "Parallel", "char-tab") - tab.find("Device Type:", "combo box").click() - tab.find_fuzzy("UNIX", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Device Type:", "UNIX") + self._finish(addhw, check=details) # Add spicevmc channel self._open_addhw_window(details) tab = self._select_hw(addhw, "Channel", "char-tab") - # Ensures that this is selected by default - tab.find("com.redhat.spice.0", "combo box") - finish.click() - uiutils.check(lambda: details.active) + combo = tab.combo_select("Device Type:", ".*spicevmc.*") + self._finish(addhw, check=details) def testAddLXCFilesystem(self): @@ -542,16 +480,12 @@ class AddHardware(uiutils.UITestCase): details = self._open_details_window() addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") # Add File+nbd share tab = self._select_hw(addhw, "Filesystem", "filesystem-tab") - tab.find("Type:", "combo box").click() - tab.find("File", "menu item").click() - tab.find("Driver:", "combo box").click() - tab.find("Nbd", "menu item").click() - tab.find("Format:", "combo box").click_combo_entry() - tab.find("qcow2", "menu item").click() + tab.combo_select("Type:", "File") + tab.combo_select("Driver:", "Nbd") + tab.combo_select("Format:", "qcow2") source = tab.find("Source path:", "text") source.text = "/foo/source" @@ -573,113 +507,97 @@ class AddHardware(uiutils.UITestCase): # Use this to test some error.py logic for truncating large errors badtarget = "a" * 1024 tab.find("Target path:", "text").text = badtarget - finish.click() + self._finish(addhw, check=None) self._click_alert_button("aaa...", "Close") tab.find("Target path:", "text").text = "/foo/target" - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) # Add RAM type self._open_addhw_window(details) tab = self._select_hw(addhw, "Filesystem", "filesystem-tab") - tab.find("Type:", "combo box").click() - tab.find("Ram", "menu item").click() + tab.combo_select("Type:", "Ram") tab.find("Usage:", "spin button").text = "12345" tab.find("Target path:", "text").text = "/mem" - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) - def testAddHWMisc(self): + def testAddHWMisc1(self): """ - Add one each of simple devices + Add some simple devices """ details = self._open_details_window() addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") # Add input tab = self._select_hw(addhw, "Input", "input-tab") - tab.find("Type:", "combo box").click() - tab.find("EvTouch", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Type:", "EvTouch") + self._finish(addhw, check=details) # Add sound self._open_addhw_window(details) tab = self._select_hw(addhw, "Sound", "sound-tab") - tab.find("Model:", "combo box").click_combo_entry() - tab.find("HDA", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Model:", "HDA") + self._finish(addhw, check=details) # Add video self._open_addhw_window(details) tab = self._select_hw(addhw, "Video", "video-tab") - tab.find("Model:", "combo box").click_combo_entry() - tab.find("Virtio", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Model:", "Virtio") + self._finish(addhw, check=details) # Add watchdog self._open_addhw_window(details) tab = self._select_hw(addhw, "Watchdog", "watchdog-tab") - tab.find("Model:", "combo box").click() - tab.find("I6300", "menu item").click() - tab.find("Action:", "combo box").click() - tab.find("Pause the guest", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Model:", "I6300") + tab.combo_select("Action:", "Pause the guest") + self._finish(addhw, check=details) # Add smartcard self._open_addhw_window(details) tab = self._select_hw(addhw, "Smartcard", "smartcard-tab") - tab.find("Mode:", "combo box").click() - tab.find("Passthrough", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Mode:", "Passthrough") + self._finish(addhw, check=details) + + def testAddHWMisc2(self): + """ + Add some more simple devices" + """ + details = self._open_details_window() + addhw = self._open_addhw_window(details) # Add basic filesystem self._open_addhw_window(details) tab = self._select_hw(addhw, "Filesystem", "filesystem-tab") tab.find("Source path:", "text").text = "/foo/source" tab.find("Target path:", "text").text = "/foo/target" - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) # Add TPM self._open_addhw_window(details) tab = self._select_hw(addhw, "TPM", "tpm-tab") - tab.find("Model:", "combo").click() - tab.find("TIS", "menu item").click() - tab.find("Backend:", "combo").click() - tab.find("Passthrough", "menu item").click() + tab.combo_select("Model:", "TIS") + tab.combo_select("Backend:", "Passthrough") tab.find("Device Path:", "text").text = "/tmp/foo" - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) # Add RNG self._open_addhw_window(details) tab = self._select_hw(addhw, "RNG", "rng-tab") tab.find("Host Device:", "text").text = "/dev/random" - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) # Add Panic self._open_addhw_window(details) tab = self._select_hw(addhw, "Panic", "panic-tab") - tab.find("Model:", "combo box").click() - tab.find("Hyper-V", "menu item").click() - finish.click() - uiutils.check(lambda: details.active) + tab.combo_select("Model:", "Hyper-V") + self._finish(addhw, check=details) # Add vsock self._open_addhw_window(details) tab = self._select_hw(addhw, "VirtIO VSOCK", "vsock-tab") tab.find("vsock-auto").click() tab.find("vsock-cid").text = "7" - finish.click() - uiutils.check(lambda: details.active) + self._finish(addhw, check=details) def testAddHWCornerCases(self): @@ -688,14 +606,13 @@ class AddHardware(uiutils.UITestCase): """ details = self._open_details_window("test-many-devices") addhw = self._open_addhw_window(details) - finish = addhw.find("Finish", "push button") # Test cancel addhw.find("Cancel", "push button").click() # Test live adding, error dialog, click no self._open_addhw_window(details) - finish.click() + self._finish(addhw, check=None) alert = self.app.root.find("vmm dialog", "alert") alert.find( "This device could not be attached to the running machine", @@ -706,7 +623,7 @@ class AddHardware(uiutils.UITestCase): # Test live adding, error dialog, click yes self._open_addhw_window(details) - finish.click() + self._finish(addhw, check=None) alert = self.app.root.find("vmm dialog", "alert") alert.find( "This device could not be attached to the running machine", @@ -722,7 +639,6 @@ class AddHardware(uiutils.UITestCase): self.app.open(xmleditor_enabled=True) details = self._open_details_window() win = self._open_addhw_window(details) - finish = win.find("Finish", "push button") # Disk test, change path and make sure we error it is missing win.find("XML", "page tab").click() @@ -730,14 +646,14 @@ class AddHardware(uiutils.UITestCase): origpath = "/var/lib/libvirt/images/test-clone-simple.qcow2" newpath = "/FOO/XMLEDIT/test1.img" xmleditor.text = xmleditor.text.replace(origpath, newpath) - finish.click() + self._finish(win, check=None) self._click_alert_button("non-existent path", "Close") # Undo the bad change, change bus/target xmleditor.text = xmleditor.text.replace(newpath, origpath) xmleditor.text = xmleditor.text.replace("hdb", "xvda") xmleditor.text = xmleditor.text.replace("ide", "xen") - finish.click() + self._finish(win, check=details) # Verify the changes applied details.find("Xen Disk 1").click() @@ -758,6 +674,7 @@ class AddHardware(uiutils.UITestCase): uiutils.check(lambda: not xmleditor.showing) # Do standard xmleditor tests + finish = win.find("Finish", "push button") self._test_xmleditor_interactions(win, finish) win.find("Cancel", "push button").click() uiutils.check(lambda: not win.visible) diff --git a/tests/uitests/test_clonevm.py b/tests/uitests/test_clonevm.py index ac62f4ea7..c9ef029ec 100644 --- a/tests/uitests/test_clonevm.py +++ b/tests/uitests/test_clonevm.py @@ -71,8 +71,7 @@ class CloneVM(uiutils.UITestCase): "text", "New MAC:").text = "00:16:3e:cc:cf:05" macwin.find("OK", "push button").click() - win.find_fuzzy("Clone this disk.*", "combo box").click() - win.find_fuzzy("Details...", "menu item").click() + win.combo_select("Clone this disk.*", "Details...") stgwin = self.app.root.find("Change storage path", "dialog") stgwin.find(None, "text", "New Path:").text = "/dev/default-pool/my-new-path" diff --git a/tests/uitests/test_createconn.py b/tests/uitests/test_createconn.py index c0ec69179..3da8b349e 100644 --- a/tests/uitests/test_createconn.py +++ b/tests/uitests/test_createconn.py @@ -39,20 +39,15 @@ class VMMConnect(uiutils.UITestCase): uiutils.check(lambda: user.showing is host.showing is True) # Select all HV options - hvcombo = win.find_fuzzy("Hypervisor", "combo box") - def _click_hv(hvname): - hvcombo.click() - hvcombo.find_fuzzy(hvname, "menu item").click() - _click_hv("user session") - _click_hv("QEMU/KVM") - _click_hv("Xen") - _click_hv("Bhyve") - _click_hv("Virtuozzo") - _click_hv("LXC") + win.combo_select("Hypervisor", "QEMU/KVM user session") + win.combo_select("Hypervisor", r"^QEMU/KVM$") + win.combo_select("Hypervisor", "Xen") + win.combo_select("Hypervisor", "Bhyve") + win.combo_select("Hypervisor", "Virtuozzo") + win.combo_select("Hypervisor", r".*LXC.*") # Test a simple selection - win.find_fuzzy("Hypervisor", "combo box").click() - win.find_fuzzy("QEMU/KVM user session", "menu item").click() + win.combo_select("Hypervisor", "QEMU/KVM user session") uiutils.check(lambda: user.showing is host.showing is False) uiutils.check(lambda: urilabel.text == "qemu:///session") @@ -67,7 +62,7 @@ class VMMConnect(uiutils.UITestCase): uiutils.check(lambda: ":///session" not in urilabel.text) # Relaunch the dialog, confirm it doesn't overwrite content - _click_hv("LXC") + win.combo_select("Hypervisor", ".*LXC.*") uiutils.check(lambda: "lxc" in urilabel.text) self.app.root.find("File", "menu").click() self.app.root.find("Add Connection...", "menu item").click() @@ -76,7 +71,7 @@ class VMMConnect(uiutils.UITestCase): # Enter a failing URI, make sure error is raised, and we can # fall back to the dialog - _click_hv("Xen") + win.combo_select("Hypervisor", "Xen") remote.click() user.text = "fribuser" connect.click() @@ -111,7 +106,7 @@ class VMMConnect(uiutils.UITestCase): self.app.root.find("File", "menu").click() self.app.root.find("Add Connection...", "menu item").click() win = self.app.root.find_fuzzy("Add Connection", "dialog") - _click_hv("Custom URI") + win.combo_select("Hypervisor", "Custom URI") urientry.text = "test:///default" connect.click() @@ -120,7 +115,7 @@ class VMMConnect(uiutils.UITestCase): self.app.root.find("File", "menu").click() self.app.root.find("Add Connection...", "menu item").click() win = self.app.root.find_fuzzy("Add Connection", "dialog") - _click_hv("Custom URI") + win.combo_select("Hypervisor", "Custom URI") urientry.text = "test:///default" connect.click() diff --git a/tests/uitests/test_createpool.py b/tests/uitests/test_createpool.py index c71348b93..26f46c4a9 100644 --- a/tests/uitests/test_createpool.py +++ b/tests/uitests/test_createpool.py @@ -70,11 +70,9 @@ class CreatePool(uiutils.UITestCase): # Test a disk pool win = self._open_create_win(hostwin) - typ = win.find("Type:", "combo box") + win.combo_select("Type:", "disk:") newname = "a-disk-pool" name.text = "a-disk-pool" - typ.click() - win.find_fuzzy("Physical Disk", "menu item").click() win.find("source-browse").click() _browse_local_path("Choose source path", "console") finish.click() @@ -82,11 +80,9 @@ class CreatePool(uiutils.UITestCase): # Test a iscsi pool win = self._open_create_win(hostwin) - typ = win.find("Type:", "combo box") + win.combo_select("Type:", "iscsi:") newname = "a-iscsi-pool" name.text = "a-iscsi-pool" - typ.click() - win.find_fuzzy("iSCSI", "menu item").click() win.find("target-browse").click() _browse_local_path("Choose target directory", "by-path") finish.click() @@ -101,28 +97,21 @@ class CreatePool(uiutils.UITestCase): # Test a logical pool win = self._open_create_win(hostwin) - typ = win.find("Type:", "combo box") + win.combo_select("Type:", "logical:") newname = "a-lvm-pool" name.text = "a-lvm-pool" - typ.click() - win.find_fuzzy("LVM", "menu item").click() - srcname = win.find_fuzzy("Volgroup", "combo") - srcnametext = win.find_fuzzy("pool-source-name-text") - uiutils.check(lambda: srcnametext.text == "testvg1") - srcname.click_combo_entry() - win.find_fuzzy("testvg2", "menu item").click() + + win.combo_check_default("Volgroup", "testvg1") + win.combo_select("Volgroup", "testvg2") finish.click() hostwin.find(newname, "table cell") # Test a scsi pool win = self._open_create_win(hostwin) - typ = win.find("Type:", "combo box") + win.combo_select("Type:", "scsi:") newname = "a-scsi-pool" name.text = "a-scsi-pool" - typ.click() - win.find_fuzzy("SCSI Host Adapter", "menu item").click() - win.find_fuzzy("Source Adapter:", "combo").click_combo_entry() - win.find_fuzzy("host2", "menu item").click() + win.combo_select("Source Adapter:", "host2") finish.click() hostwin.find(newname, "table cell") @@ -130,8 +119,7 @@ class CreatePool(uiutils.UITestCase): win = self._open_create_win(hostwin) newname = "a-ceph-pool" name.text = "a-ceph-pool" - typ.click() - win.find_fuzzy("RADOS Block", "menu item").click() + win.combo_select("Type:", "rbd:") win.find_fuzzy("Host Name:", "text").text = "example.com:1234" win.find_fuzzy("pool-source-name-text", "text").typeText("frob") finish.click() diff --git a/tests/uitests/test_createvm.py b/tests/uitests/test_createvm.py index 449824a3c..12ddd5c5c 100644 --- a/tests/uitests/test_createvm.py +++ b/tests/uitests/test_createvm.py @@ -49,16 +49,13 @@ class NewVM(uiutils.UITestCase): self.app.root.find("File", "menu").click() self.app.root.find("Add Connection...", "menu item").click() win = self.app.root.find_fuzzy("Add Connection", "dialog") - win.find_fuzzy("Hypervisor", "combo box").click() - win.find_fuzzy("Custom URI", "menu item").click() + win.combo_select("Hypervisor", "Custom URI") win.find("uri-entry", "text").text = "test:///default" win.find("Connect", "push button").click() # Open the new VM wizard, select a connection newvm = self._open_create_wizard() - combo = newvm.find("create-conn") - combo.click() - combo.find_fuzzy("testdriver.xml").click() + newvm.combo_select("create-conn", ".*testdriver.xml.*") self.forward(newvm) # Verify media-combo contents for testdriver.xml @@ -72,8 +69,7 @@ class NewVM(uiutils.UITestCase): self.back(newvm) back = newvm.find_fuzzy("Back", "button") uiutils.check(lambda: not back.sensitive) - combo.click() - combo.find_fuzzy("test default").click() + newvm.combo_select("create-conn", ".*test default.*") self.forward(newvm) cdrom.click_combo_entry() uiutils.check(lambda: "/dev/sr1" not in cdrom.fmt_nodes()) @@ -312,9 +308,8 @@ class NewVM(uiutils.UITestCase): newvm = self._open_create_wizard() newvm.find_fuzzy("Architecture options", "toggle").click() - newvm.find_fuzzy("Architecture", "combo").click() - newvm.find_fuzzy("ppc64", "menu item").click() - newvm.find_fuzzy("pseries", "menu item") + newvm.combo_select("Architecture", ".*ppc64.*") + newvm.combo_check_default("Machine Type", ".*pseries.*") newvm.find_fuzzy("Import", "radio").click() newvm.find_fuzzy(None, @@ -517,8 +512,7 @@ class NewVM(uiutils.UITestCase): newvm = self._open_create_wizard() newvm.find_fuzzy("Architecture options", "toggle").click() - newvm.find_fuzzy("Xen Type", "combo").click() - newvm.find_fuzzy("paravirt", "menu item").click() + newvm.combo_select("Xen Type", ".*paravirt.*") newvm.find_fuzzy("Import", "radio").click() newvm.find_fuzzy(None, @@ -729,9 +723,7 @@ class NewVM(uiutils.UITestCase): newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm) self.forward(newvm) - combo = newvm.find(None, "combo box", "Network source:") - # For some reason atspi reports the internal combo value - uiutils.check(lambda: combo.name == "user") + newvm.combo_check_default("net-source", "Usermode") newvm.find_fuzzy("Finish", "button").click() self.app.root.find_fuzzy("vm1 on", "frame") @@ -752,9 +744,7 @@ class NewVM(uiutils.UITestCase): newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm) self.forward(newvm) - combo = newvm.find(None, "combo box", "Network source:") - # For some reason atspi reports the internal combo value - uiutils.check(lambda: combo.name == 'bridge') + newvm.combo_check_default("net-source", "Bridge") warnlabel = newvm.find_fuzzy("suitable default network", "label") uiutils.check(lambda: warnlabel.onscreen) newvm.find("Device name:", "text").text = "foobr0" @@ -807,9 +797,8 @@ class NewVM(uiutils.UITestCase): newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm) self.forward(newvm) - combo = newvm.find(None, "combo box", "Network source:") - # For some reason atspi reports the internal combo value - uiutils.check(lambda: combo.name == 'bridge') + newvm.find("Network selection", "toggle button").click_expander() + newvm.combo_check_default("net-source", "Bridge") devname = newvm.find("Device name:", "text") uiutils.check(lambda: devname.text == "testsuitebr0") diff --git a/tests/uitests/test_createvol.py b/tests/uitests/test_createvol.py index 04013c03a..32051eee8 100644 --- a/tests/uitests/test_createvol.py +++ b/tests/uitests/test_createvol.py @@ -71,9 +71,7 @@ class CreateVol(uiutils.UITestCase): # Create a qcow2 with backing file newname = "aaa-qcow2-backing.qcow2" name.text = newname - combo = win.find("Format:", "combo box") - combo.click_combo_entry() - combo.find("qcow2", "menu item").click() + win.combo_select("Format:", "qcow2") win.find("Backing store").click_expander() win.find("Browse...").click() browsewin = self.app.root.find("vmm-storage-browser") @@ -98,9 +96,7 @@ class CreateVol(uiutils.UITestCase): win = self._open_create_win(hostwin) # Using previous name so we collide name.text = newname - combo = win.find("Format:", "combo box") - combo.click_combo_entry() - combo.find("raw", "menu item").click() + win.combo_select("Format:", "raw") cap = win.find("Max Capacity:", "spin button") alloc = win.find("Allocation:", "spin button") alloc.text = "50.0" diff --git a/tests/uitests/test_details.py b/tests/uitests/test_details.py index 01318c568..ab07183fb 100644 --- a/tests/uitests/test_details.py +++ b/tests/uitests/test_details.py @@ -241,14 +241,13 @@ class Details(uiutils.UITestCase): # Network values w/ macvtap manual tab = self._select_hw(win, "NIC :54:32:10", "network-tab") - src = tab.find("Network source:", "combo box") + src = tab.find("net-source") src.click() self.pressKey("Home") tab.find_fuzzy("Macvtap device...", "menu item").bring_on_screen().click() tab.find("Device name:", "text").text = "fakedev12" - tab.find("Device model:", "combo box").click_combo_entry() - tab.find("rtl8139", "menu item").click() + tab.combo_select("Device model:", "rtl8139") appl.click() uiutils.check(lambda: not appl.sensitive) @@ -276,13 +275,11 @@ class Details(uiutils.UITestCase): # Graphics tab = self._select_hw(win, "Display VNC", "graphics-tab") - tab.find("Type:", "combo box").click_combo_entry() - tab.find("Spice server", "menu item").click() + tab.combo_select("Type:", "Spice") appl.click() uiutils.check(lambda: not appl.sensitive) - tab.find("Type:", "combo box").click_combo_entry() - tab.find("VNC server", "menu item").click() + tab.combo_select("Type:", "VNC") appl.click() uiutils.check(lambda: not appl.sensitive) @@ -321,31 +318,26 @@ class Details(uiutils.UITestCase): # Controller SCSI tab = self._select_hw( win, "Controller VirtIO SCSI 9", "controller-tab") - tab.find("controller-model", "combo box").click_combo_entry() - tab.find("Hypervisor default", "menu item").click() + tab.combo_select("controller-model", "Hypervisor") tab.find("SCSI Disk 1 on 9:0:0:0", "table cell") appl.click() uiutils.check(lambda: not appl.sensitive) # Controller USB tab = self._select_hw(win, "Controller USB 0", "controller-tab") - tab.find("controller-model", "combo box").click_combo_entry() - tab.find("USB 2", "menu item").click() + tab.combo_select("controller-model", "USB 2") appl.click() uiutils.check(lambda: not appl.sensitive) tab = self._select_hw(win, "Controller USB 0", "controller-tab") - tab.find("controller-model", "combo box").click_combo_entry() - tab.find("USB 3", "menu item").click() + tab.combo_select("controller-model", "USB 3") appl.click() uiutils.check(lambda: not appl.sensitive) # Filesystem tweaks tab = self._select_hw(win, "Filesystem /target/", "filesystem-tab") - tab.find("Driver:", "combo box").click() - tab.find("Path", "menu item").click() - tab.find("Write Policy:", "combo box").click() - tab.find("Immediate", "menu item").click() + tab.combo_select("Driver:", "Path") + tab.combo_select("Write Policy:", "Immediate") tab.find("Source path:", "text").text = "/frib1" tab.find("Target path:", "text").text = "newtarget" tab.find_fuzzy("Export filesystem", "check box").click() @@ -355,8 +347,7 @@ class Details(uiutils.UITestCase): # Smartcard tweaks tab = self._select_hw(win, "Smartcard", "smartcard-tab") - tab.find("smartcard-mode", "combo box").click_combo_entry() - tab.find("Passthrough", "menu item").click() + tab.combo_select("smartcard-mode", "Passthrough") appl.click() uiutils.check(lambda: not appl.sensitive) diff --git a/tests/uitests/test_livetests.py b/tests/uitests/test_livetests.py index ee5b8549a..f4beb0db0 100644 --- a/tests/uitests/test_livetests.py +++ b/tests/uitests/test_livetests.py @@ -178,8 +178,7 @@ class Console(uiutils.UITestCase): uiutils.check(lambda: tab.showing) tab.find("Select or create", "radio button").click() tab.find("storage-entry").text = fname - tab.find("Bus type:", "combo box").click() - tab.find("SCSI", "menu item").click() + tab.combo_select("Bus type:", "SCSI") addhw.find("Finish", "push button").click() # Verify permission dialog pops up, ask to change diff --git a/tests/uitests/test_migrate.py b/tests/uitests/test_migrate.py index f1ee8a093..b910e42a5 100644 --- a/tests/uitests/test_migrate.py +++ b/tests/uitests/test_migrate.py @@ -18,8 +18,7 @@ class VMMMigrate(uiutils.UITestCase): self.app.root.find("File", "menu").click() self.app.root.find("Add Connection...", "menu item").click() win = self.app.root.find_fuzzy("Add Connection", "dialog") - win.find_fuzzy("Hypervisor", "combo box").click() - win.find_fuzzy("Custom URI", "menu item").click() + win.combo_select("Hypervisor", "Custom URI") win.find("uri-entry", "text").text = "test:///default" win.find("Connect", "push button").click() diff --git a/tests/uitests/test_prefs.py b/tests/uitests/test_prefs.py index 415837efb..b130e7073 100644 --- a/tests/uitests/test_prefs.py +++ b/tests/uitests/test_prefs.py @@ -34,38 +34,30 @@ class VMMPrefs(uiutils.UITestCase): win.find("Polling", "page tab").click() tab = pollingtab uiutils.check(lambda: tab.onscreen) - tab.find_fuzzy(None, "check box", "Poll CPU").click() - tab.find_fuzzy(None, "check box", "Poll Disk").click() - tab.find_fuzzy(None, "check box", "Poll Memory").click() - tab.find_fuzzy(None, "check box", "Poll Network").click() + tab.find("Poll CPU", "check box").click() + tab.find("Poll Disk", "check box").click() + tab.find("Poll Memory", "check box").click() + tab.find("Poll Network", "check box").click() period = tab.find_fuzzy("cpu-poll", "spin button") period.click() period.text = "5" win.find("New VM", "page tab").click() tab = newvmtab - newvmtab.print_nodes() uiutils.check(lambda: tab.onscreen) - tab.find_fuzzy(None, "check box", "sound device").click() - tab.find(None, "combo box", "CPU default:").click() - tab.find_fuzzy("Copy host", "menu item").click() - tab.find(None, "combo box", "Storage format:").click() - tab.find("Raw", "menu item").click() - tab.find("prefs-add-spice-usbredir", "combo box").click() - tab.find("No", "menu item").click() - tab.find_fuzzy("Graphics type", "combo box").click() - tab.find("VNC", "menu item").click() + tab.find("Add sound device", "check box").click() + tab.combo_select("CPU default:", "Copy host") + tab.combo_select("Storage format:", "Raw") + tab.combo_select("prefs-add-spice-usbredir", "No") + tab.combo_select("Graphics type", "VNC") win.find("Console", "page tab").click() tab = consoletab uiutils.check(lambda: tab.onscreen) - tab.find(None, "combo box", "SPICE USB").click() - tab.find_fuzzy("Manual redirect", "menu item").click() - tab.find_fuzzy(None, "combo box", "Resize guest").click() - tab.find("On", "menu item").click() - tab.find_fuzzy(None, "combo box", "console scaling").click() - tab.find_fuzzy("Always", "menu item").click() - tab.find_fuzzy(None, "check box", "Force console").click() + tab.combo_select("SPICE USB", "Manual redirect") + tab.combo_select("Resize guest", "On") + tab.combo_select("Graphical console scaling", "Always") + tab.find("Force console", "check box").click() tab.find("Change...", "push button").click() keyframe = self.app.root.find_fuzzy("Configure grab", "dialog") @@ -90,12 +82,12 @@ class VMMPrefs(uiutils.UITestCase): win.find("Feedback", "page tab").click() tab = feedbacktab uiutils.check(lambda: tab.onscreen) - tab.find_fuzzy(None, "check box", "Force Poweroff").click() - tab.find_fuzzy(None, "check box", "Poweroff/Reboot").click() - tab.find_fuzzy(None, "check box", "Pause").click() - tab.find_fuzzy(None, "check box", "Device removal").click() - tab.find_fuzzy(None, "check box", "Unapplied changes").click() - tab.find_fuzzy(None, "check box", "Deleting storage").click() + tab.find("Force Poweroff", "check box").click() + tab.find("Poweroff/Reboot", "check box").click() + tab.find("Pause", "check box").click() + tab.find("Device removal", "check box").click() + tab.find("Unapplied changes", "check box").click() + tab.find("Deleting storage", "check box").click() win.find("General", "page tab").click() win.find_fuzzy("Enable system tray", "check").click() diff --git a/tests/uitests/utils.py b/tests/uitests/utils.py index 34905c0ca..d5bd00e27 100644 --- a/tests/uitests/utils.py +++ b/tests/uitests/utils.py @@ -392,6 +392,28 @@ class VMMDogtailNode(dogtail.tree.Node): return self.find(name_pattern, role_pattern, labeller_pattern) + ########################## + # Higher level behaviors # + ########################## + + def combo_select(self, combolabel, itemlabel): + """ + Lookup the combo, click it, select the menu item + """ + combo = self.find(combolabel, "combo box") + combo.click_combo_entry() + combo.find(itemlabel, "menu item").click() + + def combo_check_default(self, combolabel, itemlabel): + """ + Lookup the combo and verify the menu item is selected + """ + combo = self.find(combolabel, "combo box") + combo.click_combo_entry() + item = combo.find(itemlabel, "menu item") + check(lambda: item.selected) + dogtail.rawinput.pressKey("Escape") + ##################### # Debugging helpers # diff --git a/ui/netlist.ui b/ui/netlist.ui index 61e68999a..f0cd135e7 100644 --- a/ui/netlist.ui +++ b/ui/netlist.ui @@ -84,6 +84,11 @@ start False + + + net-source + + 0