From a289676574306c44ea6e1b7987cd89d54dc508b8 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 27 Aug 2020 12:23:14 -0400 Subject: [PATCH] uitests: More use of safer utility helpers Signed-off-by: Cole Robinson --- tests/uitests/test_addhardware.py | 66 ++++++++-------- tests/uitests/test_clonevm.py | 6 +- tests/uitests/test_createconn.py | 10 +-- tests/uitests/test_createnet.py | 28 +++---- tests/uitests/test_createpool.py | 26 +++---- tests/uitests/test_createvm.py | 122 ++++++++++++++---------------- tests/uitests/test_createvol.py | 25 +++--- tests/uitests/test_details.py | 63 ++++++++------- tests/uitests/test_host.py | 10 +-- tests/uitests/test_livetests.py | 4 +- tests/uitests/test_manager.py | 2 +- tests/uitests/test_mediachange.py | 9 +-- tests/uitests/test_migrate.py | 4 +- tests/uitests/test_prefs.py | 6 +- tests/uitests/test_snapshot.py | 18 ++--- tests/uitests/utils.py | 40 +++++++++- ui/createvm.ui | 5 ++ 17 files changed, 236 insertions(+), 208 deletions(-) diff --git a/tests/uitests/test_addhardware.py b/tests/uitests/test_addhardware.py index 822de50e6..e89f87131 100644 --- a/tests/uitests/test_addhardware.py +++ b/tests/uitests/test_addhardware.py @@ -152,10 +152,10 @@ class AddHardware(uiutils.UITestCase): tab.combo_select("Discard mode:", "ignore") tab.combo_select("Detect zeroes:", "unmap") # Size too big - tab.find("GiB", "spin button").text = "2000" + tab.find("GiB", "spin button").set_text("2000") self._finish(addhw, check=None) self._click_alert_button("not enough free space", "Close") - tab.find("GiB", "spin button").text = "1.5" + tab.find("GiB", "spin button").set_text("1.5") self._finish(addhw, check=details) # Managed storage tests @@ -172,7 +172,7 @@ class AddHardware(uiutils.UITestCase): browse.find("vol-new", "push button").click() newvol = self.app.root.find("Add a Storage Volume", "frame") newname = "a-newvol" - newvol.find("Name:", "text").text = newname + newvol.find("Name:", "text").set_text(newname) newvol.find("Finish", "push button").click() uiutils.check(lambda: not newvol.showing) volcell = browse.find(newname, "table cell") @@ -221,7 +221,7 @@ class AddHardware(uiutils.UITestCase): 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" + tab.find("storage-entry").set_text("/dev/default-pool/bochs-vol") self._finish(addhw, check=details) # empty cdrom @@ -244,7 +244,7 @@ class AddHardware(uiutils.UITestCase): 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 + tab.find("storage-entry").set_text(path) self._finish(addhw, check=None) self._click_alert_button("emulator may not have", "No") uiutils.check(lambda: details.active) @@ -254,7 +254,7 @@ class AddHardware(uiutils.UITestCase): tab = self._select_hw(addhw, "Storage", "storage-tab") tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo2.img" - tab.find("storage-entry").text = path + tab.find("storage-entry").set_text(path) self._finish(addhw, check=None) alert = self.app.root.find_fuzzy("vmm dialog", "alert") alert.find_fuzzy("Don't ask", "check box").click() @@ -266,7 +266,7 @@ class AddHardware(uiutils.UITestCase): tab = self._select_hw(addhw, "Storage", "storage-tab") tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo3.img" - tab.find("storage-entry").text = path + tab.find("storage-entry").set_text(path) self._finish(addhw, check=details) @_search_permissions_decorator @@ -282,7 +282,7 @@ class AddHardware(uiutils.UITestCase): 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 + tab.find("storage-entry").set_text(path) self._finish(addhw, check=None) self._click_alert_button("emulator may not have", "Yes") uiutils.check(lambda: details.active) @@ -292,7 +292,7 @@ class AddHardware(uiutils.UITestCase): tab = self._select_hw(addhw, "Storage", "storage-tab") tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo3.img" - tab.find("storage-entry").text = path + tab.find("storage-entry").set_text(path) self._finish(addhw, check=details) @_search_permissions_decorator @@ -309,7 +309,7 @@ class AddHardware(uiutils.UITestCase): 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 + tab.find("storage-entry").set_text(path) self._finish(addhw, check=None) self._click_alert_button("emulator may not have", "Yes") alert = self.app.root.find("vmm dialog", "alert") @@ -323,7 +323,7 @@ class AddHardware(uiutils.UITestCase): tab = self._select_hw(addhw, "Storage", "storage-tab") tab.find_fuzzy("Select or create", "radio").click() path = tmpdir + "/foo2.img" - tab.find("storage-entry").text = path + tab.find("storage-entry").set_text(path) self._finish(addhw, check=details) def testAddNetworks(self): @@ -336,7 +336,7 @@ class AddHardware(uiutils.UITestCase): # Basic network + opts tab = self._select_hw(addhw, "Network", "network-tab") tab.combo_select("net-source", "Virtual network 'default'") - tab.find("MAC Address Field", "text").text = "00:11:00:11:00:11" + tab.find("MAC Address Field", "text").set_text("00:11:00:11:00:11") tab.combo_select("Device model:", "virtio") self._finish(addhw, check=details) @@ -344,7 +344,7 @@ class AddHardware(uiutils.UITestCase): self._open_addhw_window(details) tab = self._select_hw(addhw, "Network", "network-tab") tab.combo_select("net-source", "Macvtap device...") - tab.find("Device name:", "text").text = "macvtapfoo7" + tab.find("Device name:", "text").set_text("macvtapfoo7") self._finish(addhw, check=details) # Manual bridge. Also trigger MAC collision @@ -352,14 +352,14 @@ class AddHardware(uiutils.UITestCase): tab = self._select_hw(addhw, "Network", "network-tab") tab.find("mac-address-enable", "check box").click() tab.combo_select("net-source", "Bridge device...") - tab.find("Device name:", "text").text = "zbr0" + tab.find("Device name:", "text").set_text("zbr0") 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" + tab.find("MAC Address Field", "text").set_text("00:11:0A:11:00:11") self._finish(addhw, check=details) @@ -376,7 +376,7 @@ class AddHardware(uiutils.UITestCase): 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("graphics-port", "spin button").set_text("1234") tab.find("Password:", "check").click() passwd = tab.find_fuzzy("graphics-password", "text") newpass = "foobar" @@ -388,7 +388,7 @@ class AddHardware(uiutils.UITestCase): 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" + tab.find("graphics-port", "spin button").set_text("5920") self._finish(addhw, check=details) # Spice regular example @@ -462,7 +462,7 @@ class AddHardware(uiutils.UITestCase): self._open_addhw_window(details) tab = self._select_hw(addhw, "Serial", "char-tab") tab.combo_select("Device Type:", "Output to a file") - tab.find("Path:", "text").text = "/tmp/foo.log" + tab.find("Path:", "text").set_text("/tmp/foo.log") self._finish(addhw, check=details) self._open_addhw_window(details) @@ -495,7 +495,7 @@ class AddHardware(uiutils.UITestCase): tab.combo_select("Format:", "qcow2") source = tab.find("Source path:", "text") - source.text = "/foo/source" + source.set_text("/foo/source") tab.find("Browse...", "push button").click() # Specific testing for dir vol handling for filesystem browse browsewin = self.app.root.find("vmm-storage-browser") @@ -513,18 +513,18 @@ class AddHardware(uiutils.UITestCase): tab.find_fuzzy("Export filesystem", "check").click() # Use this to test some error.py logic for truncating large errors badtarget = "a" * 1024 - tab.find("Target path:", "text").text = badtarget + tab.find("Target path:", "text").set_text(badtarget) self._finish(addhw, check=None) self._click_alert_button("aaa...", "Close") - tab.find("Target path:", "text").text = "/foo/target" + tab.find("Target path:", "text").set_text("/foo/target") self._finish(addhw, check=details) # Add RAM type self._open_addhw_window(details) tab = self._select_hw(addhw, "Filesystem", "filesystem-tab") tab.combo_select("Type:", "Ram") - tab.find("Usage:", "spin button").text = "12345" - tab.find("Target path:", "text").text = "/mem" + tab.find("Usage:", "spin button").set_text("12345") + tab.find("Target path:", "text").set_text("/mem") self._finish(addhw, check=details) @@ -592,8 +592,8 @@ class AddHardware(uiutils.UITestCase): # 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" + tab.find("Source path:", "text").set_text("/foo/source") + tab.find("Target path:", "text").set_text("/foo/target") self._finish(addhw, check=details) # Add TPM passthrough @@ -601,13 +601,13 @@ class AddHardware(uiutils.UITestCase): tab = self._select_hw(addhw, "TPM", "tpm-tab") tab.combo_select("Model:", "TIS") tab.combo_select("Backend:", "Passthrough") - tab.find("Device Path:", "text").text = "/tmp/foo" + tab.find("Device Path:", "text").set_text("/tmp/foo") 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" + tab.find("Host Device:", "text").set_text("/dev/random") self._finish(addhw, check=details) # Add Panic @@ -620,7 +620,7 @@ class AddHardware(uiutils.UITestCase): 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" + tab.find("vsock-cid").set_text("7") self._finish(addhw, check=details) def testAddHWUSBNone(self): @@ -641,7 +641,7 @@ class AddHardware(uiutils.UITestCase): addhw = self._open_addhw_window(details) tab = self._select_hw(addhw, "Controller", "controller-tab") combo = tab.find("Type:", "combo box") - combo.find(None, "text").text = "foobar" + combo.find(None, "text").set_text("foobar") self._finish(addhw, check=None) self._click_alert_button("Unable to add device", "Close") uiutils.check(lambda: addhw.active) @@ -691,14 +691,14 @@ class AddHardware(uiutils.UITestCase): xmleditor = win.find("XML editor") origpath = "/var/lib/libvirt/images/test-clone-simple.qcow2" newpath = "/FOO/XMLEDIT/test1.img" - xmleditor.text = xmleditor.text.replace(origpath, newpath) + xmleditor.set_text(xmleditor.text.replace(origpath, newpath)) 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") + xmleditor.set_text(xmleditor.text.replace(newpath, origpath)) + xmleditor.set_text(xmleditor.text.replace("hdb", "xvda")) + xmleditor.set_text(xmleditor.text.replace("ide", "xen")) self._finish(win, check=details) # Verify the changes applied diff --git a/tests/uitests/test_clonevm.py b/tests/uitests/test_clonevm.py index c9ef029ec..4377ac420 100644 --- a/tests/uitests/test_clonevm.py +++ b/tests/uitests/test_clonevm.py @@ -63,18 +63,18 @@ class CloneVM(uiutils.UITestCase): """ win = self._open_window("test-clone-simple") win.find_fuzzy(None, - "text", "Name").text = "test-new-vm" + "text", "Name").set_text("test-new-vm") win.find("Details...", "push button").click() macwin = self.app.root.find("Change MAC address", "dialog") macwin.find(None, - "text", "New MAC:").text = "00:16:3e:cc:cf:05" + "text", "New MAC:").set_text("00:16:3e:cc:cf:05") macwin.find("OK", "push button").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" + "New Path:").set_text("/dev/default-pool/my-new-path") stgwin.find("OK", "push button").click() win.find("Clone", "push button").click() diff --git a/tests/uitests/test_createconn.py b/tests/uitests/test_createconn.py index fe1acf705..65ef19c0e 100644 --- a/tests/uitests/test_createconn.py +++ b/tests/uitests/test_createconn.py @@ -77,14 +77,14 @@ class VMMConnect(uiutils.UITestCase): # fall back to the dialog win.combo_select("Hypervisor", "Xen") remote.click() - user.text = "fribuser" + user.set_text("fribuser") connect.click() self._click_alert_button("hostname is required", "OK") fakeipv6 = "fe80::1" - host.text = fakeipv6 + host.set_text(fakeipv6) uiutils.check(lambda: urilabel.text == "xen+ssh://fribuser@[%s]/" % fakeipv6) fakehost = "ix8khfyidontexistkdjur.com" - host.text = fakehost + ":12345" + host.set_text(fakehost + ":12345") uiutils.check(lambda: urilabel.text == "xen+ssh://fribuser@%s:12345/" % fakehost) connect.click() @@ -111,7 +111,7 @@ class VMMConnect(uiutils.UITestCase): self.app.root.find("Add Connection...", "menu item").click() win = self.app.root.find_fuzzy("Add Connection", "dialog") win.combo_select("Hypervisor", "Custom URI") - urientry.text = "test:///default" + urientry.set_text("test:///default") connect.click() # Do it again to make sure things don't explode @@ -120,7 +120,7 @@ class VMMConnect(uiutils.UITestCase): self.app.root.find("Add Connection...", "menu item").click() win = self.app.root.find_fuzzy("Add Connection", "dialog") win.combo_select("Hypervisor", "Custom URI") - urientry.text = "test:///default" + urientry.set_text("test:///default") connect.click() # Try various connect/disconnect routines diff --git a/tests/uitests/test_createnet.py b/tests/uitests/test_createnet.py index e74d36e12..52b3642e4 100644 --- a/tests/uitests/test_createnet.py +++ b/tests/uitests/test_createnet.py @@ -32,7 +32,7 @@ class CreateNet(uiutils.UITestCase): finish = win.find("Finish", "push button") uiutils.check(lambda: name.text == "network") newname = "a-test-new-net" - name.text = newname + name.set_text(newname) finish.click() # Select the new network in the host window, then do @@ -74,11 +74,11 @@ class CreateNet(uiutils.UITestCase): # Create a new obj with XML edited name, verify it worked tmpname = "objtmpname" newname = "froofroo" - name.text = tmpname + name.set_text(tmpname) win.find("XML", "page tab").click() xmleditor = win.find("XML editor") - xmleditor.text = xmleditor.text.replace( - ">%s<" % tmpname, ">%s<" % newname) + newtext = xmleditor.text.replace(">%s<" % tmpname, ">%s<" % newname) + xmleditor.set_text(newtext) finish.click() uiutils.check(lambda: hostwin.active) cell = hostwin.find(newname, "table cell") @@ -107,11 +107,11 @@ class CreateNet(uiutils.UITestCase): finish = win.find("Finish", "push button") # Create a network with a bunch of options - win.find("Name:", "text").text = "default" + win.find("Name:", "text").set_text("default") win.find("net-mode").click() win.find("Isolated", "menu item").click() win.find("IPv4 configuration").click_expander() - win.find("ipv4-network").text = "192.168.100.0/25" + win.find("ipv4-network").set_text("192.168.100.0/25") ipv4start = win.find("ipv4-start") ipv4end = win.find("ipv4-end") uiutils.check(lambda: ipv4start.text == "192.168.100.64") @@ -121,26 +121,26 @@ class CreateNet(uiutils.UITestCase): win.find("IPv6 configuration").click_expander() win.find("Enable IPv6").click() win.find("Enable DHCPv6").click() - win.find("ipv6-network").text = "fd00:beef:10:6::1/64" - win.find("ipv6-start").text = "fd00:beef:10:6::1:1" - win.find("ipv6-end").text = "bad" + win.find("ipv6-network").set_text("fd00:beef:10:6::1/64") + win.find("ipv6-start").set_text("fd00:beef:10:6::1:1") + win.find("ipv6-end").set_text("bad") win.find("DNS domain name").click_expander() win.find("Custom").click() - win.find("domain-custom").text = "mydomain" + win.find("domain-custom").set_text("mydomain") finish.click() # Name collision validation self._click_alert_button("in use by another network", "Close") - win.find("Name:", "text").text = "newnet1" + win.find("Name:", "text").set_text("newnet1") finish.click() # XML define error self._click_alert_button("Error creating virtual network", "Close") - win.find("ipv6-end").text = "fd00:beef:10:6::1:f1" + win.find("ipv6-end").set_text("fd00:beef:10:6::1:f1") finish.click() uiutils.check(lambda: hostwin.active) # More option work win = self._open_create_win(hostwin) - win.find("Name:", "text").text = "newnet2" + win.find("Name:", "text").set_text("newnet2") devicelist = win.find("net-devicelist") uiutils.check(lambda: not devicelist.visible) win.find("net-mode").click() @@ -152,7 +152,7 @@ class CreateNet(uiutils.UITestCase): win.find("Routed", "menu item").click() win.find("net-forward").click() win.find("Physical device", "menu item").click() - win.find("net-device").text = "fakedev0" + win.find("net-device").set_text("fakedev0") finish.click() uiutils.check(lambda: hostwin.active) diff --git a/tests/uitests/test_createpool.py b/tests/uitests/test_createpool.py index 05af68c9e..471069366 100644 --- a/tests/uitests/test_createpool.py +++ b/tests/uitests/test_createpool.py @@ -40,7 +40,7 @@ class CreatePool(uiutils.UITestCase): # Create a simple default dir pool uiutils.check(lambda: name.text == "pool") newname = "a-test-new-pool" - name.text = newname + name.set_text(newname) finish.click() # Select the new object in the host window, then do @@ -72,7 +72,7 @@ class CreatePool(uiutils.UITestCase): win = self._open_create_win(hostwin) win.combo_select("Type:", "disk:") newname = "a-disk-pool" - name.text = "a-disk-pool" + name.set_text("a-disk-pool") win.find("source-browse").click() _browse_local_path("Choose source path", "console") finish.click() @@ -82,16 +82,16 @@ class CreatePool(uiutils.UITestCase): win = self._open_create_win(hostwin) win.combo_select("Type:", "iscsi:") newname = "a-iscsi-pool" - name.text = "a-iscsi-pool" + name.set_text("a-iscsi-pool") win.find("target-browse").click() _browse_local_path("Choose target directory", "by-path") finish.click() # Catch example error self._click_alert_button("source host name", "Close") - win.find("Host Name:", "text").text = "example.com" - win.find("pool-source-path-text").text = "foo-iqn" + win.find("Host Name:", "text").set_text("example.com") + win.find("pool-source-path-text").set_text("foo-iqn") win.find_fuzzy("Initiator IQN:", "check").click() - win.find("iqn-text", "text").text = "initiator-foo" + win.find("iqn-text", "text").set_text("initiator-foo") finish.click() hostwin.find(newname, "table cell") @@ -99,7 +99,7 @@ class CreatePool(uiutils.UITestCase): win = self._open_create_win(hostwin) win.combo_select("Type:", "logical:") newname = "a-lvm-pool" - name.text = "a-lvm-pool" + name.set_text("a-lvm-pool") win.combo_check_default("Volgroup", "testvg1") win.combo_select("Volgroup", "testvg2") @@ -110,7 +110,7 @@ class CreatePool(uiutils.UITestCase): win = self._open_create_win(hostwin) win.combo_select("Type:", "scsi:") newname = "a-scsi-pool" - name.text = "a-scsi-pool" + name.set_text("a-scsi-pool") win.combo_select("Source Adapter:", "host2") finish.click() hostwin.find(newname, "table cell") @@ -118,9 +118,9 @@ class CreatePool(uiutils.UITestCase): # Test a ceph pool win = self._open_create_win(hostwin) newname = "a-ceph-pool" - name.text = "a-ceph-pool" + name.set_text("a-ceph-pool") win.combo_select("Type:", "rbd:") - win.find_fuzzy("Host Name:", "text").text = "example.com:1234" + win.find_fuzzy("Host Name:", "text").set_text("example.com:1234") win.find_fuzzy("pool-source-name-text", "text").typeText("frob") finish.click() uiutils.check(lambda: not win.showing) @@ -143,11 +143,11 @@ class CreatePool(uiutils.UITestCase): # Create a new obj with XML edited name, verify it worked tmpname = "objtmpname" newname = "froofroo" - name.text = tmpname + name.set_text(tmpname) win.find("XML", "page tab").click() xmleditor = win.find("XML editor") - xmleditor.text = xmleditor.text.replace( - ">%s<" % tmpname, ">%s<" % newname) + newtext = xmleditor.text.replace(">%s<" % tmpname, ">%s<" % newname) + xmleditor.set_text(newtext) finish.click() uiutils.check(lambda: hostwin.active) cell = hostwin.find(newname, "table cell") diff --git a/tests/uitests/test_createvm.py b/tests/uitests/test_createvm.py index 8085d5d60..df9e88ea5 100644 --- a/tests/uitests/test_createvm.py +++ b/tests/uitests/test_createvm.py @@ -50,7 +50,7 @@ class NewVM(uiutils.UITestCase): self.app.root.find("Add Connection...", "menu item").click() win = self.app.root.find_fuzzy("Add Connection", "dialog") win.combo_select("Hypervisor", "Custom URI") - win.find("uri-entry", "text").text = "test:///default" + win.find("uri-entry", "text").set_text("test:///default") win.find("Connect", "push button").click() # Open the new VM wizard, select a connection @@ -148,7 +148,7 @@ class NewVM(uiutils.UITestCase): # test entry activation too entry = newvm.find("media-entry") entry.click() - entry.text = "/dev/sr0" + entry.set_text("/dev/sr0") self.pressKey("Enter") # Select a fake iso @@ -161,7 +161,7 @@ class NewVM(uiutils.UITestCase): # Change distro to win8 newvm.find_fuzzy("Automatically detect", "check").click() osentry.click() - osentry.text = "windows 8" + osentry.set_text("windows 8") popover = newvm.find("oslist-popover") uiutils.check(lambda: popover.onscreen) # Verify Escape resets the text entry @@ -169,7 +169,7 @@ class NewVM(uiutils.UITestCase): uiutils.check(lambda: not popover.onscreen) uiutils.check(lambda: osentry.text == "") # Re-enter text - osentry.text = "windows 8" + osentry.set_text("windows 8") uiutils.check(lambda: popover.onscreen) popover.find_fuzzy("include-eol").click() popover.find_fuzzy(r"\(win8\)").click() @@ -177,7 +177,7 @@ class NewVM(uiutils.UITestCase): foundtext = osentry.text # Start typing again, and exit, make sure it resets to previous entry osentry.click() - osentry.text = "foo" + osentry.set_text("foo") uiutils.check(lambda: popover.onscreen) self.pressKey("Escape") uiutils.check(lambda: not popover.onscreen) @@ -221,7 +221,7 @@ class NewVM(uiutils.UITestCase): appl = vmwindow.find("config-apply", "push button") hwlist = vmwindow.find("hw-list") tab = vmwindow.find("disk-tab") - tab.find("Disk bus:", "text").text = "usb" + tab.find("Disk bus:", "text").set_text("usb") appl.click() uiutils.check(lambda: not appl.sensitive) # Device is now 'USB Disk 1' @@ -235,7 +235,7 @@ class NewVM(uiutils.UITestCase): vmwindow.find_fuzzy("NIC", "table cell").click() tab = vmwindow.find("network-tab") tab.print_nodes() - tab.find("mac-entry", "text").text = "00:11:00:11:00:11" + tab.find("mac-entry", "text").set_text("00:11:00:11:00:11") appl.click() uiutils.check(lambda: not appl.sensitive) @@ -263,9 +263,9 @@ class NewVM(uiutils.UITestCase): url = "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/10/Fedora/x86_64/os/" oslabel = "Fedora 10" - newvm.find("install-url-entry").text = url + newvm.find("install-url-entry").set_text(url) newvm.find("install-urlopts-expander").click_expander() - newvm.find("install-urlopts-entry").text = "foo=bar" + newvm.find("install-urlopts-entry").set_text("foo=bar") uiutils.check(lambda: osentry.text == oslabel, timeout=10) @@ -316,9 +316,8 @@ class NewVM(uiutils.UITestCase): newvm.find_fuzzy("Import", "radio").click() self.forward(newvm) - newvm.find_fuzzy(None, - "text", "existing storage").text = "/dev/default-pool/testvol1.img" - newvm.find("oslist-entry").text = "fedora30" + newvm.find("import-entry").set_text("/dev/default-pool/testvol1.img") + newvm.find("oslist-entry").set_text("fedora30") popover = newvm.find("oslist-popover") popover.find("include-eol").click() popover.find_fuzzy("Fedora 30").click() @@ -367,7 +366,7 @@ class NewVM(uiutils.UITestCase): newvm.find_fuzzy("Manual", "radio").click() self.forward(newvm) - newvm.find("oslist-entry").text = "generic" + newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm) self.forward(newvm) @@ -418,9 +417,9 @@ class NewVM(uiutils.UITestCase): self.forward(newvm) newvm.find_fuzzy("Automatically detect", "check").click() - newvm.find("oslist-entry").text = "generic" + newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() - newvm.find("media-entry").text = "/dev/default-pool/testvol1.img" + newvm.find("media-entry").set_text("/dev/default-pool/testvol1.img") self.forward(newvm) self.forward(newvm) newvm.find_fuzzy("Enable storage", "check box").click() @@ -460,17 +459,10 @@ class NewVM(uiutils.UITestCase): uiutils.check(lambda: importradio.checked) self.forward(newvm) - # Set the import media details - importentry = newvm.find_fuzzy(None, "text", "existing storage") - # For some reason 'Import' doesn't take effect sometimes - # And we end up in 'Manual' install mode, this will - # make it explicit when it fails - uiutils.check(lambda: importentry.onscreen) - - importentry.text = "/dev/default-pool/default-vol" + newvm.find("import-entry").set_text("/dev/default-pool/default-vol") # Make sure the info box shows up newvm.find("Kernel/initrd settings can be configured") - newvm.find("oslist-entry").text = "generic" + newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm, check=False) @@ -496,7 +488,7 @@ class NewVM(uiutils.UITestCase): # Set custom init apptext = newvm.find_fuzzy(None, "text", "application path") - apptext.text = "" + apptext.set_text("") self.forward(newvm, check=False) self._click_alert_button("path is required", "OK") newvm.find("install-app-browse").click() @@ -522,13 +514,13 @@ class NewVM(uiutils.UITestCase): details.find("Boot Options", "table cell").click() tab = details.find("boot-tab") tab.print_nodes() - tab.find("Init path:", "text").text = "" - tab.find("Init args:", "text").text = "some args" + tab.find("Init path:", "text").set_text("") + tab.find("Init args:", "text").set_text("some args") appl = details.find("config-apply") appl.click() self._click_alert_button("init path must be specified", "OK") uiutils.check(lambda: appl.sensitive) - tab.find("Init path:", "text").text = "/some/path" + tab.find("Init path:", "text").set_text("/some/path") appl.click() uiutils.check(lambda: not appl.sensitive) @@ -555,7 +547,7 @@ class NewVM(uiutils.UITestCase): newvm = self._open_create_wizard() newvm.find_fuzzy("Manual", "radio").click() self.forward(newvm) - newvm.find("oslist-entry").text = "generic" + newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm) self.forward(newvm) @@ -581,7 +573,7 @@ class NewVM(uiutils.UITestCase): newvm = self._open_create_wizard() newvm.find_fuzzy("Manual", "radio").click() self.forward(newvm) - newvm.find("oslist-entry").text = "generic" + newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm) self.forward(newvm) @@ -595,12 +587,12 @@ class NewVM(uiutils.UITestCase): # Test name change tab = details.find("overview-tab") nametext = tab.find("Name:", "text") - nametext.text = "foonewname" + nametext.set_text("foonewname") details.find("config-apply").click() self.app.root.find_fuzzy("foonewname", "frame") # Trigger XML failure to hit some codepaths - nametext.text = "" + nametext.set_text("") details.find("Begin Installation").click() self._click_alert_button("unapplied changes", "Yes") self._click_alert_button("name must be specified", "Close") @@ -626,7 +618,7 @@ class NewVM(uiutils.UITestCase): # Set directory path dirtext = newvm.find_fuzzy(None, "text", "root directory") - dirtext.text = "" + dirtext.set_text("") self.forward(newvm, check=False) self._click_alert_button("path is required", "OK") @@ -654,7 +646,7 @@ class NewVM(uiutils.UITestCase): # Set directory path newvm.find_fuzzy(None, - "text", "container template").text = "centos-6-x86_64" + "text", "container template").set_text("centos-6-x86_64") self.forward(newvm) self.forward(newvm) newvm.find_fuzzy("Finish", "button").click() @@ -680,9 +672,9 @@ class NewVM(uiutils.UITestCase): newvm.find_fuzzy("Create OS directory", "check box").click() rootdir = newvm.find_fuzzy(None, "text", "root directory") uiutils.check(lambda: ".local/share/libvirt" in rootdir.text) - rootdir.text = tmpdir.name - newvm.find("install-oscontainer-source-uri").text = "docker://alpine" - newvm.find("install-oscontainer-root-passwd").text = "foobar" + rootdir.set_text(tmpdir.name) + newvm.find("install-oscontainer-source-uri").set_text("docker://alpine") + newvm.find("install-oscontainer-root-passwd").set_text("foobar") self.forward(newvm) self.forward(newvm) newvm.find_fuzzy("Finish", "button").click() @@ -705,9 +697,8 @@ class NewVM(uiutils.UITestCase): newvm.find_fuzzy("Import", "radio").click() self.forward(newvm) - newvm.find_fuzzy(None, - "text", "existing storage").text = "/dev/default-pool/testvol1.img" - newvm.find("oslist-entry").text = "generic" + newvm.find("import-entry").set_text("/dev/default-pool/testvol1.img") + newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm) self.forward(newvm) @@ -722,14 +713,14 @@ class NewVM(uiutils.UITestCase): _newvm = self._open_create_wizard() _newvm.find_fuzzy("Manual", "radio").click() self.forward(_newvm) - _newvm.find("oslist-entry").text = "generic" + _newvm.find("oslist-entry").set_text("generic") _newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(_newvm) self.forward(_newvm) self.forward(_newvm) # '/' in name will trigger libvirt error - _newvm.find_fuzzy("Name", "text").text = "test/bad" + _newvm.find_fuzzy("Name", "text").set_text("test/bad") _newvm.find_fuzzy("Finish", "button").click() self._click_alert_button("Unable to complete install", "Close") return _newvm @@ -744,9 +735,9 @@ class NewVM(uiutils.UITestCase): newvm = dofail() self.back(newvm) newvm.find_fuzzy("Select or create", "radio").click() - newvm.find("storage-entry").text = "/dev/default-pool/somenewvol1" + newvm.find("storage-entry").set_text("/dev/default-pool/somenewvol1") self.forward(newvm) - newvm.find_fuzzy("Name", "text").text = "test-foo" + newvm.find_fuzzy("Name", "text").set_text("test-foo") newvm.find_fuzzy("Finish", "button").click() self.app.root.find_fuzzy("test-foo on", "frame") @@ -766,20 +757,20 @@ class NewVM(uiutils.UITestCase): newvm.find_fuzzy("Forward", "button").click() nonexistpath = "/dev/foovmm-idontexist" existpath = "/dev/default-pool/testvol1.img" - newvm.find("media-entry").text = nonexistpath + newvm.find("media-entry").set_text(nonexistpath) uiutils.check( lambda: newvm.find("oslist-entry").text == "None detected") newvm.find_fuzzy("Automatically detect", "check").click() - newvm.find("oslist-entry").text = "generic" + newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm, check=False) self._click_alert_button("Error setting installer", "OK") - newvm.find("media-entry").text = existpath + newvm.find("media-entry").set_text(existpath) self.forward(newvm) self.forward(newvm) self.forward(newvm) newvm.find_fuzzy("Customize", "check").click() - newvm.find_fuzzy("Name", "text").text = vmname + newvm.find_fuzzy("Name", "text").set_text(vmname) newvm.find_fuzzy("Finish", "button").click() # Change a VM setting and verify it @@ -791,8 +782,9 @@ class NewVM(uiutils.UITestCase): bootmenu = tab.find("Enable boot menu", "check box") uiutils.check(lambda: not bootmenu.checked) win.find("XML", "page tab").click() - xmleditor.text = xmleditor.text.replace( + newtext = xmleditor.text.replace( "", "") + xmleditor.set_text(newtext) finish.click() win.find("Details", "page tab").click() uiutils.check(lambda: bootmenu.checked) @@ -804,7 +796,7 @@ class NewVM(uiutils.UITestCase): newbrname = "BRFAKE" newx = xmleditor.text.replace("network", "bridge") newx = newx.replace('bridge="default"', "bridge='%s'" % newbrname) - xmleditor.text = newx + xmleditor.set_text(newx) finish.click() # Finish install. @@ -851,14 +843,14 @@ class NewVM(uiutils.UITestCase): newvm.find_fuzzy("Import", "radio").click() self.forward(newvm) - importtext = newvm.find_fuzzy(None, "text", "existing storage") + importtext = newvm.find("import-entry") # Click forward, hitting missing OS error self.forward(newvm, check=False) self._click_alert_button("select an OS", "OK") # Set OS - newvm.find("oslist-entry").text = "generic" + newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() # Click forward, hitting missing Import path error @@ -866,12 +858,12 @@ class NewVM(uiutils.UITestCase): self._click_alert_button("import is required", "OK") # Click forward, but Import path doesn't exist - importtext.text = "/dev/default-pool/idontexist" + importtext.set_text("/dev/default-pool/idontexist") self.forward(newvm, check=False) self._click_alert_button("import path must point", "OK") # Click forward, but Import path is in use, and exit - importtext.text = "/dev/default-pool/default-vol" + importtext.set_text("/dev/default-pool/default-vol") self.forward(newvm, check=False) self._click_alert_button("in use", "No") @@ -905,10 +897,9 @@ class NewVM(uiutils.UITestCase): newvm = self._open_create_wizard() newvm.find_fuzzy("Import", "radio").click() - newvm.find_fuzzy(None, - "text", "existing storage").text = "/dev/default-pool/testvol1.img" self.forward(newvm) - newvm.find("oslist-entry").text = "generic" + newvm.find("import-entry").set_text("/dev/default-pool/testvol1.img") + newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm) self.forward(newvm) @@ -926,17 +917,16 @@ class NewVM(uiutils.UITestCase): newvm = self._open_create_wizard() newvm.find_fuzzy("Import", "radio").click() - newvm.find_fuzzy(None, - "text", "existing storage").text = __file__ self.forward(newvm) - newvm.find("oslist-entry").text = "generic" + newvm.find("import-entry").set_text(__file__) + newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm) self.forward(newvm) 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" + newvm.find("Device name:", "text").set_text("foobr0") # Select customize wizard, we will use this VM to hit specific # code paths @@ -977,10 +967,9 @@ class NewVM(uiutils.UITestCase): newvm = self._open_create_wizard() newvm.find_fuzzy("Import", "radio").click() - newvm.find_fuzzy(None, - "text", "existing storage").text = __file__ self.forward(newvm) - newvm.find("oslist-entry").text = "generic" + newvm.find("import-entry").set_text(__file__) + newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm) self.forward(newvm) @@ -999,10 +988,9 @@ class NewVM(uiutils.UITestCase): newvm = self._open_create_wizard() newvm.find_fuzzy("Import", "radio").click() - newvm.find_fuzzy(None, - "text", "existing storage").text = __file__ self.forward(newvm) - newvm.find("oslist-entry").text = "generic" + newvm.find("import-entry").set_text(__file__) + newvm.find("oslist-entry").set_text("generic") newvm.find("oslist-popover").find_fuzzy("generic").click() self.forward(newvm) self.forward(newvm) diff --git a/tests/uitests/test_createvol.py b/tests/uitests/test_createvol.py index 32051eee8..f1ed0e444 100644 --- a/tests/uitests/test_createvol.py +++ b/tests/uitests/test_createvol.py @@ -36,8 +36,8 @@ class CreateVol(uiutils.UITestCase): # Create a default qcow2 volume uiutils.check(lambda: name.text == "vol") newname = "a-newvol" - name.text = newname - win.find("Max Capacity:", "spin button").text = "10.5" + name.set_text(newname) + win.find("Max Capacity:", "spin button").set_text("10.5") finish.click() # Delete it, clicking 'No' first @@ -70,7 +70,7 @@ class CreateVol(uiutils.UITestCase): # Create a qcow2 with backing file newname = "aaa-qcow2-backing.qcow2" - name.text = newname + name.set_text(newname) win.combo_select("Format:", "qcow2") win.find("Backing store").click_expander() win.find("Browse...").click() @@ -95,19 +95,19 @@ class CreateVol(uiutils.UITestCase): # Create a raw volume with some size tweaking win = self._open_create_win(hostwin) # Using previous name so we collide - name.text = newname + name.set_text(newname) win.combo_select("Format:", "raw") cap = win.find("Max Capacity:", "spin button") alloc = win.find("Allocation:", "spin button") - alloc.text = "50.0" + alloc.set_text("50.0") alloc.click() self.pressKey("Enter") uiutils.check(lambda: cap.text == "50.0") - cap.text = "1.0" + cap.set_text("1.0") cap.click() self.pressKey("Enter") uiutils.check(lambda: alloc.text == "1.0") - alloc.text = "0.5" + alloc.set_text("0.5") alloc.click() self.pressKey("Enter") uiutils.check(lambda: cap.text == "1.0") @@ -115,7 +115,7 @@ class CreateVol(uiutils.UITestCase): finish.click() self._click_alert_button("Error validating volume", "Close") newname = "a-newvol.raw" - name.text = newname + name.set_text(newname) finish.click() vollist.find(newname) @@ -123,7 +123,7 @@ class CreateVol(uiutils.UITestCase): hostwin.find("disk-pool", "table cell").click() win = self._open_create_win(hostwin) newname = "aaa-lvm" - name.text = newname + name.set_text(newname) win.find("Backing store").click_expander() win.find("Browse...").click() self._select_storagebrowser_volume("disk-pool", "diskvol7") @@ -144,11 +144,12 @@ class CreateVol(uiutils.UITestCase): # Create a new obj with XML edited name, verify it worked tmpname = "objtmpname" newname = "aafroofroo" - name.text = tmpname + name.set_text(tmpname) win.find("XML", "page tab").click() xmleditor = win.find("XML editor") - xmleditor.text = xmleditor.text.replace( - ">%s.qcow2<" % tmpname, ">%s<" % newname) + newtext = xmleditor.text.replace( + ">%s.qcow2<" % tmpname, ">%s<" % newname) + xmleditor.set_text(newtext) finish.click() uiutils.check(lambda: hostwin.active) vollist.find(newname) diff --git a/tests/uitests/test_details.py b/tests/uitests/test_details.py index b52872289..c828088c1 100644 --- a/tests/uitests/test_details.py +++ b/tests/uitests/test_details.py @@ -66,7 +66,7 @@ class Details(uiutils.UITestCase): win.find("Overview", "table cell").click() oldcell = self.app.root.find_fuzzy(origname, "table cell") - win.find("Name:", "text").text = newname + win.find("Name:", "text").set_text(newname) win.find("config-apply", "push button").click() # Confirm lists were updated @@ -117,7 +117,7 @@ class Details(uiutils.UITestCase): # Make a change and then trigger unapplied change warning tab = self._select_hw(win, "Overview", "overview-tab") - tab.find("Name:", "text").text = "" + tab.find("Name:", "text").set_text("") uiutils.check(lambda: appl.sensitive) run = win.find("Run", "push button") run.click() @@ -152,8 +152,8 @@ class Details(uiutils.UITestCase): # Overview description tab = self._select_hw(win, "Overview", "overview-tab") - tab.find("Description:", "text").text = "hey new description" - tab.find("Title:", "text").text = "hey new title" + tab.find("Description:", "text").set_text("hey new description") + tab.find("Title:", "text").set_text("hey new title") appl.click() uiutils.check(lambda: not appl.sensitive) @@ -162,7 +162,7 @@ class Details(uiutils.UITestCase): # Memory tab = self._select_hw(win, "Memory", "memory-tab") - tab.find("Memory allocation:", "spin button").text = "300" + tab.find("Memory allocation:", "spin button").set_text("300") appl.click() uiutils.check(lambda: not appl.sensitive) @@ -185,18 +185,18 @@ class Details(uiutils.UITestCase): appl.click() uiutils.check(lambda: not appl.sensitive) copyhost = tab.find("Copy host", "check box") - uiutils.check(lambda: copyhost.selected) + uiutils.check(lambda: copyhost.checked) copyhost.click() tab.find("cpu-model").click_combo_entry() tab.find("Hypervisor Default", "menu item").click() appl.click() uiutils.check(lambda: not appl.sensitive) - tab.find("cpu-model").text = "host-passthrough" + tab.find("cpu-model").find(None, "text").text = "host-passthrough" appl.click() uiutils.check(lambda: not appl.sensitive) # vCPUs - tab.find("vCPU allocation:", "spin button").text = "50" + tab.find("vCPU allocation:", "spin button").set_text("50") appl.click() uiutils.check(lambda: not appl.sensitive) @@ -238,7 +238,7 @@ class Details(uiutils.UITestCase): self.pressKey("Down") popover = win.find("oslist-popover") popover.find("include-eol").click() - entry.text = "fedora12" + entry.set_text("fedora12") popover.find_fuzzy("fedora12").bring_on_screen().click() uiutils.check(lambda: not popover.visible) uiutils.check(lambda: entry.text == "Fedora 12") @@ -257,13 +257,14 @@ class Details(uiutils.UITestCase): dogtail.rawinput.click(x, y, button) tab = self._select_hw(win, "Boot Options", "boot-tab") - self._stop_vm(win) tab.find_fuzzy("Start virtual machine on host", "check box").click() tab.find("Enable boot menu", "check box").click() - check_bootorder(tab.find("SCSI Disk 1", "table cell")) + tab.find("SCSI Disk 1", "table cell").click() tab.find("boot-movedown", "push button").click() tab.find("Floppy 1", "table cell").click() tab.find("boot-moveup", "push button").click() + check_bootorder(tab.find("NIC :33:44", "table cell")) + check_bootorder(tab.find("PCI 0003:", "table cell")) appl.click() uiutils.check(lambda: not appl.sensitive) @@ -271,7 +272,7 @@ class Details(uiutils.UITestCase): tab.find_fuzzy("Direct kernel boot", "toggle button").click_expander() tab.find_fuzzy("Enable direct kernel", "check box").click() - tab.find("Kernel args:", "text").text = "console=ttyS0" + tab.find("Kernel args:", "text").set_text("console=ttyS0") appl.click() self._click_alert_button("arguments without specifying", "OK") uiutils.check(lambda: win.active) @@ -322,9 +323,9 @@ class Details(uiutils.UITestCase): tab.find("Shareable:", "check box").click() tab.find("Readonly:", "check box").click() tab.find("Advanced options", "toggle button").click_expander() - tab.find("Cache mode:", "text").text = "unsafe" - tab.find("Discard mode:", "text").text = "unmap" - tab.find("Detect zeroes:", "text").text = "unmap" + tab.find("Cache mode:", "text").set_text("unsafe") + tab.find("Discard mode:", "text").set_text("unmap") + tab.find("Detect zeroes:", "text").set_text("unmap") appl.click() uiutils.check(lambda: not appl.sensitive) @@ -337,7 +338,7 @@ class Details(uiutils.UITestCase): self.pressKey("Home") tab.find_fuzzy("Macvtap device...", "menu item").bring_on_screen().click() - tab.find("Device name:", "text").text = "fakedev12" + tab.find("Device name:", "text").set_text("fakedev12") tab.combo_select("Device model:", "rtl8139") tab.find("Link state:", "check box").click() appl.click() @@ -347,11 +348,11 @@ class Details(uiutils.UITestCase): src.click() tab.find_fuzzy("Bridge device...", "menu item").bring_on_screen().click() - tab.find("Device name:", "text").text = "" + tab.find("Device name:", "text").set_text("") appl.click() # Check validation error self._click_alert_button("Error changing VM configuration", "Close") - tab.find("Device name:", "text").text = "zbr0" + tab.find("Device name:", "text").set_text("zbr0") appl.click() uiutils.check(lambda: not appl.sensitive) @@ -381,7 +382,7 @@ class Details(uiutils.UITestCase): tab.combo_select("Type:", "VNC") tab.combo_select("Listen type:", "Address") tab.find("graphics-port-auto", "check").click() - tab.find("graphics-port", "spin button").text = "6001" + tab.find("graphics-port", "spin button").set_text("6001") tab.find("Password:", "check").click() passwd = tab.find_fuzzy("graphics-password", "text") newpass = "foobar" @@ -391,7 +392,7 @@ class Details(uiutils.UITestCase): # Sound device tab = self._select_hw(win, "Sound sb16", "sound-tab") - tab.find("Model:", "text").text = "ac97" + tab.find("Model:", "text").set_text("ac97") appl.click() uiutils.check(lambda: not appl.sensitive) # Test non-disk removal @@ -415,7 +416,7 @@ class Details(uiutils.UITestCase): # Video device tab = self._select_hw(win, "Video VMVGA", "video-tab") - tab.find("Model:", "text").text = "virtio" + tab.find("Model:", "text").set_text("virtio") tab.find("3D acceleration:", "check box").click() appl.click() uiutils.check(lambda: not appl.sensitive) @@ -423,7 +424,7 @@ class Details(uiutils.UITestCase): # Watchdog tab = self._select_hw(win, "Watchdog", "watchdog-tab") - tab.find("Model:", "text").text = "diag288" + tab.find("Model:", "text").set_text("diag288") tab.find("Action:", "text").click() self.pressKey("Down") appl.click() @@ -458,8 +459,8 @@ class Details(uiutils.UITestCase): tab = self._select_hw(win, "Filesystem /target/", "filesystem-tab") 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("Source path:", "text").set_text("/frib1") + tab.find("Target path:", "text").set_text("newtarget") tab.find_fuzzy("Export filesystem", "check box").click() appl.click() uiutils.check(lambda: not appl.sensitive) @@ -482,7 +483,7 @@ class Details(uiutils.UITestCase): addr = tab.find("vsock-cid") auto = tab.find("vsock-auto") uiutils.check(lambda: addr.text == "5") - addr.text = "7" + addr.set_text("7") appl.click() uiutils.check(lambda: addr.text == "7") uiutils.check(lambda: not appl.sensitive) @@ -524,9 +525,7 @@ class Details(uiutils.UITestCase): # Attempt to apply changes when skipping away, but they fail tab.find("Advanced options", "toggle button").click_expander() - cacheui = tab.find("Cache mode:", "text") - origcache = cacheui.text - cacheui.text = "badcachemode" + tab.find("Cache mode:", "text").set_text("badcachemode") hwlist.find("CPUs", "table cell").click() self._click_alert_button("There are unapplied changes", "Yes") self._click_alert_button("badcachemode", "Close") @@ -577,7 +576,7 @@ class Details(uiutils.UITestCase): # Unapplied changes should warn when switching to XML tab tab = self._select_hw(win, "Overview", "overview-tab") - tab.find("Description:", "text").text = "hey new description" + tab.find("Description:", "text").set_text("hey new description") win.find("XML", "page tab").click() # Select 'No', meaning don't abandon changes self._click_alert_button("changes will be lost", "No") @@ -589,7 +588,7 @@ class Details(uiutils.UITestCase): uiutils.check(lambda: not tab.showing) # Verify addhardware right click works - cell = win.find("Overview", "table cell").click(button=3) + win.find("Overview", "table cell").click(button=3) self.app.root.find("Add Hardware", "menu item").click() self.app.root.find("Add New Virtual Hardware", "frame") @@ -605,7 +604,7 @@ class Details(uiutils.UITestCase): # Edit vcpu count and verify it's reflected in CPU page tab = self._select_hw(win, "CPUs", "cpu-tab") win.find("XML", "page tab").click() - xmleditor.text = xmleditor.text.replace(">5858F4") detailswin.click() - xmleditor.text = xmleditor.text.replace(">", - ">FOOTITLE", 1) + newtext = xmleditor.text.replace(">", ">FOOTITLE", 1) + xmleditor.set_text(newtext) finish.click() detailswin.find("Details", "page tab").click() uiutils.check(lambda: diff --git a/tests/uitests/test_snapshot.py b/tests/uitests/test_snapshot.py index d6aff97fb..1a97268f7 100644 --- a/tests/uitests/test_snapshot.py +++ b/tests/uitests/test_snapshot.py @@ -64,13 +64,13 @@ class Snapshots(uiutils.UITestCase): # Edit snapshot descui = win.find("snapshot-description") desc = "TESTSNAP" - descui.text = desc + descui.set_text(desc) win.find("snapshot-apply", "push button").click() win.find("snapshot-refresh", "push button").click() uiutils.check(lambda: descui.text == desc) # Apply by clicking away desc += " ROUND2" - descui.text = desc + descui.set_text(desc) win.find("internal-root", "table cell").click() self._click_alert_button("There are unapplied changes", "Yes") @@ -78,8 +78,8 @@ class Snapshots(uiutils.UITestCase): win.find("snapshot-add", "push button").click() newwin = self.app.root.find("Create snapshot", "frame") snapname = "testnewsnap" - newwin.find("Name:", "text").text = snapname - newwin.find("Description:", "text").text = "testdesc" + newwin.find("Name:", "text").set_text(snapname) + newwin.find("Description:", "text").set_text("testdesc") newwin.find("Finish", "push button").click() uiutils.check(lambda: not newwin.showing) newc = win.find(snapname, "table cell") @@ -97,7 +97,7 @@ class Snapshots(uiutils.UITestCase): win.find("snapshot-add", "push button").click() newwin = self.app.root.find("Create snapshot", "frame") snapname = "testnewsnap" - newwin.find("Name:", "text").text = snapname + newwin.find("Name:", "text").set_text(snapname) newwin.find("Finish", "push button").click() uiutils.check(lambda: not newwin.showing) newc = win.find(snapname, "table cell") @@ -128,7 +128,7 @@ class Snapshots(uiutils.UITestCase): self._click_alert_button("not become part of the snapshot", "OK") newwin = self.app.root.find("Create snapshot", "frame") snapname1 = "testnewsnap1" - newwin.find("Name:", "text").text = snapname1 + newwin.find("Name:", "text").set_text(snapname1) newwin.find("Finish", "push button").click() uiutils.check(lambda: not newwin.showing) newc = win.find(snapname1, "table cell") @@ -140,16 +140,16 @@ class Snapshots(uiutils.UITestCase): win.find("snapshot-add", "push button").click() newwin = self.app.root.find("Create snapshot", "frame") # Force validation error - newwin.find("Name:", "text").text = "bad name" + newwin.find("Name:", "text").set_text("bad name") newwin.find("Finish", "push button").click() self._click_alert_button("validating snapshot", "OK") # Force name collision - newwin.find("Name:", "text").text = snapname1 + newwin.find("Name:", "text").set_text(snapname1) newwin.find("Finish", "push button").click() self._click_alert_button(snapname1, "Close") # Make it succeed snapname2 = "testnewsnap2" - newwin.find("Name:", "text").text = snapname2 + newwin.find("Name:", "text").set_text(snapname2) newwin.find("Finish", "push button").click() uiutils.check(lambda: not newwin.showing) newc = win.find(snapname2, "table cell") diff --git a/tests/uitests/utils.py b/tests/uitests/utils.py index 54cc0df22..7c58b183b 100644 --- a/tests/uitests/utils.py +++ b/tests/uitests/utils.py @@ -161,7 +161,7 @@ class UITestCase(unittest.TestCase): # Click the tab, make a bogus XML edit win.find("XML", "page tab").click() xmleditor = win.find("XML editor") - xmleditor.text = xmleditor.text.replace("<", "= 0 and self.position[1] + self.size[1] < screen.get_height()) + def check_onscreen(self): + """ + Check in a loop that the widget is onscreen + """ + check(lambda: self.onscreen) + + def check_sensitive(self): + """ + Check whether interactive widgets are sensitive or not + """ + valid_types = [ + "push button", + "toggle button", + "check button", + "combo box", + "menu item", + "text", + "menu", + ] + if self.roleName not in valid_types: + return True + check(lambda: self.sensitive) + def click_secondary_icon(self): """ Helper for clicking the secondary icon of a text entry """ + self.check_onscreen() + self.check_sensitive() button = 1 clickX = self.position[0] + self.size[0] - 10 clickY = self.position[1] + (self.size[1] / 2) @@ -318,6 +343,8 @@ class VMMDogtailNode(dogtail.tree.Node): Using a small, hardcoded offset may not work on some themes (e.g. when running virt-manager on KDE) """ + self.check_onscreen() + self.check_sensitive() button = 1 clickX = self.position[0] + self.size[0] - self.size[1] / 4 clickY = self.position[1] + self.size[1] / 2 @@ -328,6 +355,8 @@ class VMMDogtailNode(dogtail.tree.Node): Helper for clicking expander, hitting the text part to actually open it. Basically clicks top left corner with some indent """ + self.check_onscreen() + self.check_sensitive() button = 1 clickX = self.position[0] + 10 clickY = self.position[1] + 5 @@ -351,9 +380,16 @@ class VMMDogtailNode(dogtail.tree.Node): screen, helps reduce some test flakiness """ # pylint: disable=arguments-differ,signature-differs - check(lambda: self.onscreen) + self.check_onscreen() + self.check_sensitive() dogtail.tree.Node.click(self, *args, **kwargs) + def set_text(self, text): + self.check_onscreen() + self.check_sensitive() + assert hasattr(self, "text") + self.text = text + def bring_on_screen(self, key_name="Down", max_tries=100): """ Attempts to bring the item to screen by repeatedly clicking the given diff --git a/ui/createvm.ui b/ui/createvm.ui index 879d43264..8b9ff045e 100644 --- a/ui/createvm.ui +++ b/ui/createvm.ui @@ -1078,6 +1078,11 @@ User shouldn't see this. True True + + + import-entry + + True