2016-04-08 08:46:01 +02:00
|
|
|
local awful = require("awful")
|
2017-01-24 11:28:54 +01:00
|
|
|
local hotkeys_widget = require("awful.hotkeys_popup").widget
|
2016-04-08 08:46:01 +02:00
|
|
|
|
|
|
|
-- luacheck: globals modkey
|
|
|
|
|
|
|
|
local old_c = nil
|
2019-12-15 07:48:56 +01:00
|
|
|
local called = false
|
2016-04-08 08:46:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
-- Get a tag and a client
|
|
|
|
local function get_c_and_t()
|
|
|
|
client.focus = old_c or client.get()[1]
|
|
|
|
local c = client.focus
|
|
|
|
|
|
|
|
local t = c.screen.selected_tag
|
|
|
|
|
|
|
|
return c, t
|
|
|
|
end
|
|
|
|
|
2017-01-24 11:28:54 +01:00
|
|
|
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
|
|
|
|
|
2019-10-10 18:00:34 +02:00
|
|
|
local test_context = {}
|
|
|
|
|
2016-04-08 08:46:01 +02:00
|
|
|
local steps = {
|
2016-12-27 21:39:08 +01:00
|
|
|
function(count)
|
|
|
|
if count <= 5 then
|
|
|
|
awful.spawn("xterm")
|
|
|
|
elseif #client.get() >= 5 then
|
|
|
|
local c, _ = get_c_and_t()
|
|
|
|
old_c = c
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Wait for the focus to change
|
|
|
|
function()
|
|
|
|
assert(old_c)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Test layout
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
--TODO use the key once the bug is fixed
|
|
|
|
local l = old_c.screen.selected_tag.layout
|
|
|
|
assert(l)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2018-12-29 02:47:06 +01:00
|
|
|
--awful.keyboard.emulate_key_combination({modkey}, " ")
|
2016-12-27 21:39:08 +01:00
|
|
|
awful.layout.inc(1)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(old_c.screen.selected_tag.layout ~= l)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Test ontop
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(not old_c.ontop)
|
2018-12-29 02:47:06 +01:00
|
|
|
awful.keyboard.emulate_key_combination({modkey}, "t")
|
2017-01-01 14:22:36 +01:00
|
|
|
awesome.sync()
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
|
|
|
end,
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Ok, no now ontop should be true
|
|
|
|
function()
|
|
|
|
local _, t = get_c_and_t()
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Give awesome some time
|
|
|
|
if not old_c.ontop then return nil end
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(old_c.ontop)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Now, test the master_width_factor
|
|
|
|
assert(t.master_width_factor == 0.5)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2018-12-29 02:47:06 +01:00
|
|
|
awful.keyboard.emulate_key_combination({modkey}, "l")
|
2017-01-01 14:22:36 +01:00
|
|
|
awesome.sync()
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
|
|
|
end,
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- The master width factor should now be bigger
|
|
|
|
function()
|
|
|
|
local _, t = get_c_and_t()
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(t.master_width_factor == 0.55)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Now, test the master_count
|
|
|
|
assert(t.master_count == 1)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2018-12-29 02:47:06 +01:00
|
|
|
awful.keyboard.emulate_key_combination({modkey, "Shift"}, "h")
|
2017-01-01 14:22:36 +01:00
|
|
|
awesome.sync()
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
|
|
|
end,
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- The number of master client should now be 2
|
|
|
|
function()
|
|
|
|
local _, t = get_c_and_t()
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(t.master_count == 2)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Now, test the column_count
|
|
|
|
assert(t.column_count == 1)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2018-12-29 02:47:06 +01:00
|
|
|
awful.keyboard.emulate_key_combination({modkey, "Control"}, "h")
|
|
|
|
awful.keyboard.emulate_key_combination({modkey, "Shift" }, "l")
|
2017-01-01 14:22:36 +01:00
|
|
|
awesome.sync()
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
|
|
|
end,
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- The number of columns should now be 2
|
|
|
|
function()
|
|
|
|
local _, t = get_c_and_t()
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(t.column_count == 2)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Now, test the switching tag
|
|
|
|
assert(t.index == 1)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2018-12-29 02:47:06 +01:00
|
|
|
awful.keyboard.emulate_key_combination({modkey, }, "Right")
|
2017-01-01 14:22:36 +01:00
|
|
|
awesome.sync()
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
|
|
|
end,
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- The tag index should now be 2
|
|
|
|
function()
|
|
|
|
local tags = mouse.screen.tags
|
|
|
|
-- local t = awful.screen.focused().selected_tag
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- assert(t.index == 2)--FIXME
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(tags[1].index == 1)
|
|
|
|
tags[1]:view_only()
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
|
|
|
end,
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Before testing tags, lets make sure everything is still right
|
|
|
|
function()
|
|
|
|
local tags = mouse.screen.tags
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(tags[1].selected)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
local clients = mouse.screen.clients
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Make sure the clients are all on the same screen, they should be
|
|
|
|
local c_scr = client.get()[1].screen
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
for _, c in ipairs(client.get()) do
|
|
|
|
assert(c_scr == c.screen)
|
|
|
|
end
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Then this should be true
|
|
|
|
assert(#clients == #client.get())
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(#mouse.screen.all_clients == #clients)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(#mouse.screen.all_clients - #mouse.screen.hidden_clients == #clients)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
|
|
|
end,
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Now, test switching tags
|
|
|
|
function()
|
|
|
|
local tags = mouse.screen.tags
|
|
|
|
local clients = mouse.screen.all_clients
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(#tags == 9)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(#clients == 5)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(mouse.screen.selected_tag == tags[1])
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
for i=1, 9 do
|
|
|
|
-- Check that assertion, because if it's false, the other assert()
|
|
|
|
-- wont make any sense.
|
|
|
|
assert(tags[i].index == i)
|
|
|
|
end
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
for i=1, 9 do
|
|
|
|
tags[i]:view_only()
|
|
|
|
assert(tags[i].selected)
|
|
|
|
assert(#mouse.screen.selected_tags == 1)
|
|
|
|
end
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
tags[1]:view_only()
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
|
|
|
end,
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Lets shift some clients around
|
|
|
|
function()
|
|
|
|
local tags = mouse.screen.tags
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Given all tags have been selected, the selection should be back on
|
|
|
|
-- tags[1] and the client history should be kept
|
|
|
|
assert(client.focus == old_c)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2018-12-29 02:47:06 +01:00
|
|
|
--awful.keyboard.emulate_key_combination({modkey, "Shift" }, "#"..(9+i)) --FIXME
|
2016-12-27 21:39:08 +01:00
|
|
|
client.focus:move_to_tag(tags[2])
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(not client.focus)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
|
|
|
end,
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- The client should be on tag 5
|
|
|
|
function()
|
|
|
|
-- Confirm the move did happen
|
|
|
|
local tags = mouse.screen.tags
|
|
|
|
assert(tags[1].selected)
|
|
|
|
assert(#old_c:tags() == 1)
|
|
|
|
assert(old_c:tags()[1] ~= tags[1])
|
|
|
|
assert(not old_c:tags()[1].selected)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- The focus should have changed by now, as the tag isn't visible
|
|
|
|
assert(client.focus ~= old_c)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(old_c:tags()[1] == tags[2])
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(#tags[2]:clients() == 1)
|
|
|
|
assert(#tags[1]:clients() == 4)
|
2016-04-08 08:46:01 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
2017-01-24 11:28:54 +01:00
|
|
|
end,
|
|
|
|
|
2019-12-02 01:25:10 +01:00
|
|
|
-- Add more keybindings for make sure the popup has many pages.
|
|
|
|
function()
|
|
|
|
for j=1, 10 do
|
|
|
|
for i=1, 200 do
|
|
|
|
awful.keyboard.append_global_keybinding(
|
|
|
|
awful.key {
|
|
|
|
key = "#"..(300+i),
|
|
|
|
modifiers = {},
|
|
|
|
on_press = function() end,
|
|
|
|
description = "Fake "..i,
|
|
|
|
group = "Fake"..j,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
|
2017-01-24 11:28:54 +01:00
|
|
|
-- 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)
|
2018-12-29 02:47:06 +01:00
|
|
|
awful.keyboard.emulate_key_combination({modkey}, "s")
|
2017-01-24 11:28:54 +01:00
|
|
|
return nil
|
|
|
|
|
|
|
|
elseif count == 2 then
|
|
|
|
assert(num_pairs(cached_wiboxes) > 0)
|
|
|
|
assert(num_pairs(cached_wiboxes[s]) == 1)
|
2019-10-10 18:00:34 +02:00
|
|
|
|
|
|
|
elseif (
|
|
|
|
test_context.hotkeys01_count_vim and
|
|
|
|
(count - test_context.hotkeys01_count_vim) == 2
|
|
|
|
) then
|
|
|
|
-- new wibox instance should be generated for including vim hotkeys:
|
|
|
|
assert(num_pairs(cached_wiboxes[s]) == 2)
|
2017-01-24 11:28:54 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local hotkeys_wibox
|
2019-10-10 18:00:34 +02:00
|
|
|
local visible_hotkeys_widget
|
2017-01-24 11:28:54 +01:00
|
|
|
for _, widget in pairs(cached_wiboxes[s]) do
|
|
|
|
hotkeys_wibox = widget.wibox
|
2019-10-10 18:00:34 +02:00
|
|
|
if hotkeys_wibox.visible then
|
|
|
|
visible_hotkeys_widget = widget
|
|
|
|
end
|
2017-01-24 11:28:54 +01:00
|
|
|
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")
|
2019-10-10 18:00:34 +02:00
|
|
|
test_context.hotkeys01_clients_before = #client.get()
|
2019-10-18 19:02:47 +02:00
|
|
|
-- imitate fake client with name "vim"
|
|
|
|
-- so hotkeys widget will offer vim hotkeys:
|
|
|
|
awful.spawn("xterm -title vim cat")
|
2019-10-10 18:00:34 +02:00
|
|
|
|
|
|
|
elseif not test_context.hotkeys01_count_vim then
|
|
|
|
-- if xterm with vim got already opened:
|
|
|
|
if (
|
|
|
|
test_context.hotkeys01_clients_before and
|
|
|
|
test_context.hotkeys01_clients_before < #client.get()
|
|
|
|
) then
|
|
|
|
-- open hotkeys popup with vim hotkeys:
|
2018-12-29 02:47:06 +01:00
|
|
|
awful.keyboard.emulate_key_combination({modkey}, "s")
|
2019-10-10 18:00:34 +02:00
|
|
|
test_context.hotkeys01_count_vim = count
|
|
|
|
end
|
|
|
|
|
|
|
|
elseif test_context.hotkeys01_count_vim then
|
|
|
|
if (count - test_context.hotkeys01_count_vim) == 1 then
|
|
|
|
assert(visible_hotkeys_widget ~= nil)
|
|
|
|
assert(visible_hotkeys_widget.current_page == 1)
|
|
|
|
-- Should change the page on PgDn:
|
|
|
|
root.fake_input("key_press", "Next")
|
|
|
|
elseif (count - test_context.hotkeys01_count_vim) == 2 then
|
|
|
|
assert(visible_hotkeys_widget ~= nil)
|
|
|
|
assert(visible_hotkeys_widget.current_page == 2)
|
|
|
|
root.fake_input("key_release", "Next")
|
|
|
|
-- Should disappear on anykey
|
|
|
|
root.fake_input("key_press", "Super_L")
|
|
|
|
elseif (count - test_context.hotkeys01_count_vim) == 3 then
|
|
|
|
assert(not visible_hotkeys_widget)
|
|
|
|
root.fake_input("key_release", "Super_L")
|
|
|
|
return true
|
|
|
|
end
|
2017-01-24 11:28:54 +01:00
|
|
|
end
|
|
|
|
end,
|
2019-12-15 07:48:56 +01:00
|
|
|
-- Test the `c:activate{}` keybindings.
|
|
|
|
function()
|
|
|
|
client.connect_signal("request::activate", function()
|
|
|
|
called = true
|
|
|
|
end)
|
|
|
|
|
|
|
|
old_c = client.focus
|
|
|
|
|
|
|
|
root.fake_input("key_press", "Super_L")
|
|
|
|
awful.placement.centered(mouse, {parent=old_c})
|
|
|
|
root.fake_input("button_press",1)
|
|
|
|
root.fake_input("button_release",1)
|
|
|
|
root.fake_input("key_release", "Super_L")
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
if not called then return end
|
|
|
|
|
|
|
|
client.focus = nil
|
|
|
|
called = false
|
|
|
|
root.fake_input("key_press", "Super_L")
|
|
|
|
root.fake_input("button_press",1)
|
|
|
|
root.fake_input("button_release",1)
|
|
|
|
root.fake_input("key_release", "Super_L")
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
-- Test resize.
|
|
|
|
function()
|
|
|
|
if not called then return end
|
|
|
|
|
|
|
|
called = false
|
|
|
|
root.fake_input("key_press", "Super_L")
|
|
|
|
root.fake_input("button_press",3)
|
|
|
|
root.fake_input("button_release",3)
|
|
|
|
root.fake_input("key_release", "Super_L")
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
if not called then return end
|
2017-01-24 11:28:54 +01:00
|
|
|
|
2019-12-15 07:48:56 +01:00
|
|
|
return true
|
|
|
|
end
|
2016-04-08 08:46:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
require("_runner").run_steps(steps)
|
2016-12-31 14:05:51 +01:00
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|