Merge pull request #1822 from psychon/get_children

Add tests for get_children()
This commit is contained in:
Emmanuel Lepage Vallée 2017-06-08 21:32:40 -04:00 committed by GitHub
commit 35c3cb7ee0
14 changed files with 241 additions and 0 deletions

View File

@ -0,0 +1,15 @@
---------------------------------------------------------------------------
-- @author Uli Schlachter
-- @copyright 2017 Uli Schlachter
---------------------------------------------------------------------------
local arcchart = require("wibox.container.arcchart")
local utils = require("wibox.test_utils")
describe("wibox.container.arcchart", function()
it("common interfaces", function()
utils.test_container(arcchart())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,15 @@
---------------------------------------------------------------------------
-- @author Uli Schlachter
-- @copyright 2017 Uli Schlachter
---------------------------------------------------------------------------
local background = require("wibox.container.background")
local utils = require("wibox.test_utils")
describe("wibox.container.background", function()
it("common interfaces", function()
utils.test_container(background())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,15 @@
---------------------------------------------------------------------------
-- @author Uli Schlachter
-- @copyright 2017 Uli Schlachter
---------------------------------------------------------------------------
local constraint = require("wibox.container.constraint")
local utils = require("wibox.test_utils")
describe("wibox.container.constraint", function()
it("common interfaces", function()
utils.test_container(constraint())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,15 @@
---------------------------------------------------------------------------
-- @author Uli Schlachter
-- @copyright 2017 Uli Schlachter
---------------------------------------------------------------------------
local margin = require("wibox.container.margin")
local utils = require("wibox.test_utils")
describe("wibox.container.margin", function()
it("common interfaces", function()
utils.test_container(margin())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,15 @@
---------------------------------------------------------------------------
-- @author Uli Schlachter
-- @copyright 2017 Uli Schlachter
---------------------------------------------------------------------------
local mirror = require("wibox.container.mirror")
local utils = require("wibox.test_utils")
describe("wibox.container.mirror", function()
it("common interfaces", function()
utils.test_container(mirror())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,15 @@
---------------------------------------------------------------------------
-- @author Uli Schlachter
-- @copyright 2017 Uli Schlachter
---------------------------------------------------------------------------
local place = require("wibox.container.place")
local utils = require("wibox.test_utils")
describe("wibox.container.place", function()
it("common interfaces", function()
utils.test_container(place())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,15 @@
---------------------------------------------------------------------------
-- @author Uli Schlachter
-- @copyright 2017 Uli Schlachter
---------------------------------------------------------------------------
local radialprogressbar = require("wibox.container.radialprogressbar")
local utils = require("wibox.test_utils")
describe("wibox.container.radialprogressbar", function()
it("common interfaces", function()
utils.test_container(radialprogressbar())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,15 @@
---------------------------------------------------------------------------
-- @author Uli Schlachter
-- @copyright 2017 Uli Schlachter
---------------------------------------------------------------------------
local rotate = require("wibox.container.rotate")
local utils = require("wibox.test_utils")
describe("wibox.container.rotate", function()
it("common interfaces", function()
utils.test_container(rotate())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,17 @@
---------------------------------------------------------------------------
-- @author Uli Schlachter
-- @copyright 2017 Uli Schlachter
---------------------------------------------------------------------------
package.loaded["gears.timer"] = {}
local scroll = require("wibox.container.scroll")
local utils = require("wibox.test_utils")
describe("wibox.container.scroll", function()
it("common interfaces", function()
utils.test_container(scroll.horizontal())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -279,6 +279,28 @@ describe("wibox.layout.align", function()
assert.is.equal(layout_changed, 0)
end)
end)
it("set_children", function()
local w1, w2, w3 = { w1 = true }, { w2 = true }, { w3 = true }
local layout = align.vertical()
assert.is.same({}, layout:get_children())
layout:set_second(w2)
assert.is.same({ w2 }, layout:get_children())
layout:set_first(w1)
assert.is.same({ w1, w2 }, layout:get_children())
layout:set_third(w3)
assert.is.same({ w1, w2, w3 }, layout:get_children())
layout:set_second(nil)
assert.is.same({ w1, w3 }, layout:get_children())
layout:reset()
assert.is.same({}, layout:get_children())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -134,6 +134,21 @@ describe("wibox.layout.fixed", function()
assert.is.equal(layout_changed, 2)
end)
end)
it("set_children", function()
local w1, w2 = base.empty_widget(), base.empty_widget()
assert.is.same({}, layout:get_children())
layout:add(w1)
assert.is.same({ w1 }, layout:get_children())
layout:add(w2)
assert.is.same({ w1, w2 }, layout:get_children())
layout:reset()
assert.is.same({}, layout:get_children())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -134,6 +134,21 @@ describe("wibox.layout.flex", function()
assert.is.equal(layout_changed, 2)
end)
end)
it("set_children", function()
local w1, w2 = base.empty_widget(), base.empty_widget()
assert.is.same({}, layout:get_children())
layout:add(w1)
assert.is.same({ w1 }, layout:get_children())
layout:add(w2)
assert.is.same({ w1, w2 }, layout:get_children())
layout:reset()
assert.is.same({}, layout:get_children())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,30 @@
---------------------------------------------------------------------------
-- @author Uli Schlachter
-- @copyright 2017 Uli Schlachter
---------------------------------------------------------------------------
local grid = require("wibox.layout.grid")
local base = require("wibox.widget.base")
describe("wibox.layout.grid", function()
it("set_children", function()
local layout = grid()
local w1, w2 = base.empty_widget(), base.empty_widget()
assert.is.same({}, layout:get_children())
layout:add(w1)
assert.is.same({ w1 }, layout:get_children())
layout:add_widget_at(w2, 2, 2)
assert.is.same({ w1, w2 }, layout:get_children())
layout:add_widget_at(w1, 1, 2)
assert.is.same({ w1, w2, w1 }, layout:get_children())
layout:reset()
assert.is.same({}, layout:get_children())
end)
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -83,6 +83,26 @@ assert:register("assertion",
"assertion.widget_layout.positive")
-- }}}
local function test_container(container)
local w1 = base.empty_widget()
assert.is.same({}, container:get_children())
container:set_widget(w1)
assert.is.same({ w1 }, container:get_children())
container:set_widget(nil)
assert.is.same({}, container:get_children())
container:set_widget(w1)
assert.is.same({ w1 }, container:get_children())
if container.reset then
container:reset()
assert.is.same({}, container:get_children())
end
end
return {
widget_stub = function(width, height)
local w = object()
@ -105,6 +125,8 @@ return {
return w
end,
test_container = test_container,
}
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80