Tests: Have only one place for stubbing widgets
This makes the tests for wibox.hierarchy use test_utils.widget_stub() instead of having its own implementation of "fake widgets". Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
45323f2801
commit
447492e986
|
@ -8,12 +8,10 @@ local hierarchy = require("wibox.hierarchy")
|
||||||
local cairo = require("lgi").cairo
|
local cairo = require("lgi").cairo
|
||||||
local matrix = require("gears.matrix")
|
local matrix = require("gears.matrix")
|
||||||
local object = require("gears.object")
|
local object = require("gears.object")
|
||||||
|
local utils = require("wibox.test_utils")
|
||||||
|
|
||||||
local function make_widget(children)
|
local function make_widget(children)
|
||||||
local result = object()
|
local result = utils.widget_stub()
|
||||||
result:add_signal("widget::redraw_needed")
|
|
||||||
result:add_signal("widget::layout_changed")
|
|
||||||
result.visible = true
|
|
||||||
result.layout = function()
|
result.layout = function()
|
||||||
return children
|
return children
|
||||||
end
|
end
|
||||||
|
|
|
@ -82,8 +82,10 @@ assert:register("assertion", "widget_layout", widget_layout, "assertion.widget_l
|
||||||
return {
|
return {
|
||||||
widget_stub = function(width, height)
|
widget_stub = function(width, height)
|
||||||
local w = object()
|
local w = object()
|
||||||
|
w:add_signal("widget::redraw_needed")
|
||||||
|
w:add_signal("widget::layout_changed")
|
||||||
w.visible = true
|
w.visible = true
|
||||||
|
w.opacity = 1
|
||||||
w.fit = function()
|
w.fit = function()
|
||||||
return width or 10, height or 10
|
return width or 10, height or 10
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue