Add unit test for wrapping a margin container
This adds a test case where a `wibox.container.margin` with a `wibox.widget.imagebox` as child is wrapped by a simple function call. Check against regression in #3213. Signed-off-by: Lucas Schwiderski <lucas@lschwiderski.de>
This commit is contained in:
parent
7bc3ec4c35
commit
504bf53b8c
|
@ -3,13 +3,60 @@
|
||||||
-- @copyright 2017 Uli Schlachter
|
-- @copyright 2017 Uli Schlachter
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local base = require('wibox.widget.base')
|
||||||
local margin = require("wibox.container.margin")
|
local margin = require("wibox.container.margin")
|
||||||
|
local imagebox = require("wibox.widget.imagebox")
|
||||||
local utils = require("wibox.test_utils")
|
local utils = require("wibox.test_utils")
|
||||||
|
|
||||||
describe("wibox.container.margin", function()
|
describe("wibox.container.margin", function()
|
||||||
it("common interfaces", function()
|
it("common interfaces", function()
|
||||||
utils.test_container(margin())
|
utils.test_container(margin())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe("composite widgets", function()
|
||||||
|
it("can be wrapped with child", function()
|
||||||
|
local widget_name = "test_widget"
|
||||||
|
local new = function()
|
||||||
|
local ret = base.make_widget_declarative {
|
||||||
|
{
|
||||||
|
id = "img",
|
||||||
|
widget = imagebox,
|
||||||
|
},
|
||||||
|
widget = margin,
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.widget_name = widget_name
|
||||||
|
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
|
local widget = base.make_widget_declarative {
|
||||||
|
widget = new,
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.is.equal(
|
||||||
|
widget_name,
|
||||||
|
widget.widget_name,
|
||||||
|
"Widget name doesn't match"
|
||||||
|
)
|
||||||
|
local children = widget:get_children()
|
||||||
|
assert.is_not.Nil(children, "Widget doesn't have children")
|
||||||
|
assert.is.equal(
|
||||||
|
1,
|
||||||
|
#children,
|
||||||
|
"Widget should have exactly one child"
|
||||||
|
)
|
||||||
|
assert.is.True(
|
||||||
|
children[1].is_widget,
|
||||||
|
"Child widget should be a valid widget"
|
||||||
|
)
|
||||||
|
assert.is.equal(
|
||||||
|
widget.img,
|
||||||
|
children[1],
|
||||||
|
"Child widget should match the id accessor"
|
||||||
|
)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue