uitests: Use drag() method again for window cleanup tests

delete and createvm tests launch a dialog which obstructs the
manager UI. The location can be kinda random, and it might obstruct
selecting the connection in the manager window. Go back to using
the drag() window pattern to make this more deterministic

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-09-21 21:29:00 -04:00
parent 9a5ab50b51
commit 12fe58cd91
4 changed files with 23 additions and 17 deletions

View File

@ -38,10 +38,11 @@ class VMMDogtailApp(object):
def sleep(self, *args, **kwargs): def sleep(self, *args, **kwargs):
return time.sleep(*args, **kwargs) return time.sleep(*args, **kwargs)
def find_window(self, name, roleName=None): def find_window(self, name, roleName=None, check_active=True):
if roleName is None: if roleName is None:
roleName = "(frame|dialog|alert|window)" roleName = "(frame|dialog|alert|window)"
return self.root.find(name=name, roleName=roleName, recursive=False) return self.root.find(name=name, roleName=roleName,
recursive=False, check_active=check_active)
rawinput = dogtail.rawinput rawinput = dogtail.rawinput
tree = dogtail.tree tree = dogtail.tree
@ -51,9 +52,10 @@ class VMMDogtailApp(object):
# virt-manager specific helpers # # virt-manager specific helpers #
################################# #################################
def get_manager(self): def get_manager(self, check_active=True):
if not self._manager: if not self._manager:
self._manager = self.find_window("Virtual Machine Manager") self._manager = self.find_window("Virtual Machine Manager",
check_active=check_active)
return self._manager return self._manager
def find_details_window(self, vmname, def find_details_window(self, vmname,
@ -115,15 +117,19 @@ class VMMDogtailApp(object):
def manager_conn_disconnect(self, conn_label): def manager_conn_disconnect(self, conn_label):
c = self.manager_get_conn_cell(conn_label) c = self.manager_get_conn_cell(conn_label)
c.click()
utils.check(lambda: c.state_selected)
c.click(button=3) c.click(button=3)
self.root.find("conn-disconnect", "menu item").click() menu = self.root.find("conn-menu", "menu")
menu.find("conn-disconnect", "menu item").click()
utils.check(lambda: "Not Connected" in c.text) utils.check(lambda: "Not Connected" in c.text)
return c return c
def manager_conn_delete(self, conn_label): def manager_conn_delete(self, conn_label):
c = self.manager_get_conn_cell(conn_label) c = self.manager_get_conn_cell(conn_label)
c.click(button=3) c.click(button=3)
self.root.find("conn-delete", "menu item").click() menu = self.root.find("conn-menu", "menu")
menu.find("conn-delete", "menu item").click()
self.click_alert_button("will remove the connection", "Yes") self.click_alert_button("will remove the connection", "Yes")
utils.check(lambda: c.dead) utils.check(lambda: c.dead)
@ -212,6 +218,14 @@ class VMMDogtailApp(object):
win.find_fuzzy(tab, "page tab").click() win.find_fuzzy(tab, "page tab").click()
return win return win
def manager_test_conn_window_cleanup(self, conn_label, childwin):
# Give time for the child window to appear and possibly grab focus
self.sleep(1)
self.get_manager(check_active=False)
dogtail.rawinput.drag(childwin.title_coordinates(), (1000, 1000))
self.manager_conn_disconnect(conn_label)
utils.check(lambda: not childwin.showing)
########################### ###########################
# Process management APIs # # Process management APIs #

View File

@ -1190,13 +1190,8 @@ def testNewVMSession(app):
details.window_close() details.window_close()
# Ensure disconnecting will close the dialog # Ensure disconnecting will close the dialog
manager = app.topwin
manager.window_maximize()
newvm = _open_newvm(app) newvm = _open_newvm(app)
app.sleep(.5) # newvm focus grab avoidance app.manager_test_conn_window_cleanup(".*session.*", newvm)
manager.grab_focus()
app.manager_conn_disconnect(".*session.*")
lib.utils.check(lambda: not newvm.showing)
def testNewVMEmptyConn(app): def testNewVMEmptyConn(app):

View File

@ -176,12 +176,8 @@ def testDeleteFailure(app, tmppath):
app.click_alert_button("Errors encountered", "Close") app.click_alert_button("Errors encountered", "Close")
# Ensure disconnecting will close the dialog # Ensure disconnecting will close the dialog
manager = app.topwin
manager.window_maximize()
win = _open_delete(app, "test-clone") win = _open_delete(app, "test-clone")
manager.click_title() app.manager_test_conn_window_cleanup("test testdriver.xml", win)
app.manager_conn_disconnect("test testdriver.xml")
lib.utils.check(lambda: not win.showing)
def testDeleteRemoteManyDevices(app): def testDeleteRemoteManyDevices(app):

View File

@ -98,6 +98,7 @@ class vmmManager(vmmGObjectUI):
self.vmmenu = vmmenu.VMActionMenu(self, self.current_vm) self.vmmenu = vmmenu.VMActionMenu(self, self.current_vm)
self.shutdownmenu = vmmenu.VMShutdownMenu(self, self.current_vm) self.shutdownmenu = vmmenu.VMShutdownMenu(self, self.current_vm)
self.connmenu = Gtk.Menu() self.connmenu = Gtk.Menu()
self.connmenu.get_accessible().set_name("conn-menu")
self.connmenu_items = {} self.connmenu_items = {}
self.builder.connect_signals({ self.builder.connect_signals({