tests: Prevent a rare-ish race condition in the buttons test suite.

Given there is some async wibox redraw operations, there is a tiny,
tiny chance the test suite callback will be executed before the
redraw. It has been seen on the CI, so it is not 100% impossible.
This commit is contained in:
Emmanuel Lepage Vallee 2019-04-05 21:02:16 -04:00
parent c02ad71b0c
commit 68f6a567d1
1 changed files with 15 additions and 15 deletions

View File

@ -69,7 +69,7 @@ table.insert(steps, function()
awful.button({}, 1, nil, function () awful.button({}, 1, nil, function ()
button:emit_signal_recursive("test::recursive") button:emit_signal_recursive("test::recursive")
end) end)
)) ))
layout:connect_signal("test::recursive", function() layout:connect_signal("test::recursive", function()
got_called = true got_called = true
@ -89,7 +89,7 @@ table.insert(steps, function()
end) end)
table.insert(steps, function() table.insert(steps, function()
assert(button._private.image ~= img) if button._private.image == img then return end
return true return true
end) end)
@ -115,30 +115,30 @@ table.insert(steps, function()
end) end)
table.insert(steps, function() table.insert(steps, function()
assert(button._private.image ~= img) if button._private.image == img then return end
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
-- just make sure the button is not released for nothing -- just make sure the button is not released for nothing
assert(button._private.image ~= img) assert(button._private.image ~= img)
-- test if the button is released when the mouse move out -- test if the button is released when the mouse move out
awful.placement.right(mouse--[[, {parent = w}]]) awful.placement.right(mouse--[[, {parent = w}]])
root.fake_input("button_release", 1) root.fake_input("button_release", 1)
awesome.sync() awesome.sync()
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
assert(button._private.image == img) assert(button._private.image == img)
-- The button had plenty of clicks by now. Make sure everything worked -- The button had plenty of clicks by now. Make sure everything worked
assert(got_called) assert(got_called)
return true return true
end) end)
runner.run_steps(steps) runner.run_steps(steps)