[gnome-boxes/wip/automated-tests: 21/21] tmp



commit bed99277c57ac04eb9b772c558615a212220f949
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sat Jan 31 10:26:43 2015 +0000

    tmp

 tests/general.feature       |   12 +++---
 tests/livecd.feature        |   32 ++++++++--------
 tests/multi-windows.feature |    4 +-
 tests/snapshots.feature     |    5 ++-
 tests/steps/creation.py     |   37 ++++++++++++++-----
 tests/steps/general.py      |   15 ++++----
 tests/steps/multi-window.py |   84 +++++++++++++-----------------------------
 tests/steps/snapshot.py     |    8 ++---
 tests/system-broker.feature |    8 ++--
 tests/vnc.feature           |    2 +-
 10 files changed, 96 insertions(+), 111 deletions(-)
---
diff --git a/tests/general.feature b/tests/general.feature
index b56c60b..ec332e9 100644
--- a/tests/general.feature
+++ b/tests/general.feature
@@ -41,7 +41,7 @@ Feature: General
     * Wait for "sleep 10" end
     * Hit "Enter"
     * Save IP for machine "Core-5"
-    * Press "back" in vm
+    * Press "back" in "Core-5" vm
     Then Box "Core-5" "does" exist
     Then Ping "Core-5"
 
@@ -59,7 +59,7 @@ Feature: General
     * Select "Core-5" box
     * Press "Properties"
     * Rename "Core-5" to "Kernel-6" via "button"
-    * Press "Back"
+    * Hit "Esc"
     * Quit Boxes
     * Start Boxes
     Then Box "Kernel-6" "does" exist
@@ -70,7 +70,7 @@ Feature: General
     * Select "Core-5" box
     * Press "Properties"
     * Rename "Core-5" to "Kernel-6" via "label"
-    * Press "Back"
+    * Hit "Esc"
     * Quit Boxes
     * Start Boxes
     Then Box "Kernel-6" "does" exist
@@ -88,7 +88,7 @@ Feature: General
   @search_via_shortcut
   Scenario: Search via shotcut
     * Initiate new box "Core-5" installation
-    * Initiate new box "Core-5" installation
+    * Initiate new box "Core-5 2" installation from "Core-5" menuitem
     * Hit "<Ctrl><f>"
     * Type "Core-5 2"
     Then Box "Core-5 2" "does" exist
@@ -101,7 +101,7 @@ Feature: General
   @search_via_button
   Scenario: Search via button
     * Initiate new box "Core-5" installation
-    * Initiate new box "Core-5" installation
+    * Initiate new box "Core-5 2" installation from "Core-5" menuitem
     * Press "Search"
     * Type "Core-5 2"
     Then Box "Core-5 2" "does" exist
@@ -114,7 +114,7 @@ Feature: General
   @search_escape
   Scenario: Return from search via Esc
     * Initiate new box "Core-5" installation
-    * Initiate new box "Core-5" installation
+    * Initiate new box "Core-5 2" installation from "Core-5" menuitem
     * Hit "<Ctrl><f>"
     * Type "Core-5 2"
     Then Box "Core-5 2" "does" exist
diff --git a/tests/livecd.feature b/tests/livecd.feature
index ffb6a5d..5cd9e90 100644
--- a/tests/livecd.feature
+++ b/tests/livecd.feature
@@ -8,11 +8,11 @@ Feature: LiceCD
   Scenario: New local liveCD box via file
     * Create new box from file "Downloads/Core-5.3.iso"
     * Press "Create"
-    * Wait for "sleep 10" end
+    * Wait for "sleep 3" end
     * Hit "Enter"
-    * Wait for "sleep 20" end
+    * Wait for "sleep 5" end
     * Save IP for machine "Core-5"
-    * Press "back" in vm
+    * Press "back" in "Core-5" vm
     Then Box "Core-5" "does" exist
     Then Ping "Core-5"
 
@@ -20,11 +20,11 @@ Feature: LiceCD
   Scenario: New local liveCD box
     * Create new box from menu "Core-5"
     * Press "Create"
-    * Wait for "sleep 10" end
+    * Wait for "sleep 3" end
     * Hit "Enter"
