tests: Test naughty request::icon.

This commit is contained in:
Emmanuel Lepage Vallee 2020-03-15 04:10:36 -04:00
parent c3cdac368d
commit 9e19e7a18c
1 changed files with 54 additions and 2 deletions

View File

@ -886,18 +886,70 @@ table.insert(steps, function()
return true return true
end) end)
-- Check that request::icon stops when an icon is found.
table.insert(steps, function()
local called = 0
local function set_icon1()
called = called + 1
end
local function set_icon2(n)
called = called + 1
n.icon = big_icon
end
local function set_icon3()
called = called + 1
end
naughty.connect_signal("request::icon", set_icon1)
naughty.connect_signal("request::icon", set_icon2)
naughty.connect_signal("request::icon", set_icon3)
assert(called == 0)
local n1 = naughty.notification {
title = "foo",
message = "bar",
app_icon = "baz"
}
assert(called == 2)
n1:destroy()
naughty.disconnect_signal("request::icon", set_icon1)
naughty.disconnect_signal("request::icon", set_icon2)
naughty.disconnect_signal("request::icon", set_icon3)
-- Check if `disconnect_signal` works.
n1 = naughty.notification {
title = "foo",
message = "bar",
app_icon = "baz"
}
assert(called == 2)
n1:destroy()
return true
end)
local icon_requests = {} local icon_requests = {}
-- Check if the action icon support is detected. -- Check if the action icon support is detected.
table.insert(steps, function() table.insert(steps, function()
assert(#active == 0) assert(#active == 0)
naughty.connect_signal("request::action_icon", function(a, context, hints) naughty.connect_signal("request::action_icon", function(a, _, hints)
icon_requests[hints.id] = a icon_requests[hints.id] = a
a.icon = hints.id == "list-add" and small_icon or big_icon a.icon = hints.id == "list-add" and small_icon or big_icon
end) end)
naughty.connect_signal("request::icon", function(n, context, hints) naughty.connect_signal("request::icon", function(n, _)
icon_requests[n] = true icon_requests[n] = true
end) end)