[gnome-boxes] Add multi-windows tests



commit 9a4b1732287a4de933bec5908ae3737d5f15a13d
Author: Vladimir Benes <vbenes redhat com>
Date:   Tue Jan 6 09:33:20 2015 -0500

    Add multi-windows tests
    
    Switching between windows was quite tough as boxes name widgets are not
    visible to dogtail until you go to preferences. So clicking through
    machines' preferences is done just after opening new windows.
    
    Coverage:
     * open in new window
     * poweroff in new window
     * open 3 new windows
    
    https://bugzilla.gnome.org/review?bug=736288

 Makefile.am                 |    1 +
 tests/README                |    3 ++
 tests/multi-windows.feature |   50 ++++++++++++++++++++++++++
 tests/steps/multi-window.py |   82 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 136 insertions(+), 0 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 6ea3788..04d1516 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -78,6 +78,7 @@ INSTALLED_TESTS=                              \
        general.feature                         \
        import-vms.feature                      \
        livecd.feature                          \
+       multi-windows.feature                   \
        $(NULL)
 INSTALLED_TESTS_TYPE=session-exclusive
 -include $(top_srcdir)/git.mk
diff --git a/tests/README b/tests/README
index ffd46af..41ad1e7 100644
--- a/tests/README
+++ b/tests/README
@@ -24,6 +24,9 @@ Structure
     * delete/undo
     * poweroff/pause/resume
     * force shutdown
+  * multi-windows.feature
+    * open one/several new windows
+    * poweroff in new window
 * Environment file
   * everything for setting/cleaning up the environment
 * Steps
diff --git a/tests/multi-windows.feature b/tests/multi-windows.feature
new file mode 100644
index 0000000..e3d669c
--- /dev/null
+++ b/tests/multi-windows.feature
@@ -0,0 +1,50 @@
+Feature: Multi Window
+
+  Background:
+    * Make sure that gnome-boxes is running
+    * Wait until overview is loaded
+
+  @open_in_new_window
+  Scenario: Open box in new window
+    * Initiate new box "Core-5" installation
+    * Select "Core-5" box
+    * Press "Open in new window"
+    * Wait for "sleep 2" end
+    Then Boxes app has "2" windows
+    Then Verify back button "is not" visible for machine "Core-5"
+
+  @poweroff_in_new_window
+  Scenario: Poweroff in new window
+    * Create new box "Core-5"
+    * Select "Core-5" box
+    * Press "Open in new window"
+    * Wait for "sleep 2" end
+    * Type "sudo poweroff"
+    * Wait for "sleep 20" end
+    Then Boxes app has "1" windows
+
+  @open_three_new_windows
+  Scenario: Open three new windows
+    * Create new box "Core-5"
+    * Create new box "Core-5"
+    * Create new box "Core-5"
+    * Select "Core-5" box
+    * Select "Core-5 2" box
+    * Select "Core-5 3" box
+    * Open "Core-5, Core-5 2, Core-5 3" in new windows
+    Then Boxes app has "4" windows
+    Then Verify back button "is not" visible for machine "Core-5"
+    Then Verify back button "is not" visible for machine "Core-5 2"
+    Then Verify back button "is not" visible for machine "Core-5 3"
+    When Ping "Core-5"
+    When Ping "Core-5 2"
+    When Ping "Core-5 3"
+    * Focus "Core-5" window
+    * Type "sudo ifconfig eth0 down"
+    * Focus "Core-5 2" window
+    * Type "sudo ifconfig eth0 down"
+    * Focus "Core-5 3" window
+    * Type "sudo ifconfig eth0 down"
+    Then Cannot ping "Core-5"
+    Then Cannot ping "Core-5 2"
+    Then Cannot ping "Core-5 3"
diff --git a/tests/steps/multi-window.py b/tests/steps/multi-window.py
new file mode 100644
index 0000000..e35252f
--- /dev/null
+++ b/tests/steps/multi-window.py
@@ -0,0 +1,82 @@
+# -*- coding: UTF-8 -*-
+
+from behave import step
+from dogtail.rawinput import pressKey
+from dogtail import predicate
+from time import sleep
+from utils import get_showing_node_rolename, get_showing_node_name
+
+ step(u'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)
+
+ step(u'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())
+
+    if len(names) == 1:
+        button = 'Open in new window'
+    else:
+        button = "Open in %s new windows" %len(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)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]