-    * Wait for "sleep 20" end
+    * Wait for "sleep 5" end
     * Save IP for machine "Core-5"
-    * Press "back" in vm
+    * Press "back" in "Core-5" vm
     Then Box "Core-5" "does" exist
     Then Ping "Core-5"
 
@@ -32,13 +32,13 @@ Feature: LiceCD
   Scenario: Create five liveCD boxes
     * Create new box "Core-5"
     Then Ping "Core-5"
-    * Create new box "Core-5"
+    * Create new box "Core-5 2" from "Core-5" menuitem
     Then Ping "Core-5 2"
-    * Create new box "Core-5"
+    * Create new box "Core-5 3" from "Core-5" menuitem
     Then Ping "Core-5 3"
-    * Create new box "Core-5"
+    * Create new box "Core-5 4" from "Core-5" menuitem
     Then Ping "Core-5 4"
-    * Create new box "Core-5"
+    * Create new box "Core-5 5" from "Core-5" menuitem
     Then Ping "Core-5 5"
 
   @go_into_local_livecd_box
@@ -75,10 +75,10 @@ Feature: LiceCD
   @delete_five_local_livecd_boxes
   Scenario: Delete five local liveCD boxes
     * Create new box "Core-5"
-    * Create new box "Core-5"
-    * Create new box "Core-5"
-    * Create new box "Core-5"
-    * Create new box "Core-5"
+    * Create new box "Core-5 2" from "Core-5" menuitem
+    * Create new box "Core-5 3" from "Core-5" menuitem
+    * Create new box "Core-5 4" from "Core-5" menuitem
+    * Create new box "Core-5 5" from "Core-5" menuitem
     * Select "Core-5" box
     * Select "Core-5 2" box
     * Select "Core-5 3" box
@@ -135,15 +135,15 @@ Feature: LiceCD
     * Create new box "Core-5"
     * Select "Core-5" box
     * Press "Properties"
+    * Hit "Right"
     * Press "Force Shutdown"
-    * Press "Shutdown" in alert
     Then Box "Core-5" "does" exist
     Then Cannot ping "Core-5"
 
   @livecd_restart_persistence
   Scenario: LiveCD restart persistence
     * Initiate new box "Core-5" installation
-    * Initiate new box "Core-5" installation
+    * Initiate new box "Core-5 2" installation from "Core-5" menuitem
     * Import machine "Core-5" from image "Downloads/Core-5.3.qcow2"
     * Import machine "Core-5" from image "Downloads/Core-5.3.vmdk"
     * Quit Boxes
diff --git a/tests/multi-windows.feature b/tests/multi-windows.feature
index e3d669c..42bdcca 100644
--- a/tests/multi-windows.feature
+++ b/tests/multi-windows.feature
@@ -26,8 +26,8 @@ Feature: Multi Window
   @open_three_new_windows
   Scenario: Open three new windows
     * Create new box "Core-5"
-    * Create new box "Core-5"
-    * Create new box "Core-5"
+    * Create new box "Core-5 2" from "Core-5" menuitem
+    * Create new box "Core-5 3" from "Core-5" menuitem
     * Select "Core-5" box
     * Select "Core-5 2" box
     * Select "Core-5 3" box
diff --git a/tests/snapshots.feature b/tests/snapshots.feature
index f13188d..3acc4f3 100644
--- a/tests/snapshots.feature
+++ b/tests/snapshots.feature
@@ -8,10 +8,11 @@ Feature: Snapshots
   Scenario: Create snapshots and revert to them
     * Create new box "Core-5"
     * Create snapshot "working network" from machine "Core-5"
+    * Wait for "sleep 2" end
     * Go into "Core-5" box
-    * Wait for "sleep 1" end
+    * Wait for "sleep 4" end
     * Type "sudo ifconfig eth0 down"
-    * Press "back" in vm
+    * Press "back" in "Core-5" vm
     * Wait for "sleep 5" end
     * Create snapshot "network down" from machine "Core-5"
     When "network down" is visible with command "virsh snapshot-current boxes-unknown |grep description"
