2015-09-27 12:25:20 +02:00
|
|
|
-- Some memory leak checks as integration tests.
|
|
|
|
|
2016-03-06 10:20:45 +01:00
|
|
|
local runner = require("_runner")
|
2015-09-27 12:25:20 +02:00
|
|
|
local awful = require("awful")
|
|
|
|
local cairo = require("lgi").cairo
|
|
|
|
local create_wibox = require("_wibox_helper").create_wibox
|
|
|
|
local wibox = require("wibox")
|
|
|
|
|
|
|
|
local prepare_for_collect = nil
|
2019-02-15 17:04:19 +01:00
|
|
|
local function run_delayed_calls()
|
|
|
|
require("gears.timer").run_delayed_calls_now()
|
2015-09-27 15:30:04 +02:00
|
|
|
end
|
2015-09-27 12:25:20 +02:00
|
|
|
|
2015-09-27 14:42:39 +02:00
|
|
|
-- Make the layoutbox in the default config GC'able
|
2016-03-26 18:09:24 +01:00
|
|
|
for s in screen do
|
2016-09-30 22:46:51 +02:00
|
|
|
s.mywibox:set_widget(wibox.widget.textbox())
|
|
|
|
s.mywibox.visible = false
|
|
|
|
s.mywibox = nil
|
|
|
|
s.mylayoutbox = nil
|
2016-03-26 18:09:24 +01:00
|
|
|
end
|
2019-02-15 17:04:19 +01:00
|
|
|
run_delayed_calls()
|
2015-09-27 14:42:39 +02:00
|
|
|
|
2015-09-27 12:25:20 +02:00
|
|
|
-- Test if some objects can be garbage collected
|
2015-09-27 14:10:45 +02:00
|
|
|
local function collectable(a, b, c, d, e, f, g, h, last)
|
|
|
|
assert(last == nil, "got more arguments than supported")
|
2015-09-27 12:25:20 +02:00
|
|
|
local objs = setmetatable({ a, b, c, d, e, f, g, h }, { __mode = "v" })
|
2016-02-07 13:04:01 +01:00
|
|
|
a, b, c, d, e, f, g, h = nil, nil, nil, nil, nil, nil, nil, nil -- luacheck: ignore
|
2015-09-27 12:25:20 +02:00
|
|
|
if prepare_for_collect then
|
|
|
|
prepare_for_collect()
|
|
|
|
prepare_for_collect = nil
|
|
|
|
end
|
|
|
|
collectgarbage("collect")
|
2015-09-27 16:04:20 +02:00
|
|
|
collectgarbage("collect")
|
2016-03-26 10:14:56 +01:00
|
|
|
collectgarbage("collect")
|
2015-09-27 12:25:20 +02:00
|
|
|
-- Check if the table is now empty
|
2016-02-07 13:04:01 +01:00
|
|
|
for _, v in pairs(objs) do
|
2015-09-27 12:25:20 +02:00
|
|
|
print("Some object was not garbage collected!")
|
|
|
|
error(v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-27 15:31:42 +02:00
|
|
|
-- Use the layoutbox for testing delayed tooltips
|
|
|
|
local function tooltip_delayed()
|
2018-12-28 08:19:26 +01:00
|
|
|
local l = awful.widget.layoutbox{screen = 1}
|
2015-09-27 15:31:42 +02:00
|
|
|
local t = l._layoutbox_tooltip
|
|
|
|
assert(t)
|
|
|
|
return l, t
|
|
|
|
end
|
|
|
|
|
|
|
|
local function tooltip_now()
|
|
|
|
local w = wibox.widget.textbox("some textbox")
|
|
|
|
local t = awful.tooltip({ objects = {w} })
|
|
|
|
return w, t
|
|
|
|
end
|
|
|
|
|
2015-09-27 12:25:20 +02:00
|
|
|
-- First test some basic widgets
|
|
|
|
collectable(wibox.widget.base.make_widget())
|
|
|
|
collectable(wibox.widget.textbox("foo"))
|
|
|
|
collectable(wibox.layout.fixed.horizontal())
|
|
|
|
collectable(wibox.layout.align.horizontal())
|
|
|
|
|
|
|
|
-- Then some random widgets from awful
|
|
|
|
collectable(awful.widget.launcher({ image = cairo.ImageSurface(cairo.Format.ARGB32, 20, 20), command = "bash" }))
|
|
|
|
collectable(awful.widget.prompt())
|
2016-05-23 06:46:01 +02:00
|
|
|
collectable(wibox.widget.textclock())
|
2018-12-28 08:19:26 +01:00
|
|
|
collectable(awful.widget.layoutbox{screen=1})
|
2015-09-27 14:10:45 +02:00
|
|
|
|
2015-09-27 15:30:04 +02:00
|
|
|
-- Some widgets do things via timer.delayed_call
|
2019-02-15 17:04:19 +01:00
|
|
|
prepare_for_collect = run_delayed_calls
|
2015-09-27 15:31:42 +02:00
|
|
|
collectable(tooltip_delayed())
|
|
|
|
|
2019-02-15 17:04:19 +01:00
|
|
|
prepare_for_collect = run_delayed_calls
|
2015-09-27 15:31:42 +02:00
|
|
|
collectable(tooltip_now())
|
|
|
|
|
2019-02-15 17:04:19 +01:00
|
|
|
prepare_for_collect = run_delayed_calls
|
2017-11-27 06:50:03 +01:00
|
|
|
collectable(awful.widget.taglist{screen=1, filter=awful.widget.taglist.filter.all})
|
2015-09-27 12:25:20 +02:00
|
|
|
|
2019-02-15 17:04:19 +01:00
|
|
|
prepare_for_collect = run_delayed_calls
|
2017-11-27 06:50:03 +01:00
|
|
|
collectable(awful.widget.tasklist{screen=1, filter=awful.widget.tasklist.filter.currenttags})
|
2015-09-27 14:10:45 +02:00
|
|
|
|
2019-02-15 17:04:19 +01:00
|
|
|
prepare_for_collect = run_delayed_calls
|
2015-09-27 12:25:20 +02:00
|
|
|
collectable(create_wibox())
|
|
|
|
|
2016-03-06 10:20:45 +01:00
|
|
|
runner.run_steps({ function() return true end })
|
2015-12-12 17:42:33 +01:00
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|