Merge pull request #1527 from actionless/awful-hotkeys-tests

test(awful: hotkeys_popup): add a minimal test
This commit is contained in:
Emmanuel Lepage Vallée 2017-02-05 18:00:21 -05:00 committed by GitHub
commit 3bff1ef730
3 changed files with 53 additions and 9 deletions

View File

@ -100,9 +100,9 @@ function widget.new()
['#21']="=",
Control="Ctrl"
},
_cached_wiboxes = {}
}
local cached_wiboxes = {}
local cached_awful_keys = nil
local colors_counter = {}
local colors = beautiful.xresources.get_current_theme()
@ -408,13 +408,13 @@ function widget.new()
end
local joined_groups = join_plus_sort(available_groups)
if not cached_wiboxes[s] then
cached_wiboxes[s] = {}
if not widget_instance._cached_wiboxes[s] then
widget_instance._cached_wiboxes[s] = {}
end
if not cached_wiboxes[s][joined_groups] then
cached_wiboxes[s][joined_groups] = create_wibox(s, available_groups)
if not widget_instance._cached_wiboxes[s][joined_groups] then
widget_instance._cached_wiboxes[s][joined_groups] = create_wibox(s, available_groups)
end
local help_wibox = cached_wiboxes[s][joined_groups]
local help_wibox = widget_instance._cached_wiboxes[s][joined_groups]
help_wibox:show()
return capi.keygrabber.run(function(_, key, event)

View File

@ -1,4 +1,5 @@
local awful = require("awful")
local hotkeys_widget = require("awful.hotkeys_popup").widget
-- luacheck: globals modkey
@ -15,6 +16,15 @@ local function get_c_and_t()
return c, t
end
local function num_pairs(container_table)
local number_of_items = 0
for _, _ in pairs(container_table) do
number_of_items = number_of_items + 1
end
return number_of_items
end
-- display deprecated warnings
--awful.util.deprecate = function() end
@ -219,7 +229,41 @@ local steps = {
assert(#tags[1]:clients() == 4)
return true
end,
-- Hotkeys popup should be displayed and hidden
function(count)
local s = awful.screen.focused()
local cached_wiboxes = hotkeys_widget.default_widget._cached_wiboxes
if count == 1 then
assert(num_pairs(cached_wiboxes) == 0)
awful.key.execute({modkey}, "s")
return nil
elseif count == 2 then
assert(num_pairs(cached_wiboxes) > 0)
assert(num_pairs(cached_wiboxes[s]) == 1)
end
local hotkeys_wibox
for _, widget in pairs(cached_wiboxes[s]) do
hotkeys_wibox = widget.wibox
end
if count == 2 then
assert(hotkeys_wibox ~= nil)
assert(hotkeys_wibox.visible)
-- Should disappear on anykey
root.fake_input("key_press", "Super_L")
elseif count == 3 then
assert(not hotkeys_wibox.visible)
root.fake_input("key_release", "Super_L")
return true
end
end,
}
require("_runner").run_steps(steps)

View File

@ -88,9 +88,9 @@ table.insert(steps, function()
end)
table.insert(steps, function()
assert(button._private.image ~= img)
assert(button._private.image ~= img)
return true
return true
end)
-- Test a button release