tests: Test awful.screen against regressions

This commit is contained in:
Emmanuel Lepage Vallee 2016-04-07 23:53:00 -04:00
parent f8fc0e27bf
commit c7fb00dd47
1 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,89 @@
local awful = require("awful")
awful.util.deprecate = function() end
local has_spawned = false
local steps = {
function(count)
if count <= 1 and not has_spawned and #client.get() < 2 then
awful.spawn("xterm")
awful.spawn("xterm")
has_spawned = true
elseif #client.get() >= 2 then
-- Test properties
client.focus = client.get()[1]
local s = mouse.screen
assert(s)
assert(s == screen[s])
-- Test padding
s.padding = 42
local counter = 0
for _, v in pairs(s.padding) do
assert(v == 42)
counter = counter + 1
end
assert(counter == 4)
awful.screen.padding(s, {
left = 1337,
right = 1337,
top = 1337,
bottom = 1337,
})
counter = 0
for _, v in pairs(s.padding) do
assert(v == 1337)
counter = counter + 1
end
assert(counter == 4)
counter = 0
for _, v in pairs(awful.screen.padding(s)) do
assert(v == 1337)
counter = counter + 1
end
assert(counter == 4)
-- Test square distance
assert(s:get_square_distance(9999, 9999))
assert(s:get_square_distance(9999, 9999)
== awful.screen.getdistance_sq(s, 9999, 9999))
-- Test count
counter = 0
for _ in screen do
counter = counter + 1
end
assert(screen.count() == counter)
counter = 0
awful.screen.connect_for_each_screen(function()
counter = counter + 1
end)
assert(screen.count() == counter)
return true
end
end
}
require("_runner").run_steps(steps)