[gnome-boxes] tests: Better handle case of multiple windows
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] tests: Better handle case of multiple windows
- Date: Mon, 2 Feb 2015 13:50:36 +0000 (UTC)
commit 14aaad5a52f7067ac839db7465bebb52b0dd7407
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sun Feb 1 13:49:29 2015 +0000
tests: Better handle case of multiple windows
We were using some magic code to focus secondary windows. Not only was
it not working on 3.15 branch, we don't need this magic anymore now that
we ensure each window gets it's accessible-name properly set.
tests/steps/multi-window.py | 83 +++++++++++++------------------------------
1 files changed, 25 insertions(+), 58 deletions(-)
---
diff --git a/tests/steps/multi-window.py b/tests/steps/multi-window.py
index 3a6d7b7..c38dc7e 100644
--- a/tests/steps/multi-window.py
+++ b/tests/steps/multi-window.py
@@ -7,77 +7,44 @@ from dogtail import predicate
from time import sleep
from utils import get_showing_node_rolename, get_showing_node_name
+def find_window(context, name):
+ target = None
+ for window in context.app.children:
+ if window.name == name:
+ target = window
+
+ break
+
+ if target == None:
+ raise Exception("Window for %s was not found" %vm_name)
+
+ return target
+
@step('Focus "{window}" window')
def focus_window(context, window):
if window == 'main':
context.app.findChildren(lambda x: x.name == 'New' and x.showing and x.sensitive)[0].grabFocus()
else:
- cores = context.app.findChildren(lambda x: x.name == window)
- main = context.app.children[0]
- for core in cores:
- frame = core.findAncestor(predicate.GenericPredicate(name='Boxes', roleName='frame'))
- if frame != main:
- core.grabFocus()
- sleep(0.5)
- pressKey('Tab')
- sleep(0.5)
+ core = find_window(context, window)
+ button = core.findChildren(lambda x: x.roleName == 'toggle button' and x.showing)[1]
+ button.grabFocus()
+ sleep(0.5)
+ pressKey('Tab')
+ sleep(0.5)
@step('Open "{vm_names_list}" in new windows')
def open_new_windows(context, vm_names_list):
- vm_names = vm_names_list.split(',')
- names = []
- for name in vm_names:
- names.append(name.strip())
+ vm_names = vm_names_list.split(', ')
- if len(names) == 1:
+ if len(vm_names) == 1:
button = 'Open in new window'
else:
- button = "Open in %s new windows" %len(names)
+ button = "Open in %s new windows" %len(vm_names)
# Click open in new windows
context.app.findChildren(lambda x: x.name == button and x.showing and x.sensitive)[0].click()
sleep(3)
- # Have to go to every single prefs to allow focusing, this can be done just from main window (grabFocus
to main)
- boxes = context.app.findChildren(lambda x: x.name == 'Boxes')
-
- # For each window (aka box)
- for box in boxes:
- if box == context.app.children[0]:
- continue
- # Find New button
- context.app.findChildren(lambda x: x.name == 'New' and x.showing)[0].grabFocus()
- # Find pane which contains icons with box name as text property
- pane = context.app.children[0].child(roleName='layered pane')
- vm = names.pop()
- for icon in pane.children:
- # Icon has text property equal to box name we've found it
- if icon.text == vm:
- # Click that icon
- icon.click()
- sleep(1)
- break
- # Locate visible panel of single box
- panel = box.children[0].findChildren(lambda x: x.roleName == 'panel' and x.showing)[0]
- # Locate preference button and click it
- buttons = panel.findChildren(lambda x: x.roleName == 'push button' \
- and not x.name and x.showing and x.sensitive)
- buttons[0].click()
-
- timer = 0
- # Wait up to 5 seconds for panel with Back button to appear
- while True:
- sleep(1)
- box_panel = get_showing_node_rolename('panel', box.children[0])
- if box_panel != panel:
- break
- timer += 1
- if timer == 5:
- raise Exception("Timeout: Back button's panel wasn't found showing")
-
- # Locate visible panel again
- panel = box.children[0].findChildren(lambda x: x.roleName == 'panel' and x.showing)[0]
- # Wait for back button to be shown
-
- get_showing_node_name('Back', panel).click()
- sleep(1)
+ for vm_name in vm_names:
+ # Ensure we have a window for each box
+ find_window(context, vm_name)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]