awesome/tests/test-spawn-snid.lua
Emmanuel Lepage Vallee 067bcaca60 client: Rename the manage and unmanage signals.
They currently fit the general concept of a `request::` in the sense
that they are not property related and have "request handlers".

The commit also add deprecation for signals.

The reason for this fits within the larger standardization project.
Non-namespaced signals will eventually be renamed. This has started
a long time ago.

What is old is new again. Once upon a time, there was a `startup`
parameter to the `manage` signal. It is now back in the form of
a context.

Finally, this commit removes the `manage` section of `rc.lua`. It no
longer did anything worthy of being in the config. Each of its
important parts have been moved out over the years and the last
remaining bit is always required anyway. The code has been moved
to `client.lua`.
2020-01-11 14:43:56 -08:00

60 lines
1.6 KiB
Lua

--- Tests for spawn's startup notifications.
local runner = require("_runner")
local test_client = require("_client")
local manage_called, c_snid
client.connect_signal("request::manage", function(c)
manage_called = true
c_snid = c.startup_id
assert(c.machine == awesome.hostname,
tostring(c.machine) .. " ~= " .. tostring(awesome.hostname))
end)
local snid
local num_callbacks = 0
local function callback(c)
assert(c.startup_id == snid)
num_callbacks = num_callbacks + 1
end
local steps = {
function(count)
if count == 1 then
snid = test_client("foo", "bar", true)
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
test_client("bar", "foo", false)
elseif manage_called then
assert(c_snid == nil, "c.startup_snid should be nil!")
return true
end
end,
function(count)
if count == 1 then
manage_called = false
snid = test_client("baz", "barz", false, callback)
elseif manage_called then
assert(snid)
assert(snid == c_snid)
assert(num_callbacks == 1, num_callbacks)
return true
end
end,
}
runner.run_steps(steps)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80