2015-03-14 10:06:53 +01:00
|
|
|
-- Test set_{,new}index_miss_handler
|
|
|
|
|
2016-04-25 03:04:27 +02:00
|
|
|
local mouse = mouse
|
2015-03-14 10:06:53 +01:00
|
|
|
local class = tag
|
|
|
|
local obj = class({})
|
2016-03-30 09:20:56 +02:00
|
|
|
local handler = require("gears.object.properties")
|
2018-12-26 23:38:05 +01:00
|
|
|
local abutton = require("awful.button")
|
|
|
|
local gtable = require("gears.table")
|
2016-05-12 07:18:12 +02:00
|
|
|
local wibox = require("wibox")
|
2018-12-26 23:38:05 +01:00
|
|
|
local runner = require("_runner")
|
2015-03-14 10:06:53 +01:00
|
|
|
|
|
|
|
awesome.connect_signal("debug::index::miss", error)
|
|
|
|
awesome.connect_signal("debug::newindex::miss", error)
|
|
|
|
|
|
|
|
class.set_index_miss_handler(function(o, k)
|
|
|
|
assert(o == obj)
|
|
|
|
assert(k == "key")
|
|
|
|
return 42
|
|
|
|
end)
|
|
|
|
assert(obj.key == 42)
|
|
|
|
|
|
|
|
local called = false
|
|
|
|
class.set_newindex_miss_handler(function(o, k, v)
|
|
|
|
assert(o == obj)
|
|
|
|
assert(k == "key")
|
|
|
|
assert(v == 42)
|
|
|
|
called = true
|
|
|
|
end)
|
|
|
|
obj.key = 42
|
|
|
|
assert(called)
|
|
|
|
|
2016-03-30 09:20:56 +02:00
|
|
|
handler(class, {auto_emit=true})
|
|
|
|
|
|
|
|
assert(not obj.key)
|
|
|
|
obj.key = 1337
|
|
|
|
assert(obj.key == 1337)
|
|
|
|
|
2016-04-25 03:04:27 +02:00
|
|
|
-- The the custom mouse handler
|
|
|
|
mouse.foo = "bar"
|
|
|
|
assert(mouse.foo == "bar")
|
|
|
|
|
2016-05-12 07:18:12 +02:00
|
|
|
local w = wibox()
|
|
|
|
w.foo = "bar"
|
|
|
|
assert(w.foo == "bar")
|
|
|
|
|
2016-06-04 15:56:52 +02:00
|
|
|
-- Test if read-only properties really are read-only
|
|
|
|
screen[1].clients = 42
|
|
|
|
assert(screen[1].clients ~= 42)
|
|
|
|
|
2016-08-01 22:02:58 +02:00
|
|
|
-- Test the wibox declarative widget system (drawin proxy)
|
|
|
|
|
|
|
|
local w2 = wibox {
|
|
|
|
visible = true,
|
|
|
|
wisth = 100,
|
|
|
|
height = 100
|
|
|
|
}
|
|
|
|
|
|
|
|
w2:setup{
|
|
|
|
{
|
|
|
|
text = "Awesomeness!",
|
|
|
|
id = "main_textbox",
|
|
|
|
widget = wibox.widget.textbox,
|
|
|
|
},
|
|
|
|
id = "main_background",
|
|
|
|
widget = wibox.container.background
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(w2.main_background)
|
|
|
|
assert(w2:get_children_by_id("main_background")[1])
|
|
|
|
assert(w2:get_children_by_id("main_textbox")[1])
|
|
|
|
assert(w2.main_background.main_textbox)
|
|
|
|
assert(w2.main_background == w2:get_children_by_id("main_background")[1])
|
|
|
|
|
2018-12-26 23:38:05 +01:00
|
|
|
-- You can't retry this, so if the assert above were false, assume it never
|
|
|
|
-- reaches this.
|
|
|
|
|
|
|
|
local steps = { function() return true end }
|
|
|
|
|
|
|
|
-- Try each combinations of current and legacy style accessors.
|
|
|
|
table.insert(steps, function()local b1, b2 = button({}, 1, function() end), button({}, 2, function() end)
|
|
|
|
root.buttons = {b1}
|
|
|
|
|
|
|
|
assert(#root.buttons == 1 )
|
|
|
|
assert(#root.buttons() == 1 )
|
|
|
|
assert(root.buttons[1] == b1)
|
|
|
|
|
|
|
|
root.buttons{b2}
|
|
|
|
|
|
|
|
assert(#root.buttons == 1 )
|
|
|
|
assert(#root.buttons() == 1 )
|
|
|
|
assert(root.buttons()[1] == b2)
|
|
|
|
|
|
|
|
local ab1, ab2 = abutton({}, 1, function() end), abutton({}, 2, function() end)
|
|
|
|
|
|
|
|
root.buttons = {ab1}
|
|
|
|
assert(#root.buttons == 1)
|
|
|
|
assert(#root.buttons() == 4)
|
|
|
|
for i=1, 4 do
|
|
|
|
assert(root.buttons()[i] == ab1[i])
|
|
|
|
end
|
|
|
|
|
|
|
|
root.buttons(gtable.join(ab2))
|
|
|
|
assert(#root.buttons == 1)
|
|
|
|
assert(#root.buttons() == 4)
|
|
|
|
for i=1, 4 do
|
|
|
|
assert(root.buttons()[i] == ab2[i])
|
|
|
|
end
|
|
|
|
|
|
|
|
root.buttons{ab1}
|
|
|
|
assert(#root.buttons == 1)
|
|
|
|
assert(#root.buttons() == 4)
|
|
|
|
for i=1, 4 do
|
|
|
|
assert(root.buttons()[i] == ab1[i])
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end)
|
|
|
|
|
|
|
|
runner.run_steps(steps)
|
2016-12-31 14:05:51 +01:00
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|