[gnome-boxes/wip/automated-tests: 3/10] tests: More reliable pressing of actions



commit 757317ee398362394a7de1363e1545d825854036
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sun Feb 1 16:49:59 2015 +0000

    tests: More reliable pressing of actions
    
    We were asssuming that media will have the same title as every VM
    created out of it. Lets modify the rules to specify the names of VM and
    media both.

 tests/general.feature       |    8 ++++----
 tests/livecd.feature        |   22 +++++++++++-----------
 tests/multi-windows.feature |    4 ++--
 tests/snapshots.feature     |    2 +-
 tests/steps/creation.py     |   32 +++++++++++++++++++++++++-------
 tests/steps/general.py      |    6 +++---
 tests/system-broker.feature |    6 +++---
 tests/vnc.feature           |    2 +-
 8 files changed, 50 insertions(+), 32 deletions(-)
---
diff --git a/tests/general.feature b/tests/general.feature
index dee2f09..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"
 
@@ -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..b2a3bfa 100644
--- a/tests/livecd.feature
+++ b/tests/livecd.feature
@@ -12,7 +12,7 @@ Feature: LiceCD
     * Hit "Enter"
     * Wait for "sleep 20" 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"
 
@@ -24,7 +24,7 @@ Feature: LiceCD
     * Hit "Enter"
     * Wait for "sleep 20" 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
@@ -143,7 +143,7 @@ Feature: LiceCD
   @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..7425dfa 100644
--- a/tests/snapshots.feature
+++ b/tests/snapshots.feature
@@ -11,7 +11,7 @@ Feature: Snapshots
     * Go into "Core-5" box
     * Wait for "sleep 1" 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..0150c2f 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}"')
@@ -66,8 +75,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 +85,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..3ace020 100644
--- a/tests/steps/general.py
+++ b/tests/steps/general.py
@@ -65,9 +65,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()
diff --git a/tests/system-broker.feature b/tests/system-broker.feature
index 78fa538..ff47a0c 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,7 +63,7 @@ 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
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]