tests: Emulate some clicks on the titlebars.

Maybe it will make the test coverage more deterministic... or not.
This commit is contained in:
Emmanuel Lepage Vallee 2021-10-28 20:26:33 -07:00
parent 15f63c700c
commit 6c1f2aac5b
1 changed files with 57 additions and 1 deletions

View File

@ -29,7 +29,7 @@ window.decorated = false
]]) ]])
} }
local found_font = nil local found_font, events, next_pos = nil, {}, {}
-- Use the test client props -- Use the test client props
local dep = gdebug.deprecate local dep = gdebug.deprecate
@ -44,6 +44,20 @@ local function kill_client(c)
awesome.kill(c.pid, 9) awesome.kill(c.pid, 9)
end end
local function click()
local x, y= next_pos.x, next_pos.y
mouse.coords{x=x, y=y}
assert(mouse.coords().x == x and mouse.coords().y == y)
root.fake_input("button_press", 1)
awesome.sync()
root.fake_input("button_release", 1)
awesome.sync()
next_pos = nil
return true
end
-- Too bad there's no way to disconnect the rc.lua request::titlebars function -- Too bad there's no way to disconnect the rc.lua request::titlebars function
local steps = { local steps = {
@ -183,6 +197,48 @@ local steps = {
assert(found_font == "sans 10") assert(found_font == "sans 10")
-- Test the events.
for _, event in ipairs { "button::press", "button::release", "mouse::move" } do
c:connect_signal(event, function()
table.insert(events, event)
end)
end
next_pos = { x = c:geometry().x + 5, y = c:geometry().y + 5 }
return true
end,
click,
function()
if #events == 0 then return end
events = {}
local c = client.get()[1]
next_pos = { x = c:geometry().x + 5, y = c:geometry().y + c:geometry().height - 5 }
return true
end,
click,
function()
if #events == 0 then return end
local c = client.get()[1]
next_pos = {
x = c:geometry().x + c:geometry().width/2,
y = c:geometry().y + c:geometry().height/2
}
return true
end,
click,
function()
if #events == 0 then return end
local c = client.get()[1]
kill_client(c) kill_client(c)
return true return true