tests: Test titlebar fonts.

This commit is contained in:
Emmanuel Lepage Vallee 2021-10-25 21:30:09 -07:00
parent 146a9c3166
commit cd83b64268
1 changed files with 36 additions and 9 deletions

View File

@ -3,6 +3,7 @@ local titlebar = require("awful.titlebar")
local rules = require("ruled.client") local rules = require("ruled.client")
local spawn = require("awful.spawn") local spawn = require("awful.spawn")
local gdebug = require("gears.debug") local gdebug = require("gears.debug")
local textbox = require("wibox.widget.textbox")
local lua_executable = os.getenv("LUA") local lua_executable = os.getenv("LUA")
if lua_executable == nil or lua_executable == "" then if lua_executable == nil or lua_executable == "" then
@ -17,10 +18,8 @@ window = Gtk.Window {default_width=100, default_height=100, title='title'}
%s %s
window:set_wmclass(class, class) window:set_wmclass(class, class)
local app = Gtk.Application {} local app = Gtk.Application {}
function app:on_activate() window:show_all()
window.application = self Gtk:main{...}
window:show_all()
end
app:run {''} app:run {''}
]] ]]
local tiny_client = { lua_executable, "-e", string.format(tiny_client_code_template, "") } local tiny_client = { lua_executable, "-e", string.format(tiny_client_code_template, "") }
@ -30,12 +29,21 @@ window.decorated = false
]]) ]])
} }
local found_font = nil
-- Use the test client props -- Use the test client props
local dep = gdebug.deprecate local dep = gdebug.deprecate
gdebug.deprecate = function() end gdebug.deprecate = function() end
rules.rules = {} rules.rules = {}
gdebug.deprecate = dep gdebug.deprecate = dep
local function kill_client(c)
-- Make sure the process finishes. Just `c:kill()` only
-- closes the window. Adding some handlers to the GTK "app"
-- created some unwanted side effects in the CI.
awesome.kill(c.pid, 9)
end
-- Too bad there's no way to disconnect the rc.lua request::titlebars function -- Too bad there's no way to disconnect the rc.lua request::titlebars function
local steps = { local steps = {
@ -69,7 +77,7 @@ local steps = {
titlebar.toggle(c, "top") titlebar.toggle(c, "top")
assert(c.height == 100) assert(c.height == 100)
c:kill() kill_client(c)
return true return true
end, end,
@ -100,7 +108,7 @@ local steps = {
assert(c.width == 100 and c.height == h) assert(c.width == 100 and c.height == h)
c:kill() kill_client(c)
return true return true
end, end,
@ -119,7 +127,7 @@ local steps = {
assert(c.width == 100 and c.height > 100) assert(c.width == 100 and c.height > 100)
assert(c._request_titlebars_called) assert(c._request_titlebars_called)
c:kill() kill_client(c)
return true return true
end, end,
@ -140,7 +148,7 @@ local steps = {
assert(c.width == 100 and c.height > 100) assert(c.width == 100 and c.height > 100)
assert(c._request_titlebars_called) assert(c._request_titlebars_called)
c:kill() kill_client(c)
return true return true
end, end,
@ -161,7 +169,26 @@ local steps = {
assert(not c._request_titlebars_called) assert(not c._request_titlebars_called)
assert(c.width == 100 and c.height == 100) assert(c.width == 100 and c.height == 100)
c:kill() function textbox:set_font(value)
found_font = value
end
local args = {size = 40, font = "sans 10", position = "bottom"}
titlebar(c, args).widget = titlebar.widget.titlewidget(c)
return true
end,
function()
local c = client.get()[1]
assert(found_font == "sans 10")
kill_client(c)
return true
end,
function()
if #client.get() > 0 then return end
return true return true
end, end,