[gnome-boxes] tests: Add "Send key combos" test



commit 84ebba8d4ab94e712b1d152c5c6012b34b7bcea0
Author: Vladimir Benes <benesv email cz>
Date:   Wed Jun 10 13:00:50 2015 +0200

    tests: Add "Send key combos" test
    
    Boxes app is now able to send key combos into VMs. Test uses showkey
    utility executed inside the VM to record signals. Network is turned
    down if all signals were recorded as expected so pass/fail state can
    be recognized from outside of the VM.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744852

 tests/README           |    4 ++++
 tests/general.feature  |   25 +++++++++++++++++++++++++
 tests/steps/general.py |   19 +++++++++++++++++++
 3 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/tests/README b/tests/README
index 1b9695c..f7aa754 100644
--- a/tests/README
+++ b/tests/README
@@ -27,6 +27,7 @@ Structure
     * customize machine memory
     * start box
     * search boxes
+    * send key combos
   * import.feature
     * import local qcow2 and vmdk images
   * livecd.feature
@@ -80,6 +81,9 @@ Requirements
             }
     });" > /etc/polkit-1/rules.d/51-virtmgr.rules
 
+* for "Send key combos" test execution
+  * xdotool
+
 Execution
 =========
 
diff --git a/tests/general.feature b/tests/general.feature
index 5f6bc19..d4604e2 100644
--- a/tests/general.feature
+++ b/tests/general.feature
@@ -153,6 +153,31 @@ Feature: General
     Then Box "Core-5 2" "does not " exist
     Then Box "Core-5 3" "does not" exist
 
+  @send_keycombos
+  Scenario: Send key combos
+    * Create new box from menu "Core-5"
+    * Press "Create"
+    * Wait for "sleep 3" end
+    * Hit "Enter"
+    * Save IP for machine "Core-5"
+    * Install TC Linux package "distro.ibiblio.org/tinycorelinux/3.x/tcz/showkey.tcz" and wait "1" seconds
+    * Start showkey signal recording
+    * Press "Send key combinations" in "Core-5" vm
+    * Press "Ctrl + Alt + Backspace" in "Core-5" vm
+    * Press "Send key combinations" in "Core-5" vm
+    * Press "Ctrl + Alt + F1" in "Core-5" vm
+    * Press "Send key combinations" in "Core-5" vm
+    * Press "Ctrl + Alt + F2" in "Core-5" vm
+    * Press "Send key combinations" in "Core-5" vm
+    * Press "Ctrl + Alt + F7" in "Core-5" vm
+    # showkey ends automatically after 10 seconds w/o signals
+    * Wait for "sleep 9" end
+    * Focus VM
+    # If all signals received as expected turn down network
+    Then Verify previously recorded signals
+    # and network should be unreachable from outside
+    Then Cannot ping "Core-5"
+
 ### TBD ###
   # local_machine_paused_after_quit
   # detach_from_system_broker
diff --git a/tests/steps/general.py b/tests/steps/general.py
index 3f5e76f..bc0d68e 100644
--- a/tests/steps/general.py
+++ b/tests/steps/general.py
@@ -238,6 +238,25 @@ def start_boxes(context):
     sleep(1)
     context.app = root.application('gnome-boxes')
 
+ step('Start showkey signal recording')
+def start_showkey_recording(context):
+    # Have to sleep a bit before as otherwise release of return can be caught
+    call("xdotool type --delay 100 'sleep 0.5; showkey > /tmp/showkey.txt\n'", shell=True)
+    sleep(1)
+
+ step('Verify previously recorded signals')
+def verify_existing_showkey_signals(context):
+    call("xdotool type --delay 100 'grep keycode /tmp/showkey.txt > /tmp/final.txt\n'", shell=True)
+    # If all signals received as expected
+    call("xdotool type --delay 100 'if [[ \"$(echo $(sed \"s/keycode//g\" /tmp/final.txt))\" == '", 
shell=True)
+    call("xdotool type --delay 100 ' \"29 press 56 press 14 press 14 release 56 release 29 release'", 
shell=True)
+    call("xdotool type --delay 100 ' 29 press 56 press 59 press 59 release 56 release 29 release'", 
shell=True)
+    call("xdotool type --delay 100 ' 29 press 56 press 60 press 60 release 56 release 29 release'", 
shell=True)
+    call("xdotool type --delay 100 ' 29 press 56 press 65 press 65 release 56 release 29 release\"'", 
shell=True)
+    # Turn down network so observer from outside the VM can say pass/fail.
+    call("xdotool type --delay 100 ' ]]; then sudo ifconfig eth0 down; fi\n'", shell=True)
+    sleep(0.5)
+
 @step('Start box name "{box}"')
 def start_boxes_via_vm(context, box):
     cmd = 'gnome-boxes %s' %box


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