tests: Add fake_input tests

This commit is contained in:
Emmanuel Lepage Vallee 2018-07-21 14:25:06 -04:00
parent 2bf930b044
commit e05222088a
2 changed files with 32 additions and 0 deletions

View File

@ -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)

View File

@ -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