tests: Test `wibox.template` `:set_property()`.
This commit is contained in:
parent
8fc30ae693
commit
452d21a634
|
@ -71,7 +71,7 @@ end
|
|||
|
||||
local function default_template()
|
||||
return custom_template {
|
||||
widget_template = {
|
||||
widget_template = wibox.template {
|
||||
id = 'background_role',
|
||||
border_strategy = 'inner',
|
||||
widget = wibox.container.background,
|
||||
|
|
|
@ -392,7 +392,7 @@ local function default_template(self)
|
|||
or self._private.style.tasklist_disable_icon
|
||||
or beautiful.tasklist_disable_icon
|
||||
|
||||
return {
|
||||
return wtemplate {
|
||||
{
|
||||
(not has_no_icon) and {
|
||||
clienticon,
|
||||
|
|
|
@ -176,7 +176,7 @@ end)
|
|||
--
|
||||
-- The default template is (less or more):
|
||||
--
|
||||
-- {
|
||||
-- wibox.template {
|
||||
-- {
|
||||
-- {
|
||||
-- {
|
||||
|
|
|
@ -7,6 +7,7 @@ _G.awesome.connect_signal = function() end
|
|||
|
||||
local gtimer = require("gears.timer")
|
||||
local template = require("wibox.template")
|
||||
local base = require("wibox.widget.base").make_widget
|
||||
|
||||
describe("wibox.template", function()
|
||||
local widget
|
||||
|
@ -80,6 +81,54 @@ describe("wibox.template", function()
|
|||
match.is_same { foo = "bar", bar = 10 }
|
||||
)
|
||||
end)
|
||||
|
||||
it("set_property", function()
|
||||
local called
|
||||
|
||||
widget = template {
|
||||
{
|
||||
id = "one",
|
||||
foo = "bar",
|
||||
widget = base
|
||||
},
|
||||
{
|
||||
id = "two",
|
||||
everything = 42,
|
||||
widget = base
|
||||
},
|
||||
{
|
||||
id = "three",
|
||||
set_prop = function(_, val)
|
||||
called = val
|
||||
end,
|
||||
widget = base
|
||||
},
|
||||
id = "main",
|
||||
widget = base,
|
||||
}
|
||||
|
||||
assert.is.equal(widget:get_children_by_id("main")[1], widget.children[1])
|
||||
assert.is.equal(widget:get_children_by_id("one")[1].foo, "bar")
|
||||
assert.is.equal(widget:get_children_by_id("two")[1].everything, 42)
|
||||
assert.is.equal(called, nil)
|
||||
|
||||
widget:set_property("prop", 1337, "three")
|
||||
assert.is.equal(called, 1337)
|
||||
|
||||
widget:set_property("foo", "baz", "one")
|
||||
assert.is.equal(widget:get_children_by_id("one")[1].foo, "baz")
|
||||
|
||||
widget:set_property("everything", -42, "two")
|
||||
assert.is.equal(widget:get_children_by_id("two")[1].everything, -42)
|
||||
|
||||
widget:set_property("foobar", true, {"one", "two"})
|
||||
assert.is_true(widget:get_children_by_id("one")[1].foobar)
|
||||
assert.is_true(widget:get_children_by_id("two")[1].foobar)
|
||||
assert.is_nil(widget:get_children_by_id("three")[1].foobar)
|
||||
|
||||
widget:set_property("test", 1337)
|
||||
assert.is.equal(widget:get_children_by_id("main")[1].test, 1337)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ beautiful.notification_action_label_only = true --DOC_HIDE
|
|||
spacing = 3,
|
||||
layout = wibox.layout.flex.horizontal
|
||||
},
|
||||
widget_template = {
|
||||
widget_template = wibox.template {
|
||||
{
|
||||
naughty.widget.icon,
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ local tasklist_buttons = nil --DOC_HIDE
|
|||
layout = wibox.layout.grid.horizontal
|
||||
},
|
||||
|
||||
widget_template = {
|
||||
widget_template = wibox.template {
|
||||
{
|
||||
{
|
||||
id = "clienticon",
|
||||
|
|
|
@ -111,7 +111,7 @@ awful.popup {
|
|||
forced_num_cols = 5,
|
||||
layout = wibox.layout.grid.vertical,
|
||||
},
|
||||
widget_template = {
|
||||
widget_template = wibox.template {
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
|
|
|
@ -28,7 +28,7 @@ local beautiful = require("beautiful") --DOC_HIDE
|
|||
forced_num_cols = 3,
|
||||
layout = wibox.layout.grid.vertical,
|
||||
},
|
||||
widget_template = {
|
||||
widget_template = wibox.template {
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
|
|
|
@ -16,7 +16,7 @@ local modkey = "mod4" --DOC_HIDE
|
|||
forced_num_cols = 5,
|
||||
layout = wibox.layout.grid.vertical,
|
||||
},
|
||||
widget_template = {
|
||||
widget_template = wibox.template {
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
|
|
|
@ -16,6 +16,7 @@ end
|
|||
local output = ""
|
||||
--DOC_NEWLINE
|
||||
for idx, c in ipairs(client.get()) do
|
||||
assert(c.name ~= "Example Client") --DOC_HIDE
|
||||
output = output .. c.name .. ":" .. idx .. ", "
|
||||
end
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ module.display_widget(_tl, nil, 22)
|
|||
module.add_event("Change the widget template.", function()
|
||||
--DOC_HIDE_END
|
||||
-- Change the widget template.
|
||||
tasklist.widget_template = {
|
||||
tasklist.widget_template = wibox.template {
|
||||
{
|
||||
{
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@ c2:tags(tags[1]) --DOC_HIDE
|
|||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
widget_template = {
|
||||
widget_template = wibox.template {
|
||||
{
|
||||
{
|
||||
{
|
||||
|
@ -80,6 +80,7 @@ c2:tags(tags[1]) --DOC_HIDE
|
|||
-- Add support for hover colors and an index label
|
||||
create_callback = function(self, c3, index, objects) --luacheck: no unused args
|
||||
self:get_children_by_id("index_role")[1].markup = "<b> "..c3.index.." </b>"
|
||||
assert(self:get_children_by_id("index_role")[1]) --DOC_HIDE
|
||||
|
||||
self:connect_signal("mouse::enter", function()
|
||||
if self.bg ~= "#ff0000" then
|
||||
|
|
|
@ -47,7 +47,7 @@ end --DOC_HIDE
|
|||
},
|
||||
-- Notice that there is *NO* `wibox.wibox` prefix, it is a template,
|
||||
-- not a widget instance.
|
||||
widget_template = {
|
||||
widget_template = wibox.template {
|
||||
{
|
||||
{
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ end --DOC_HIDE
|
|||
},
|
||||
-- Notice that there is *NO* `wibox.wibox` prefix, it is a template,
|
||||
-- not a widget instance.
|
||||
widget_template = {
|
||||
widget_template = wibox.template {
|
||||
{
|
||||
wibox.widget.base.make_widget(),
|
||||
forced_height = 5,
|
||||
|
|
|
@ -38,7 +38,7 @@ parent:add( wibox.container.background(--DOC_HIDE
|
|||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
widget_template = {
|
||||
widget_template = wibox.template {
|
||||
{
|
||||
{
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ parent:add( wibox.container.background(--DOC_HIDE
|
|||
},
|
||||
layout = wibox.layout.flex.horizontal
|
||||
},
|
||||
widget_template = {
|
||||
widget_template = wibox.template {
|
||||
{
|
||||
{
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ beautiful.notification_bg = beautiful.bg_normal --DOC_HIDE
|
|||
ruled.notification.append_rule {
|
||||
rule = { app_name = "mdp" },
|
||||
properties = {
|
||||
widget_template = {
|
||||
widget_template = wibox.template {
|
||||
{
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue