awesome/tests/test-focus.lua
Uli Schlachter e18bece3df Make tests more reliable on "early errors"
When e.g. test-leaks.lua fails, it will cause a Lua error before starting the
test runner. This means that the test will just hang, because nothing causes
awesome to quit.

Handle this by starting a timer when the test runner is loaded and quitting
awesome in there if no test run was started yet. This only works if all tests
load the runner before doing anything that could fail, so the require("_runner")
is moved to the beginning in every test.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-06 10:20:45 +01:00

50 lines
1.1 KiB
Lua

--- Tests for focus signals / property.
-- Test for https://github.com/awesomeWM/awesome/issues/134.
local runner = require("_runner")
local awful = require("awful")
local beautiful = require("beautiful")
beautiful.border_normal = "#0000ff"
beautiful.border_focus = "#00ff00"
client.connect_signal("focus", function(c)
c.border_color = "#ff0000"
end)
local steps = {
-- border_color should get applied via focus signal for first client on tag.
function(count)
if count == 1 then
awful.spawn("xterm")
else
local c = client.get()[1]
if c then
assert(c.border_color == "#ff0000")
return true
end
end
end,
-- border_color should get applied via focus signal for second client on tag.
function(count)
if count == 1 then
awful.spawn("xterm")
else
if #client.get() == 2 then
local c = client.get()[1]
assert(c == client.focus)
if c then
assert(c.border_color == "#ff0000")
return true
end
end
end
end
}
runner.run_steps(steps)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80