aboutsummaryrefslogtreecommitdiff
path: root/robot/robot.sh
diff options
context:
space:
mode:
authorPhillip Lord <phillip.lord@russet.org.uk>2019-06-15 22:10:03 +0100
committerPhillip Lord <phillip.lord@russet.org.uk>2019-06-15 22:10:03 +0100
commitbe851b9eb42faa3c096737daaab0afcbc8c5087e (patch)
tree688f1f53b5908ee5523953b3bc2ef5748f4b3524 /robot/robot.sh
parent46d71b5218eadb2be2ec5ca32e5fe40f0640bbb9 (diff)
downloadorg-drill-be851b9eb42faa3c096737daaab0afcbc8c5087e.tar.gz
org-drill-be851b9eb42faa3c096737daaab0afcbc8c5087e.zip
Refactor robot testing
Diffstat (limited to 'robot/robot.sh')
-rw-r--r--robot/robot.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/robot/robot.sh b/robot/robot.sh
new file mode 100644
index 0000000..e013308
--- /dev/null
+++ b/robot/robot.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+## call find_bot to init this
+window_id=
+
+## This is the small sleep between key presses. Change for debugging
+## when you are not sure what is happening
+small_sleep=0.25
+big_sleep=1
+
+function sleep_small {
+ sleep $small_sleep
+}
+
+function sleep_big {
+ sleep $big_sleep
+}
+
+function send_answer {
+ retn
+ sleep_small
+ key 5
+ sleep_small
+}
+
+function launch_emacs {
+ echo Launching $EMACS -Q -l $1 &
+ $EMACS -Q -l $1 &
+}
+
+function kill_emacs {
+ key alt+x
+ command kill-emacs
+ retn
+}
+
+function key {
+ xdotool key --window $window_id $1
+}
+
+function command {
+ xdotool type --window $window_id $1
+}
+
+function retn {
+ xdotool key --window $window_id Return
+}
+
+function find_bot {
+ window_id=`xdotool search --name "emacs-bot"`
+ if [ -z "$window_id" ]
+ then
+ echo "Could not find window ID for Emacs-bot"
+ exit 1
+ fi
+}