diff --git a/tests/steps/creation.py b/tests/steps/creation.py
index 0ce25d3..05cda19 100644
--- a/tests/steps/creation.py
+++ b/tests/steps/creation.py
@@ -6,8 +6,8 @@ from dogtail.rawinput import typeText
 from time import sleep
 from utils import get_showing_node_name
 
- step('Create new box "{name}"')
-def create_machine(context, name):
+ step('Create new box "{name}" from "{item}" menuitem')
+def create_machine_from_menuitem(context, name, item):
     """
     Create new box, wait till it finishes and save its IP
     """
@@ -17,7 +17,16 @@ def create_machine(context, name):
         * Wait for "sleep 3" end
         * Hit "Enter"
         * Save IP for machine "%s"
-        * Press "back" in vm
+        * Press "back" in "%s" vm
+        """ %(item, name, name))
+
+ step('Create new box "{name}"')
+def create_machine(context, name):
+    """
+    Same as create_machine_from_menuitem except it assumes menu item and created box to have the same name.
+    """
+    context.execute_steps(u"""
+        * Create new box "%s" from "%s" menuitem
         """ %(name, name))
 
 @step('Create new box from file "{location}"')
@@ -27,10 +36,9 @@ def create_new_vm_via_file(context, location):
     context.app.child('Continue').click()
     context.app.child('Select a file').click()
 
-    selector = context.app.child('Select a device or ISO file')
     for item in path:
-        selector.child(item).click()
-    selector.child('Open').click()
+        context.app.child(item).click()
+    context.app.child('Open').click()
 
 @step('Create new box from url "{url}"')
 def create_new_vm_via_url(context, url):
@@ -66,8 +74,8 @@ def import_image(context, name, location):
         * Save IP for machine "%s"
         """ %(location, name))
 
- step('Initiate new box "{name}" installation')
-def create_machine_no_wait(context, name):
+ step('Initiate new box "{name}" installation from "{item}" menuitem')
+def create_machine_from_menuitem_no_wait(context, name, item):
     """
     Initiate new box installation but don't save its IP nor wait for it to be ready
     """
@@ -76,5 +84,14 @@ def create_machine_no_wait(context, name):
         * Press "Create"
         * Wait for "sleep 3" end
         * Hit "Enter"
-        * Press "back" in vm
-        """ %(name))
+        * Press "back" in "%s" vm
+        """ %(item, name))
+
+ step('Initiate new box "{name}" installation')
+def create_machine_no_wait(context, name):
+    """
+    Same as create_machine_from_menuitem_no_wait except it assumes menu item and created box to have the 
same name.
+    """
+    context.execute_steps(u"""
+        * Initiate new box "%s" installation from "%s" menuitem
+        """ %(name, name))
diff --git a/tests/steps/general.py b/tests/steps/general.py
index 30c9401..6f5ca83 100644
--- a/tests/steps/general.py
+++ b/tests/steps/general.py
@@ -38,12 +38,10 @@ def number_of_windows(context, num):
 def customize_vm(context):
     context.app.child('Customize…').click()
     sleep(0.5)
-    pressKey('Tab')
-    pressKey('Tab')
     pressKey('Page_Up')
     pressKey('Page_Up')
 
-    context.app.children[0].children[0].children[3].child('Back').click()
+    context.app.findChildren(lambda x: x.name == 'Back' and x.showing)[0].click()
     sleep(0.5)
 
 @step('Go into "{vm}" box')
@@ -65,9 +63,9 @@ def help_shown(context):
 def no_box_sign(context):
     assert context.app.child('No boxes found') != None
 
- step('Press "{action}" in vm')
-def press_back_in_vm(context, action):
-    panel = context.app.child('Boxes').children[0].findChildren(lambda x: x.roleName == 'panel' and 
x.showing)[0]
+ step('Press "{action}" in "{vm}" vm')
+def press_back_in_vm(context, action, vm):
+    panel = context.app.child(vm).children[0].findChildren(lambda x: x.roleName == 'panel' and x.showing)[0]
     buttons = panel.findChildren(lambda x: x.roleName == 'push button' and x.showing)
     if action == 'back':
         buttons[0].click()
@@ -133,10 +131,13 @@ def save_ip_for_vm(context, vm):
 
 @step('Select "{vm}" box')
 def select_vm(context, vm):
