fix(w.widget): signal typo and unit test
This is a combination of 2 commits. * fix(w.widget): emit signal typo * add(w.widget.base_spec): Unit test for setters signals emittion
This commit is contained in:
parent
b63399f656
commit
53a880454f
|
@ -260,7 +260,7 @@ end
|
||||||
function base.widget:set_opacity(o)
|
function base.widget:set_opacity(o)
|
||||||
if o ~= self._private.opacity then
|
if o ~= self._private.opacity then
|
||||||
self._private.opacity = o
|
self._private.opacity = o
|
||||||
self:emit_signal("widget::redraw")
|
self:emit_signal("widget::redraw_needed")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,65 @@ describe("wibox.widget.base", function()
|
||||||
assert.is_true(called2)
|
assert.is_true(called2)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe("Setters emit signals", function()
|
||||||
|
local widget
|
||||||
|
local signal_called
|
||||||
|
local callback = function () signal_called = true end
|
||||||
|
|
||||||
|
before_each(function()
|
||||||
|
widget = base.make_widget()
|
||||||
|
signal_called = false
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("'set_visible' calls 'widget::layout_changed'", function()
|
||||||
|
widget:connect_signal("widget::layout_changed", callback)
|
||||||
|
widget:set_visible(false)
|
||||||
|
assert.is_true(signal_called)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("'set_visible' calls 'widget::redraw_needed'", function()
|
||||||
|
widget:connect_signal("widget::redraw_needed", callback)
|
||||||
|
widget:set_visible(false)
|
||||||
|
assert.is_true(signal_called)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("'set_opacity' calls 'widget::redraw_needed'", function()
|
||||||
|
widget:connect_signal("widget::redraw_needed", callback)
|
||||||
|
widget:set_opacity(0)
|
||||||
|
assert.is_true(signal_called)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("'set_forced_width' calls 'widget::layout_changed'", function()
|
||||||
|
widget:connect_signal("widget::layout_changed", callback)
|
||||||
|
widget:set_forced_width(0)
|
||||||
|
assert.is_true(signal_called)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("'set_forced_height' calls 'widget::layout_changed'", function()
|
||||||
|
widget:connect_signal("widget::layout_changed", callback)
|
||||||
|
widget:set_forced_height(0)
|
||||||
|
assert.is_true(signal_called)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("'set_widget_common' calls 'property::widget'", function()
|
||||||
|
-- Implement `set_widget`
|
||||||
|
rawset(widget, "set_widget", base.set_widget_common)
|
||||||
|
|
||||||
|
widget:connect_signal("property::widget", callback)
|
||||||
|
widget:set_widget(base.make_widget())
|
||||||
|
assert.is_true(signal_called)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("'set_widget_common' calls 'widget::layout_changed'", function()
|
||||||
|
-- Implement `set_widget`
|
||||||
|
rawset(widget, "set_widget", base.set_widget_common)
|
||||||
|
|
||||||
|
widget:connect_signal("widget::layout_changed", callback)
|
||||||
|
widget:set_widget(base.make_widget())
|
||||||
|
assert.is_true(signal_called)
|
||||||
|
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