From b4beb2308beda029ddbcb1ea0d459ee442f73d46 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 28 Oct 2021 20:49:26 -0700 Subject: [PATCH] tests: Add a simple systray test. Compile a random little C program found on stack overflow to make a systray. The goal is to make the `event.c` tests less flacky. --- tests/test-systray.lua | 90 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 tests/test-systray.lua diff --git a/tests/test-systray.lua b/tests/test-systray.lua new file mode 100644 index 00000000..de4b5f93 --- /dev/null +++ b/tests/test-systray.lua @@ -0,0 +1,90 @@ +local spawn = require("awful.spawn") +local wibox = require("wibox") +local beautiful = require("beautiful") + +local steps, pid1, pid2, draw_w, st = {} + +table.insert(steps, function() + screen[1].mywibox:remove() + + local widget = wibox.widget.base.make_widget() + + function widget:fit(_, w, h) + return w, h + end + + function widget:draw(_, _, width) + draw_w = width + end + + local wb = wibox { + x = 0, + y = 0, + width = 100, + height = 20, + visible = true + } + + st = wibox.widget.systray() + + wb.widget = { + st, + widget, + layout = wibox.layout.fixed.horizontal + } + + pid1 = spawn("./test-systray") + + return true +end) + +table.insert(steps, function() + if draw_w ~= 80 then return end + + pid2 = spawn("./test-systray") + + return true +end) + +table.insert(steps, function() + if draw_w ~= 60 then return end + + st.reverse = true + st.horizontal = false + + return true +end) + +table.insert(steps, function() + st.horizontal = true + + beautiful.systray_icon_spacing = 10 + + return true +end) + + +table.insert(steps, function() + if draw_w ~= 50 then return end + + st.base_size = 5 + return true +end) + + +table.insert(steps, function() + if draw_w ~= 80 then return end + + awesome.kill(pid1, 9) + awesome.kill(pid2, 9) + + return true +end) + + +table.insert(steps, function() + if draw_w ~= 100 then return end + return true +end) + +require("_runner").run_steps(steps)