+    select_button = context.app.child('Select Items')
+    if select_button.showing:
+        select_button.click()
     pane = context.app.child(roleName='layered pane')
     for child in pane.children:
         if child.text == vm:
-            child.click(button='3')
+            child.click()
             sleep(0.2)
             break
 
diff --git a/tests/steps/multi-window.py b/tests/steps/multi-window.py
index 3a6d7b7..198ba7e 100644
--- a/tests/steps/multi-window.py
+++ b/tests/steps/multi-window.py
@@ -7,77 +7,45 @@ 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':
+        print "main window"
         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)
diff --git a/tests/steps/snapshot.py b/tests/steps/snapshot.py
index 0a6cc9b..a46f4e6 100644
--- a/tests/steps/snapshot.py
+++ b/tests/steps/snapshot.py
@@ -46,7 +46,7 @@ def create_snapshot(context, snap_name, vm_name):
         * Press "Properties"
         * Press "Snapshots"
         * Add Snapshot named "%s"
-        * Press "Back"
+        * Hit "Esc"
         """ %(vm_name, snap_name))
 
 @step('Delete machines "{vm_name}" snapshot "{snap_name}"')
@@ -67,8 +67,7 @@ def delete_snapshot(context, vm_name, snap_name):
     pressKey('Enter')
     sleep(2)
 
-    get_showing_node_name('Back', context.app).click()
-    sleep(0.5)
+    pressKey('Esc')
 
 @step('Revert machine "{vm_name}" to state "{snap_name}"')
 def revert_snapshot(context, vm_name, snap_name):
@@ -83,5 +82,4 @@ def revert_snapshot(context, vm_name, snap_name):
     revert = context.app.findChildren(lambda x: x.name == "Revert to this state" and x.showing)[0]
     revert.click()
 
-    get_showing_node_name('Back', context.app).click()
-    sleep(0.5)
+    pressKey('Esc')
diff --git a/tests/system-broker.feature b/tests/system-broker.feature
index 78fa538..467e054 100644
--- a/tests/system-broker.feature
+++ b/tests/system-broker.feature
@@ -9,7 +9,7 @@ Feature: System Broker
     * Connect to system broker
     Then Box "Core-5.3" "does" exist
     Then Go into "Core-5.3" box
-    Then Press "back" in vm
+    Then Press "back" in "Core-5.3" vm
     Then Box "Core-5.3" "does" exist
 
   @delete_system_broker_machine
@@ -33,7 +33,7 @@ Feature: System Broker
     * Wait for "virt-install -r 128 --name Core-5.3 --nodisks --cdrom /tmp/Core-5.3.iso --os-type linux 
--accelerate --connect qemu:///system --wait 0" end
     Then Box "Core-5.3" "does" exist
     Then Go into "Core-5.3" box
-    Then Press "back" in vm
+    Then Press "back" in "Core-5.3" vm
     Then Box "Core-5.3" "does" exist
 
   @undo_delete_system_broker_machine
@@ -63,15 +63,15 @@ Feature: System Broker
     * Go into "Core-5.3" box
     * Wait for "sleep 10" end
     Then Ping "Core-5.3"
-    Then Press "back" in vm
+    Then Press "back" in "Core-5.3" vm
 
   @force_shutdown_system_broker_machine
   Scenario: Force off system broker box
     * Connect to system broker
     * Select "Core-5.3" box
     * Press "Properties"
+    * Hit "Right"
     * Press "Force Shutdown"
-    * Press "Shutdown" in alert
     Then Box "Core-5.3" "does" exist
     Then Cannot ping "Core-5.3"
 
diff --git a/tests/vnc.feature b/tests/vnc.feature
index 0e2b6d7..8bb0c8c 100644
--- a/tests/vnc.feature
+++ b/tests/vnc.feature
@@ -18,7 +18,7 @@ Feature: Vnc
     * Wait for "sleep 10" end
     * Type "echo 'walderon' > /tmp/vnc_text.txt"
     Then "walderon" is visible with command "cat /tmp/vnc_text.txt"
-    Then Press "back" in vm
+    Then Press "back" in "localhost" vm
 
   @vnc_restart_persistence
   Scenario: VNC restart persistence


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