2016-05-04 05:22:14 +02:00
|
|
|
local runner = require( "_runner" )
|
|
|
|
local wibox = require( "wibox" )
|
|
|
|
local awful = require( "awful" )
|
|
|
|
local beautiful = require( "beautiful" )
|
|
|
|
|
|
|
|
local steps = {}
|
|
|
|
|
|
|
|
local w
|
|
|
|
local img
|
|
|
|
local button
|
|
|
|
|
2016-08-17 08:52:28 +02:00
|
|
|
-- Also check recursive signals from events
|
|
|
|
local layout
|
|
|
|
local got_called = false
|
|
|
|
|
2016-05-04 05:22:14 +02:00
|
|
|
-- create a wibox.
|
|
|
|
table.insert(steps, function()
|
|
|
|
|
|
|
|
w = wibox {
|
|
|
|
ontop = true,
|
|
|
|
width = 250,
|
|
|
|
height = 250,
|
|
|
|
visible = true,
|
|
|
|
}
|
|
|
|
|
|
|
|
button = awful.widget.button {
|
|
|
|
image = beautiful.awesome_icon
|
|
|
|
}
|
|
|
|
|
|
|
|
w : setup {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = "foo",
|
|
|
|
widget = wibox.widget.textbox,
|
|
|
|
},
|
|
|
|
bg = "#ff0000",
|
2016-05-23 05:56:45 +02:00
|
|
|
widget = wibox.container.background
|
2016-05-04 05:22:14 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
widget = button,
|
|
|
|
},
|
|
|
|
bg = "#ff00ff",
|
2016-05-23 05:56:45 +02:00
|
|
|
widget = wibox.container.background
|
2016-05-04 05:22:14 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = "foo",
|
|
|
|
widget = wibox.widget.textbox,
|
|
|
|
},
|
|
|
|
bg = "#0000ff",
|
2016-05-23 05:56:45 +02:00
|
|
|
widget = wibox.container.background
|
2016-05-04 05:22:14 +02:00
|
|
|
},
|
|
|
|
layout = wibox.layout.flex.vertical
|
|
|
|
}
|
|
|
|
|
|
|
|
awful.placement.centered(w)
|
|
|
|
|
2016-05-26 23:39:27 +02:00
|
|
|
img = button._private.image
|
2016-05-04 05:22:14 +02:00
|
|
|
assert(img)
|
|
|
|
|
2016-08-17 08:52:28 +02:00
|
|
|
-- Test the click
|
|
|
|
layout = w.widget
|
|
|
|
assert(layout)
|
|
|
|
|
|
|
|
button:buttons(awful.util.table.join(
|
|
|
|
button:buttons(),
|
|
|
|
awful.button({}, 1, nil, function ()
|
|
|
|
button:emit_signal_recursive("test::recursive")
|
|
|
|
end)
|
2016-12-27 21:39:08 +01:00
|
|
|
))
|
2016-08-17 08:52:28 +02:00
|
|
|
|
|
|
|
layout:connect_signal("test::recursive", function()
|
|
|
|
got_called = true
|
|
|
|
end)
|
|
|
|
|
2016-05-04 05:22:14 +02:00
|
|
|
return true
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Test a button press
|
|
|
|
table.insert(steps, function()
|
|
|
|
awful.placement.centered(mouse)
|
|
|
|
|
|
|
|
root.fake_input("button_press", 1)
|
2017-01-01 14:22:36 +01:00
|
|
|
awesome.sync()
|
2016-05-04 05:22:14 +02:00
|
|
|
|
|
|
|
return true
|
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
2017-01-24 11:28:54 +01:00
|
|
|
assert(button._private.image ~= img)
|
2016-05-04 05:22:14 +02:00
|
|
|
|
2017-01-24 11:28:54 +01:00
|
|
|
return true
|
2016-05-04 05:22:14 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
-- Test a button release
|
|
|
|
table.insert(steps, function()
|
2016-05-26 23:39:27 +02:00
|
|
|
assert(button._private.image ~= img)
|
2016-05-04 05:22:14 +02:00
|
|
|
|
2017-01-01 14:22:36 +01:00
|
|
|
root.fake_input("button_release", 1)
|
|
|
|
awesome.sync()
|
|
|
|
|
2016-05-04 05:22:14 +02:00
|
|
|
return true
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Test a button press/release outside of the widget
|
|
|
|
table.insert(steps, function()
|
2016-05-26 23:39:27 +02:00
|
|
|
assert(button._private.image == img)
|
2016-05-04 05:22:14 +02:00
|
|
|
|
|
|
|
root.fake_input("button_press", 1)
|
2017-01-01 14:22:36 +01:00
|
|
|
awesome.sync()
|
2016-05-04 05:22:14 +02:00
|
|
|
|
|
|
|
return true
|
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(button._private.image ~= img)
|
2016-05-04 05:22:14 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
2016-05-04 05:22:14 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
2016-12-27 21:39:08 +01:00
|
|
|
-- just make sure the button is not released for nothing
|
|
|
|
assert(button._private.image ~= img)
|
2016-05-04 05:22:14 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- test if the button is released when the mouse move out
|
|
|
|
awful.placement.right(mouse--[[, {parent = w}]])
|
|
|
|
root.fake_input("button_release", 1)
|
2017-01-01 14:22:36 +01:00
|
|
|
awesome.sync()
|
2016-05-04 05:22:14 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
2016-05-04 05:22:14 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(button._private.image == img)
|
2016-05-04 05:22:14 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- The button had plenty of clicks by now. Make sure everything worked
|
|
|
|
assert(got_called)
|
2016-08-17 08:52:28 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
2016-05-04 05:22:14 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
runner.run_steps(steps)
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|