tests: Make sure wibar resize works.

Also add some garbage collection tests. This was my original
theory about why resizing was broken, but it turned out something
in `awful.placement` leaked, not the wibar references.
This commit is contained in:
Emmanuel Lepage Vallee 2021-07-06 01:13:48 -07:00
parent d9f27bdf4b
commit b4afd0206b
1 changed files with 50 additions and 0 deletions

View File

@ -9,6 +9,9 @@ local parent, small
local twibar, bwibar, lwibar, rwibar = screen.primary.mywibox local twibar, bwibar, lwibar, rwibar = screen.primary.mywibox
-- Track garbage collection.
local wibars = setmetatable({screen.primary.mywibox}, {__mode="v"})
-- Pretty print issues -- Pretty print issues
local function print_expected() local function print_expected()
local wa, sa = mouse.screen.workarea, mouse.screen.geometry local wa, sa = mouse.screen.workarea, mouse.screen.geometry
@ -219,6 +222,9 @@ table.insert(steps, function()
bwibar = wibar {position = "bottom", bg = "#00ff00"} bwibar = wibar {position = "bottom", bg = "#00ff00"}
lwibar = wibar {position = "left" , bg = "#0000ff"} lwibar = wibar {position = "left" , bg = "#0000ff"}
rwibar = wibar {position = "right" , bg = "#ff00ff"} rwibar = wibar {position = "right" , bg = "#ff00ff"}
table.insert(wibars, bwibar)
table.insert(wibars, lwibar)
table.insert(wibars, rwibar)
validate_wibar_geometry() validate_wibar_geometry()
@ -469,6 +475,16 @@ table.insert(steps, function()
rwibar:remove() rwibar:remove()
twibar:remove() twibar:remove()
-- Make sure the placement doesn't hold a reference.
bwibar, lwibar, rwibar, twibar = nil, nil, nil, nil
screen.primary.mywibox = nil
for _=1, 3 do
collectgarbage("collect")
end
assert(not next(wibars))
return true return true
end) end)
@ -497,18 +513,22 @@ table.insert(steps, function()
lwibar = wibar{position = "top", screen = s, height = 15, lwibar = wibar{position = "top", screen = s, height = 15,
visible = true, bg = "#660066"} visible = true, bg = "#660066"}
lwibar:setup(wdg2) lwibar:setup(wdg2)
table.insert(wibars, lwibar)
rwibar = wibar{position = "top", screen = s, height = 15, rwibar = wibar{position = "top", screen = s, height = 15,
visible = true, bg = "#660000"} visible = true, bg = "#660000"}
rwibar:setup(wdg2) rwibar:setup(wdg2)
table.insert(wibars, rwibar)
bwibar = wibar{position = "left", screen = s, ontop = true, width = 64, bwibar = wibar{position = "left", screen = s, ontop = true, width = 64,
visible = true, bg = "#006600"} visible = true, bg = "#006600"}
bwibar:setup(wdg) bwibar:setup(wdg)
table.insert(wibars, bwibar)
twibar = wibar{position = "bottom", screen = s, twibar = wibar{position = "bottom", screen = s,
height = 15, bg = "#666600"} height = 15, bg = "#666600"}
twibar:setup(wdg2) twibar:setup(wdg2)
table.insert(wibars, twibar)
test_workarea(s.geometry, s.workarea, 64, 0, 30, 15) test_workarea(s.geometry, s.workarea, 64, 0, 30, 15)
validate_wibar_geometry() validate_wibar_geometry()
@ -536,6 +556,36 @@ table.insert(steps, function()
return true return true
end) end)
-- Test resizing wibars.
table.insert(steps, function()
-- Make sure the placement doesn't hold a reference.
bwibar, lwibar, rwibar, twibar = nil, nil, nil, nil
for _=1, 3 do
collectgarbage("collect")
end
assert(not next(wibars))
twibar = wibar{position = "top", screen = s, height = 15,
visible = true, bg = "#660066"}
assert(twibar.height == 15)
twibar.height = 64
assert(twibar.height == 64)
twibar:geometry { height = 128 }
assert(twibar.height == 128)
local old_width = twibar.width
twibar.width = 42
assert(twibar.width == old_width)
return true
end)
require("_runner").run_steps(steps) require("_runner").run_steps(steps)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80