From b4afd0206b99218719339a3a88357c338c5fff2c Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 6 Jul 2021 01:13:48 -0700 Subject: [PATCH] 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. --- tests/test-struts.lua | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/test-struts.lua b/tests/test-struts.lua index 5e4e17da1..2cfee9253 100644 --- a/tests/test-struts.lua +++ b/tests/test-struts.lua @@ -9,6 +9,9 @@ local parent, small local twibar, bwibar, lwibar, rwibar = screen.primary.mywibox +-- Track garbage collection. +local wibars = setmetatable({screen.primary.mywibox}, {__mode="v"}) + -- Pretty print issues local function print_expected() local wa, sa = mouse.screen.workarea, mouse.screen.geometry @@ -219,6 +222,9 @@ table.insert(steps, function() bwibar = wibar {position = "bottom", bg = "#00ff00"} lwibar = wibar {position = "left" , bg = "#0000ff"} rwibar = wibar {position = "right" , bg = "#ff00ff"} + table.insert(wibars, bwibar) + table.insert(wibars, lwibar) + table.insert(wibars, rwibar) validate_wibar_geometry() @@ -469,6 +475,16 @@ table.insert(steps, function() rwibar: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 end) @@ -497,18 +513,22 @@ table.insert(steps, function() lwibar = wibar{position = "top", screen = s, height = 15, visible = true, bg = "#660066"} lwibar:setup(wdg2) + table.insert(wibars, lwibar) rwibar = wibar{position = "top", screen = s, height = 15, visible = true, bg = "#660000"} rwibar:setup(wdg2) + table.insert(wibars, rwibar) bwibar = wibar{position = "left", screen = s, ontop = true, width = 64, visible = true, bg = "#006600"} bwibar:setup(wdg) + table.insert(wibars, bwibar) twibar = wibar{position = "bottom", screen = s, height = 15, bg = "#666600"} twibar:setup(wdg2) + table.insert(wibars, twibar) test_workarea(s.geometry, s.workarea, 64, 0, 30, 15) validate_wibar_geometry() @@ -536,6 +556,36 @@ table.insert(steps, function() return true 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) -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80