tests: Test spawning client on a specific screen.

This commit is contained in:
Emmanuel Lepage Vallee 2016-08-28 23:48:28 -04:00
parent db73887b9f
commit 760e72f94a
1 changed files with 84 additions and 3 deletions

View File

@ -1,4 +1,5 @@
local awful = require("awful")
local test_client = require("_client")
awful.util.deprecate = function() end
@ -64,9 +65,6 @@ assert(c:tags()[1] == t2 or c:tags()[2] == t2)
awful.client.toggletag(t2, c)
assert(c:tags()[1] == t and c:tags()[1] ~= t2 and c:tags()[2] == nil)
-- Test movetoscreen
--FIXME I don't have the hardware to test
-- Test floating
assert(c.floating ~= nil and type(c.floating) == "boolean")
c.floating = true
@ -79,4 +77,87 @@ end
end
}
local has_error
table.insert(steps, function()
-- Make sure there is no extra callbacks that causes double screen changes
-- (regress #1028 #1052)
client.connect_signal("property::screen",function(c)
if c.class and c.class ~= "screen"..c.screen.index then
has_error = table.concat {
"An unexpected screen change did occur\n",
debug.traceback(),"\n",
c.class, " Screen: ",c.screen.index
}
end
end)
return true
end)
local multi_screen_steps = {}
-- Add a test client on each screen.
table.insert(multi_screen_steps, function()
has_error = false
for i=1, screen.count() do
local s = screen[i]
test_client("screen"..i, nil, {
screen = s,
})
end
return true
end)
-- Test if the clients have been placed on the right screen
table.insert(multi_screen_steps, function()
if #client.get() ~= screen.count() then return end
if has_error then print(has_error) end
assert(not has_error)
for i=1, screen.count() do
local s = screen[i]
-- Just in case
for _, t in ipairs(s.selected_tags) do
assert(t.screen == s)
end
local t = s.selected_tag
assert(t and t.screen == s)
-- In case the next step has failed, find what went wrong
for _, c in ipairs(t:clients()) do
-- This is _supposed_ to be impossible, but can be forced by buggy
-- lua code.
if c.screen ~= t.screen then
local tags = c:tags()
for _, t2 in ipairs(tags) do
assert(t2.screen == c.screen)
end
assert(false)
end
assert(c.screen.index == i)
end
-- Check that the right client is placed, the loop above will trigger
-- asserts already, but in case the tag has more than 1 client and
-- everything is messed up, those asserts are still necessary.
assert(#t:clients() == 1)
assert(t:clients()[1].class == "screen"..i)
assert(t:clients()[1].screen == s)
-- Make sure it stays where it belongs
awful.placement.maximize(t:clients()[1])
assert(t:clients()[1] and t:clients()[1].screen == t.screen)
end
return true
end)
require("_multi_screen")(steps, multi_screen_steps)
require("_runner").run_steps(steps)