2015-10-28 01:00:00 +01:00
|
|
|
--- Tests for spawn's startup notifications.
|
|
|
|
|
2016-03-06 10:20:45 +01:00
|
|
|
local runner = require("_runner")
|
2016-05-05 18:33:18 +02:00
|
|
|
local test_client = require("_client")
|
2015-10-28 01:00:00 +01:00
|
|
|
|
|
|
|
local manage_called, c_snid
|
|
|
|
|
|
|
|
client.connect_signal("manage", function(c)
|
|
|
|
manage_called = true
|
|
|
|
c_snid = c.startup_id
|
2016-05-27 19:16:10 +02:00
|
|
|
assert(c.machine == awesome.hostname,
|
|
|
|
tostring(c.machine) .. " ~= " .. tostring(awesome.hostname))
|
2015-10-28 01:00:00 +01:00
|
|
|
end)
|
|
|
|
|
2016-11-28 21:02:27 +01:00
|
|
|
local snid
|
2016-11-28 20:58:28 +01:00
|
|
|
local num_callbacks = 0
|
|
|
|
local function callback(c)
|
|
|
|
assert(c.startup_id == snid)
|
|
|
|
num_callbacks = num_callbacks + 1
|
|
|
|
end
|
|
|
|
|
2015-10-28 01:00:00 +01:00
|
|
|
local steps = {
|
|
|
|
function(count)
|
|
|
|
if count == 1 then
|
2016-11-28 21:02:27 +01:00
|
|
|
snid = test_client("foo", "bar", true)
|
2015-10-28 01:00:00 +01:00
|
|
|
elseif manage_called then
|
|
|
|
assert(snid)
|
|
|
|
assert(snid == c_snid)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
-- Test that c.startup_id is nil for a client without startup notifications,
|
|
|
|
-- and especially not the one from the previous spawn.
|
|
|
|
function(count)
|
|
|
|
if count == 1 then
|
|
|
|
manage_called = false
|
2016-11-28 21:02:27 +01:00
|
|
|
test_client("bar", "foo", false)
|
2015-10-28 01:00:00 +01:00
|
|
|
elseif manage_called then
|
|
|
|
assert(c_snid == nil, "c.startup_snid should be nil!")
|
|
|
|
return true
|
|
|
|
end
|
2016-11-28 20:58:28 +01:00
|
|
|
end,
|
|
|
|
|
|
|
|
function(count)
|
|
|
|
if count == 1 then
|
|
|
|
manage_called = false
|
2016-11-28 21:02:27 +01:00
|
|
|
snid = test_client("baz", "barz", false, callback)
|
2016-11-28 20:58:28 +01:00
|
|
|
elseif manage_called then
|
|
|
|
assert(snid)
|
|
|
|
assert(snid == c_snid)
|
|
|
|
assert(num_callbacks == 1, num_callbacks)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
2015-10-28 01:00:00 +01:00
|
|
|
}
|
|
|
|
|
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
|