2015-07-10 13:17:50 +02:00
|
|
|
--- Tests for focus signals / property.
|
|
|
|
-- Test for https://github.com/awesomeWM/awesome/issues/134.
|
|
|
|
|
2016-03-06 10:20:45 +01:00
|
|
|
local runner = require("_runner")
|
2016-02-07 13:04:01 +01:00
|
|
|
local awful = require("awful")
|
2015-07-10 13:17:50 +02:00
|
|
|
|
2016-02-07 13:04:01 +01:00
|
|
|
local beautiful = require("beautiful")
|
2015-07-10 13:17:50 +02:00
|
|
|
beautiful.border_normal = "#0000ff"
|
|
|
|
beautiful.border_focus = "#00ff00"
|
|
|
|
|
|
|
|
client.connect_signal("focus", function(c)
|
2016-12-27 21:39:08 +01:00
|
|
|
c.border_color = "#ff0000"
|
2015-07-10 13:17:50 +02:00
|
|
|
end)
|
|
|
|
|
2018-03-03 10:46:49 +01:00
|
|
|
local function assert_equals(a, b)
|
|
|
|
if a == b then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
error(string.format("Assertion failed: %s == %s", a, b))
|
|
|
|
end
|
|
|
|
|
2015-07-10 13:17:50 +02:00
|
|
|
|
|
|
|
local steps = {
|
2016-12-27 21:39:08 +01:00
|
|
|
-- 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
|
2018-03-03 10:46:49 +01:00
|
|
|
assert_equals(c.border_color, "#ff0000")
|
2016-12-27 21:39:08 +01:00
|
|
|
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]
|
2018-03-03 10:46:49 +01:00
|
|
|
assert_equals(c, client.focus)
|
2016-12-27 21:39:08 +01:00
|
|
|
if c then
|
2018-03-03 10:46:49 +01:00
|
|
|
assert_equals(c.border_color, "#ff0000")
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2015-07-10 13:17:50 +02:00
|
|
|
end
|
2018-03-03 10:56:25 +01:00
|
|
|
end,
|
|
|
|
|
|
|
|
-- Test if alpha works as intended
|
|
|
|
function()
|
|
|
|
local c = client.get()[1]
|
|
|
|
|
|
|
|
local function test(set, expected)
|
|
|
|
expected = expected or set
|
|
|
|
c.border_color = set
|
|
|
|
assert_equals(c.border_color, expected)
|
|
|
|
end
|
|
|
|
|
|
|
|
test("#123456")
|
|
|
|
test("#12345678")
|
|
|
|
test("#123456ff", "#123456")
|
|
|
|
return true
|
2015-07-10 13:17:50 +02:00
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2016-03-06 10:20:45 +01:00
|
|
|
runner.run_steps(steps)
|
2015-12-12 17:42:33 +01:00
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|