tests: Add a titlebar integration suite

It doesn't do all that much, but will prevent #2419 from regressing
This commit is contained in:
Emmanuel Lepage Vallee 2018-10-06 18:19:19 -04:00
parent 789cf11d8d
commit 6229783e16
1 changed files with 94 additions and 0 deletions

94
tests/test-titlebar.lua Normal file
View File

@ -0,0 +1,94 @@
local runner = require("_runner")
local titlebar = require("awful.titlebar")
local rules = require("awful.rules")
local spawn = require("awful.spawn")
local tiny_client = {"lua", "-e", [[
local Gtk, class = require('lgi').require('Gtk'), 'client'
Gtk.init()
window = Gtk.Window {default_width=100, default_height=100, title='title'}
window:set_wmclass(class, class)
local app = Gtk.Application {}
function app:on_activate()
window.application = self
window:show_all()
end
app:run {''}
]]}
-- Use the test client props
rules.rules = {}
-- Too bad there's no way to disconnect the rc.lua request::titlebars function
local steps = {
function()
assert(#client.get() == 0)
spawn(tiny_client)
return true
end,
function()
if #client.get() ~= 1 then return end
local c = client.get()[1]
-- The rules don't set any borders nor enable the titlebar
assert(not c._request_titlebars_called)
assert(c.width == 100 and c.height == 100)
-- Should create the top titlebar
titlebar.toggle(c, "top")
assert(c._request_titlebars_called)
local h = c.height
assert(h > 100)
-- Should do nothing, there is no titlebar at the bottom by default
titlebar.toggle(c, "bottom")
assert(h == c.height)
-- Should hide the titlebar
titlebar.toggle(c, "top")
assert(c.height == 100)
c:kill()
return true
end,
function()
if #client.get() ~= 0 then return end
spawn(tiny_client, {titlebars_enabled=true})
return true
end,
function()
if #client.get() ~= 1 then return end
local c = client.get()[1]
local h = c.height
assert(c.width == 100 and h > 100)
assert(c._request_titlebars_called)
titlebar.hide(c, "top")
assert(c.width == 100 and c.height == 100)
titlebar.hide(c, "top")
assert(c.width == 100 and c.height == 100)
titlebar.show(c, "top")
assert(c.width == 100 and c.height == h)
c:kill()
return true
end,
}
runner.run_steps(steps)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80