2015-07-10 13:17:50 +02:00
|
|
|
--- Tests for urgent property.
|
|
|
|
|
2016-02-07 13:04:01 +01:00
|
|
|
local awful = require("awful")
|
|
|
|
local runner = require("_runner")
|
|
|
|
|
2015-07-10 13:17:50 +02:00
|
|
|
-- Some basic assertion that the tag is not marked "urgent" already.
|
2016-04-17 15:49:06 +02:00
|
|
|
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == nil)
|
2015-07-10 13:17:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
-- Setup signal handler which should be called.
|
|
|
|
-- TODO: generalize and move to runner.
|
|
|
|
local urgent_cb_done
|
|
|
|
client.connect_signal("property::urgent", function (c)
|
|
|
|
urgent_cb_done = true
|
|
|
|
assert(c.class == "XTerm", "Client should be xterm!")
|
|
|
|
end)
|
|
|
|
|
|
|
|
local manage_cb_done
|
|
|
|
client.connect_signal("manage", function (c)
|
|
|
|
manage_cb_done = true
|
|
|
|
assert(c.class == "XTerm", "Client should be xterm!")
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
-- Steps to do for this test.
|
|
|
|
local steps = {
|
|
|
|
-- Step 1: tag 2 should become urgent, when a client gets tagged via rules.
|
|
|
|
function(count)
|
|
|
|
if count == 1 then -- Setup.
|
|
|
|
urgent_cb_done = false
|
|
|
|
-- Select first tag.
|
2016-04-17 15:49:06 +02:00
|
|
|
awful.screen.focused().tags[1]:view_only()
|
2015-07-10 13:17:50 +02:00
|
|
|
|
|
|
|
runner.add_to_default_rules({ rule = { class = "XTerm" },
|
2016-04-10 11:32:16 +02:00
|
|
|
properties = { tag = "2", focus = true } })
|
2015-07-10 13:17:50 +02:00
|
|
|
|
2015-09-30 00:05:56 +02:00
|
|
|
awful.spawn("xterm")
|
2015-07-10 13:17:50 +02:00
|
|
|
end
|
|
|
|
if urgent_cb_done then
|
2016-04-17 15:49:06 +02:00
|
|
|
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == true)
|
|
|
|
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent_count") == 1)
|
2015-07-10 13:17:50 +02:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
-- Step 2: when switching to tag 2, it should not be urgent anymore.
|
|
|
|
function(count)
|
|
|
|
if count == 1 then
|
|
|
|
-- Setup: switch to tag.
|
2015-08-04 21:29:29 +02:00
|
|
|
root.fake_input("key_press", "Super_L")
|
|
|
|
root.fake_input("key_press", "2")
|
|
|
|
root.fake_input("key_release", "2")
|
|
|
|
root.fake_input("key_release", "Super_L")
|
2015-07-10 13:17:50 +02:00
|
|
|
|
2016-04-17 15:49:06 +02:00
|
|
|
elseif awful.screen.focused().selected_tags[1] == awful.screen.focused().tags[2] then
|
2015-07-10 13:17:50 +02:00
|
|
|
assert(#client.get() == 1)
|
2016-02-07 13:04:01 +01:00
|
|
|
local c = client.get()[1]
|
2015-07-10 13:17:50 +02:00
|
|
|
assert(not c.urgent, "Client is not urgent anymore.")
|
|
|
|
assert(c == client.focus, "Client is focused.")
|
2016-04-17 15:49:06 +02:00
|
|
|
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == false)
|
|
|
|
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent_count") == 0)
|
2015-07-10 13:17:50 +02:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
-- Step 3: tag 2 should not be urgent, but switched to.
|
|
|
|
function(count)
|
|
|
|
if count == 1 then -- Setup.
|
2016-02-15 22:09:10 +01:00
|
|
|
urgent_cb_done = false
|
2015-07-10 13:17:50 +02:00
|
|
|
|
|
|
|
-- Select first tag.
|
2016-04-17 15:49:06 +02:00
|
|
|
awful.screen.focused().tags[1]:view_only()
|
2015-07-10 13:17:50 +02:00
|
|
|
|
|
|
|
runner.add_to_default_rules({ rule = { class = "XTerm" },
|
2016-04-10 11:32:16 +02:00
|
|
|
properties = { tag = "2", focus = true, switchtotag = true }})
|
2015-07-10 13:17:50 +02:00
|
|
|
|
2015-09-30 00:05:56 +02:00
|
|
|
awful.spawn("xterm")
|
2015-07-10 13:17:50 +02:00
|
|
|
|
2016-04-17 15:49:06 +02:00
|
|
|
elseif awful.screen.focused().selected_tags[1] == awful.screen.focused().tags[2] then
|
2016-02-15 22:09:10 +01:00
|
|
|
assert(not urgent_cb_done)
|
2016-04-17 15:49:06 +02:00
|
|
|
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == false)
|
|
|
|
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent_count") == 0)
|
2016-04-17 12:09:47 +02:00
|
|
|
assert(awful.screen.focused().selected_tags[2] == nil)
|
2015-07-10 13:17:50 +02:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
|
|
|
|
-- Step 4: tag 2 should not become urgent, when a client gets tagged via
|
|
|
|
-- rules with focus=false.
|
|
|
|
function(count)
|
|
|
|
if count == 1 then -- Setup.
|
|
|
|
client.get()[1]:kill()
|
|
|
|
manage_cb_done = false
|
|
|
|
|
|
|
|
runner.add_to_default_rules({rule = { class = "XTerm" },
|
2016-04-10 11:32:16 +02:00
|
|
|
properties = { tag = "2", focus = false }})
|
2015-07-10 13:17:50 +02:00
|
|
|
|
2015-09-30 00:05:56 +02:00
|
|
|
awful.spawn("xterm")
|
2015-07-10 13:17:50 +02:00
|
|
|
end
|
|
|
|
if manage_cb_done then
|
|
|
|
assert(client.get()[1].urgent == false)
|
2016-04-17 15:49:06 +02:00
|
|
|
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == false)
|
|
|
|
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent_count") == 0)
|
2015-07-10 13:17:50 +02:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
2016-02-07 13:04:01 +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
|