awesome/tests/test-awesomerc.lua

236 lines
5.2 KiB
Lua
Raw Normal View History

2016-04-08 08:46:01 +02:00
local awful = require("awful")
-- luacheck: globals modkey
local old_c = nil
local function get_callback(mod, key)
local inf = {}
awful.key(mod, key, nil, nil, inf)
return inf.execute
end
-- Get a tag and a client
local function get_c_and_t()
client.focus = old_c or client.get()[1]
local c = client.focus
local t = c.screen.selected_tag
return c, t
end
-- display deprecated warnings
--awful.util.deprecate = function() end
local steps = {
function(count)
if count <= 5 then
awful.spawn("xterm")
elseif #client.get() >= 5 then
local c, _ = get_c_and_t()
old_c = c
2016-04-08 08:46:01 +02:00
return true
end
end,
2016-04-08 08:46:01 +02:00
-- Wait for the focus to change
function()
assert(old_c)
2016-04-08 08:46:01 +02:00
-- Test layout
-- local cb = get_callback({modkey}, " ")
-- assert(cb)
2016-04-08 08:46:01 +02:00
--TODO use the key once the bug is fixed
local l = old_c.screen.selected_tag.layout
assert(l)
2016-04-08 08:46:01 +02:00
-- cb()
awful.layout.inc(1)
2016-04-08 08:46:01 +02:00
assert(old_c.screen.selected_tag.layout ~= l)
2016-04-08 08:46:01 +02:00
-- Test ontop
2016-04-08 08:46:01 +02:00
assert(not old_c.ontop)
get_callback({modkey}, "t")()
awesome.sync()
2016-04-08 08:46:01 +02:00
return true
end,
2016-04-08 08:46:01 +02:00
-- Ok, no now ontop should be true
function()
local _, t = get_c_and_t()
2016-04-08 08:46:01 +02:00
-- Give awesome some time
if not old_c.ontop then return nil end
2016-04-08 08:46:01 +02:00
assert(old_c.ontop)
2016-04-08 08:46:01 +02:00
-- Now, test the master_width_factor
assert(t.master_width_factor == 0.5)
2016-04-08 08:46:01 +02:00
get_callback({modkey}, "l")()
awesome.sync()
2016-04-08 08:46:01 +02:00
return true
end,
2016-04-08 08:46:01 +02:00
-- The master width factor should now be bigger
function()
local _, t = get_c_and_t()
2016-04-08 08:46:01 +02:00
assert(t.master_width_factor == 0.55)
2016-04-08 08:46:01 +02:00
-- Now, test the master_count
assert(t.master_count == 1)
2016-04-08 08:46:01 +02:00
get_callback({modkey, "Shift"}, "h")()
awesome.sync()
2016-04-08 08:46:01 +02:00
return true
end,
2016-04-08 08:46:01 +02:00
-- The number of master client should now be 2
function()
local _, t = get_c_and_t()
2016-04-08 08:46:01 +02:00
assert(t.master_count == 2)
2016-04-08 08:46:01 +02:00
-- Now, test the column_count
assert(t.column_count == 1)
2016-04-08 08:46:01 +02:00
get_callback({modkey, "Control"}, "h")()
get_callback({modkey, "Shift" }, "l")()
awesome.sync()
2016-04-08 08:46:01 +02:00
return true
end,
2016-04-08 08:46:01 +02:00
-- The number of columns should now be 2
function()
local _, t = get_c_and_t()
2016-04-08 08:46:01 +02:00
assert(t.column_count == 2)
2016-04-08 08:46:01 +02:00
-- Now, test the switching tag
assert(t.index == 1)
2016-04-08 08:46:01 +02:00
get_callback({modkey, }, "Right")()
awesome.sync()
2016-04-08 08:46:01 +02:00
return true
end,
2016-04-08 08:46:01 +02:00
-- The tag index should now be 2
function()
local tags = mouse.screen.tags
-- local t = awful.screen.focused().selected_tag
2016-04-08 08:46:01 +02:00
-- assert(t.index == 2)--FIXME
2016-04-08 08:46:01 +02:00
assert(tags[1].index == 1)
tags[1]:view_only()
2016-04-08 08:46:01 +02:00
return true
end,
2016-04-08 08:46:01 +02:00
-- Before testing tags, lets make sure everything is still right
function()
local tags = mouse.screen.tags
2016-04-08 08:46:01 +02:00
assert(tags[1].selected)
2016-04-08 08:46:01 +02:00
local clients = mouse.screen.clients
2016-04-08 08:46:01 +02:00
-- Make sure the clients are all on the same screen, they should be
local c_scr = client.get()[1].screen
2016-04-08 08:46:01 +02:00
for _, c in ipairs(client.get()) do
assert(c_scr == c.screen)
end
2016-04-08 08:46:01 +02:00
-- Then this should be true
assert(#clients == #client.get())
2016-04-08 08:46:01 +02:00
assert(#mouse.screen.all_clients == #clients)
2016-04-08 08:46:01 +02:00
assert(#mouse.screen.all_clients - #mouse.screen.hidden_clients == #clients)
2016-04-08 08:46:01 +02:00
return true
end,
2016-04-08 08:46:01 +02:00
-- Now, test switching tags
function()
local tags = mouse.screen.tags
local clients = mouse.screen.all_clients
2016-04-08 08:46:01 +02:00
assert(#tags == 9)
2016-04-08 08:46:01 +02:00
assert(#clients == 5)
2016-04-08 08:46:01 +02:00
assert(mouse.screen.selected_tag == tags[1])
2016-04-08 08:46:01 +02:00
for i=1, 9 do
-- Check that assertion, because if it's false, the other assert()
-- wont make any sense.
assert(tags[i].index == i)
end
2016-04-08 08:46:01 +02:00
for i=1, 9 do
tags[i]:view_only()
assert(tags[i].selected)
assert(#mouse.screen.selected_tags == 1)
end
2016-04-08 08:46:01 +02:00
tags[1]:view_only()
2016-04-08 08:46:01 +02:00
return true
end,
2016-04-08 08:46:01 +02:00
-- Lets shift some clients around
function()
local tags = mouse.screen.tags
2016-04-08 08:46:01 +02:00
-- Given all tags have been selected, the selection should be back on
-- tags[1] and the client history should be kept
assert(client.focus == old_c)
2016-04-08 08:46:01 +02:00
--get_callback({modkey, "Shift" }, "#"..(9+i))() --FIXME
client.focus:move_to_tag(tags[2])
2016-04-08 08:46:01 +02:00
assert(not client.focus)
2016-04-08 08:46:01 +02:00
return true
end,
2016-04-08 08:46:01 +02:00
-- The client should be on tag 5
function()
-- Confirm the move did happen
local tags = mouse.screen.tags
assert(tags[1].selected)
assert(#old_c:tags() == 1)
assert(old_c:tags()[1] ~= tags[1])
assert(not old_c:tags()[1].selected)
2016-04-08 08:46:01 +02:00
-- The focus should have changed by now, as the tag isn't visible
assert(client.focus ~= old_c)
2016-04-08 08:46:01 +02:00
assert(old_c:tags()[1] == tags[2])
2016-04-08 08:46:01 +02:00
assert(#tags[2]:clients() == 1)
assert(#tags[1]:clients() == 4)
2016-04-08 08:46:01 +02:00
return true
end
2016-04-08 08:46:01 +02:00
}
require("_runner").run_steps(steps)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80