From 225022be844f4d3dd72acbf6ed4fe51679fb209c Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 27 Sep 2015 11:58:35 +0200 Subject: [PATCH] tests: Move create_wibox() into a helper script Signed-off-by: Uli Schlachter --- tests/_wibox_helper.lua | 32 ++++++++++++++++++++++++++++++++ tests/test-benchmark.lua | 35 ++--------------------------------- 2 files changed, 34 insertions(+), 33 deletions(-) create mode 100644 tests/_wibox_helper.lua diff --git a/tests/_wibox_helper.lua b/tests/_wibox_helper.lua new file mode 100644 index 00000000..5c19df91 --- /dev/null +++ b/tests/_wibox_helper.lua @@ -0,0 +1,32 @@ +local awful = require("awful") +local cairo = require("lgi").cairo +local wibox = require("wibox") + +return { create_wibox = function() + local img = cairo.ImageSurface(cairo.Format.ARGB32, 20, 20) + + -- Widgets that are aligned to the left + local left_layout = wibox.layout.fixed.horizontal() + left_layout:add(awful.widget.launcher({ image = img, command = "bash" })) + left_layout:add(awful.widget.taglist(1, awful.widget.taglist.filter.all)) + left_layout:add(awful.widget.prompt()) + + -- Widgets that are aligned to the right + local right_layout = wibox.layout.fixed.horizontal() + local textclock = awful.widget.textclock() + right_layout:add(textclock) + right_layout:add(awful.widget.layoutbox(1)) + + -- Now bring it all together (with the tasklist in the middle) + local layout = wibox.layout.align.horizontal() + layout:set_left(left_layout) + layout:set_middle(awful.widget.tasklist(1, awful.widget.tasklist.filter.currenttags)) + layout:set_right(right_layout) + + -- Create wibox + local wb = wibox({ width = 1024, height = 20, screen = 1 }) + --wb.visible = true + wb:set_widget(layout) + + return wb, textclock +end } diff --git a/tests/test-benchmark.lua b/tests/test-benchmark.lua index 4b3c3190..ed7e9e49 100644 --- a/tests/test-benchmark.lua +++ b/tests/test-benchmark.lua @@ -2,10 +2,8 @@ -- that we notice if they break. local awful = require("awful") -local wibox = require("wibox") -local lgi = require("lgi") -local GLib = lgi.GLib -local cairo = lgi.cairo +local GLib = require("lgi").GLib +local create_wibox = require("_wibox_helper").create_wibox local not_under_travis = not os.getenv("CI") @@ -41,35 +39,6 @@ local function do_pending_repaint() awesome.emit_signal("refresh") end -local function create_wibox() - local img = cairo.ImageSurface(cairo.Format.ARGB32, 20, 20) - - -- Widgets that are aligned to the left - local left_layout = wibox.layout.fixed.horizontal() - left_layout:add(awful.widget.launcher({ image = img, command = "bash" })) - left_layout:add(awful.widget.taglist(1, awful.widget.taglist.filter.all)) - left_layout:add(awful.widget.prompt()) - - -- Widgets that are aligned to the right - local right_layout = wibox.layout.fixed.horizontal() - local textclock = awful.widget.textclock() - right_layout:add(textclock) - right_layout:add(awful.widget.layoutbox(1)) - - -- Now bring it all together (with the tasklist in the middle) - local layout = wibox.layout.align.horizontal() - layout:set_left(left_layout) - layout:set_middle(awful.widget.tasklist(1, awful.widget.tasklist.filter.currenttags)) - layout:set_right(right_layout) - - -- Create wibox - local wb = wibox({ width = 1024, height = 20, screen = 1 }) - wb.visible = true - wb:set_widget(layout) - - return wb, textclock -end - local wb, textclock = create_wibox() local function relayout_textclock()