align layout: Test signal emission
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
7acb30de71
commit
0e7ae1cb25
|
@ -139,18 +139,27 @@ end
|
|||
|
||||
--- Set the layout's first widget. This is the widget that is at the left/top
|
||||
function align:set_first(widget)
|
||||
if self.first == widget then
|
||||
return
|
||||
end
|
||||
self.first = widget
|
||||
self:emit_signal("widget::layout_changed")
|
||||
end
|
||||
|
||||
--- Set the layout's second widget. This is the centered one.
|
||||
function align:set_second(widget)
|
||||
if self.second == widget then
|
||||
return
|
||||
end
|
||||
self.second = widget
|
||||
self:emit_signal("widget::layout_changed")
|
||||
end
|
||||
|
||||
--- Set the layout's third widget. This is the widget that is at the right/bottom
|
||||
function align:set_third(widget)
|
||||
if self.third == widget then
|
||||
return
|
||||
end
|
||||
self.third = widget
|
||||
self:emit_signal("widget::layout_changed")
|
||||
end
|
||||
|
|
|
@ -222,6 +222,50 @@ describe("wibox.layout.align", function()
|
|||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("emitting signals", function()
|
||||
local layout, layout_changed
|
||||
before_each(function()
|
||||
layout = align.vertical()
|
||||
layout:connect_signal("widget::layout_changed", function()
|
||||
layout_changed = layout_changed + 1
|
||||
end)
|
||||
layout_changed = 0
|
||||
end)
|
||||
|
||||
it("set first", function()
|
||||
local w1, w2 = {}, {}
|
||||
assert.is.equal(layout_changed, 0)
|
||||
layout:set_first(w1)
|
||||
assert.is.equal(layout_changed, 1)
|
||||
layout:set_first(w2)
|
||||
assert.is.equal(layout_changed, 2)
|
||||
layout:set_first(w2)
|
||||
assert.is.equal(layout_changed, 2)
|
||||
end)
|
||||
|
||||
it("set second", function()
|
||||
local w1, w2 = {}, {}
|
||||
assert.is.equal(layout_changed, 0)
|
||||
layout:set_second(w1)
|
||||
assert.is.equal(layout_changed, 1)
|
||||
layout:set_second(w2)
|
||||
assert.is.equal(layout_changed, 2)
|
||||
layout:set_second(w2)
|
||||
assert.is.equal(layout_changed, 2)
|
||||
end)
|
||||
|
||||
it("set third", function()
|
||||
local w1, w2 = {}, {}
|
||||
assert.is.equal(layout_changed, 0)
|
||||
layout:set_third(w1)
|
||||
assert.is.equal(layout_changed, 1)
|
||||
layout:set_third(w2)
|
||||
assert.is.equal(layout_changed, 2)
|
||||
layout:set_third(w2)
|
||||
assert.is.equal(layout_changed, 2)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
Loading…
Reference in New Issue