test(awful: hotkeys_popup): add a minimal test
This commit is contained in:
parent
6416045baa
commit
3cc613fa20
|
@ -100,9 +100,9 @@ function widget.new()
|
||||||
['#21']="=",
|
['#21']="=",
|
||||||
Control="Ctrl"
|
Control="Ctrl"
|
||||||
},
|
},
|
||||||
|
_cached_wiboxes = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
local cached_wiboxes = {}
|
|
||||||
local cached_awful_keys = nil
|
local cached_awful_keys = nil
|
||||||
local colors_counter = {}
|
local colors_counter = {}
|
||||||
local colors = beautiful.xresources.get_current_theme()
|
local colors = beautiful.xresources.get_current_theme()
|
||||||
|
@ -408,13 +408,13 @@ function widget.new()
|
||||||
end
|
end
|
||||||
|
|
||||||
local joined_groups = join_plus_sort(available_groups)
|
local joined_groups = join_plus_sort(available_groups)
|
||||||
if not cached_wiboxes[s] then
|
if not widget_instance._cached_wiboxes[s] then
|
||||||
cached_wiboxes[s] = {}
|
widget_instance._cached_wiboxes[s] = {}
|
||||||
end
|
end
|
||||||
if not cached_wiboxes[s][joined_groups] then
|
if not widget_instance._cached_wiboxes[s][joined_groups] then
|
||||||
cached_wiboxes[s][joined_groups] = create_wibox(s, available_groups)
|
widget_instance._cached_wiboxes[s][joined_groups] = create_wibox(s, available_groups)
|
||||||
end
|
end
|
||||||
local help_wibox = cached_wiboxes[s][joined_groups]
|
local help_wibox = widget_instance._cached_wiboxes[s][joined_groups]
|
||||||
help_wibox:show()
|
help_wibox:show()
|
||||||
|
|
||||||
return capi.keygrabber.run(function(_, key, event)
|
return capi.keygrabber.run(function(_, key, event)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
|
local hotkeys_widget = require("awful.hotkeys_popup").widget
|
||||||
|
|
||||||
-- luacheck: globals modkey
|
-- luacheck: globals modkey
|
||||||
|
|
||||||
|
@ -15,6 +16,15 @@ local function get_c_and_t()
|
||||||
return c, t
|
return c, t
|
||||||
end
|
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
|
-- display deprecated warnings
|
||||||
--awful.util.deprecate = function() end
|
--awful.util.deprecate = function() end
|
||||||
|
|
||||||
|
@ -219,7 +229,41 @@ local steps = {
|
||||||
assert(#tags[1]:clients() == 4)
|
assert(#tags[1]:clients() == 4)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
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)
|
require("_runner").run_steps(steps)
|
||||||
|
|
|
@ -88,9 +88,9 @@ table.insert(steps, function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
table.insert(steps, function()
|
table.insert(steps, function()
|
||||||
assert(button._private.image ~= img)
|
assert(button._private.image ~= img)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Test a button release
|
-- Test a button release
|
||||||
|
|
Loading…
Reference in New Issue