From e05222088ad6850478169275af3424e1e2707343 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 21 Jul 2018 14:25:06 -0400 Subject: [PATCH] tests: Add fake_input tests --- tests/examples/text/root/fake_click.lua | 9 +++++++++ tests/examples/text/root/fake_string.lua | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/examples/text/root/fake_click.lua create mode 100644 tests/examples/text/root/fake_string.lua diff --git a/tests/examples/text/root/fake_click.lua b/tests/examples/text/root/fake_click.lua new file mode 100644 index 00000000..3fbe35b9 --- /dev/null +++ b/tests/examples/text/root/fake_click.lua @@ -0,0 +1,9 @@ +--DOC_NO_USAGE --DOC_ASTERISK + + local function click(button_id, x, y) + mouse.coords {x = x, y = y} + root.fake_input("button_press" , button_id) + root.fake_input("button_release", button_id) + end +--DOC_NEWLINE + click(1, 42, 42) diff --git a/tests/examples/text/root/fake_string.lua b/tests/examples/text/root/fake_string.lua new file mode 100644 index 00000000..78db2e8f --- /dev/null +++ b/tests/examples/text/root/fake_string.lua @@ -0,0 +1,23 @@ +--DOC_HEADER --DOC_NO_USAGE --DOC_ASTERISK + +local awful = { keygrabber = require("awful.keygrabber") } --DOC_HIDE + +local works = false --DOC_HIDE + +awful.keygrabber{autostart=true, stop_key = "!", --DOC_HIDE + stop_callback = function(_,_,_, seq) works=seq=="Hello world" end} --DOC_HIDE + + local function send_string_to_client(s, c) + local old_c = client.focus + client.focus = c + for i=1, #s do + local char = s:sub(i,i) + root.fake_input("key_press" , char) + root.fake_input("key_release", char) + end + client.focus = old_c + end +--DOC_NEWLINE + send_string_to_client("Hello world!") + +assert(works) --DOC_HIDE