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
|
2015-09-27 15:30:04 +02:00
|
|
|
local function emit_refresh()
|
|
|
|
awesome.emit_signal("refresh")
|
|
|
|
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-02-07 13:04:01 +01:00
|
|
|
-- luacheck: globals mywibox mylayoutbox
|
2016-03-26 18:09:24 +01:00
|
|
|
for s in screen do
|
|
|
|
mywibox[s].visible = false
|
|
|
|
end
|
2015-09-27 14:42:39 +02:00
|
|
|
mywibox = nil
|
|
|
|
mylayoutbox = nil
|
2015-09-27 15:30:04 +02:00
|
|
|
emit_refresh()
|
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")
|
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()
|
|
|
|
local l = awful.widget.layoutbox(1)
|
|
|
|
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())
|
|
|
|
collectable(awful.widget.textclock())
|
|
|
|
collectable(awful.widget.layoutbox(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
|
2015-09-27 15:31:42 +02:00
|
|
|
prepare_for_collect = emit_refresh
|
|
|
|
collectable(tooltip_delayed())
|
|
|
|
|
|
|
|
prepare_for_collect = emit_refresh
|
|
|
|
collectable(tooltip_now())
|
|
|
|
|
2015-09-27 15:30:04 +02:00
|
|
|
prepare_for_collect = emit_refresh
|
2015-09-27 12:25:20 +02:00
|
|
|
collectable(awful.widget.taglist(1, awful.widget.taglist.filter.all))
|
|
|
|
|
2015-09-27 15:30:04 +02:00
|
|
|
prepare_for_collect = emit_refresh
|
2015-09-27 14:10:45 +02:00
|
|
|
collectable(awful.widget.tasklist(1, awful.widget.tasklist.filter.currenttags))
|
|
|
|
|
2015-09-27 15:30:04 +02:00
|
|
|
prepare_for_collect = emit_refresh
|
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
|