Added more tests to check partial maximization handling, which require wmctrl as an optional dependency.

This commit is contained in:
Xinhao Yuan 2019-10-16 22:24:32 -04:00
parent 33570e45d7
commit 0e8dd4c1c9
4 changed files with 84 additions and 0 deletions

View File

@ -38,6 +38,7 @@ addons:
- dbus-x11
- xterm
- xdotool
- wmctrl
- xterm
- xvfb
- zsh

View File

@ -106,6 +106,8 @@ Additionally, the following optional dependencies exist:
pretty-printing of X11 errors
- [libRSVG](https://wiki.gnome.org/action/show/Projects/LibRsvg) for displaying
SVG files without scaling artifacts
- [wmctrl](http://tripie.sweb.cz/utils/wmctrl) for testing WM interactions
with external actions.
## Running Awesome

View File

@ -95,6 +95,11 @@ export GDK_SCALE=1
# No idea what this does, but it silences a warning that GTK init might print
export NO_AT_BRIDGE=1
# Enable partial maximization tests if wmctrl is found.
if command -v wmctrl >/dev/null 2>&1; then
export HAS_WMCTRL=1
fi
if [ $HEADLESS = 1 ]; then
"$XVFB" $D -noreset -screen 0 "${SIZE}x24" &
xserver_pid=$!

View File

@ -172,6 +172,82 @@ for _, gravity in ipairs { "NORTH_WEST", "NORTH", "NORTH_EAST", "WEST",
})
end
-- Partial maximization tests, which depend on wmctrl as a portable way to generate external requests.
if os.getenv('HAS_WMCTRL') == '1' then
print("Added tests for partial maximization.")
gears.table.merge(steps, {
function()
if #client.get() > 0 then return end
test_client(nil,nil,nil,nil,nil,{})
return true
end,
-- Makes the window partially maximized
function()
local c = client.get()[1]
if not c then return end
c.maximized_vertical = true
return true
end,
-- Maximizes the window externally
function()
local c = client.get()[1]
assert(c.maximized_vertical)
awful.spawn.with_shell(
"wmctrl -i -r " .. tostring(c.window) .. " -b add,maximized_vert,maximized_horz")
return true
end,
-- Partially unmaximizes the window externally
function()
local c = client.get()[1]
if not c.maximized then return end
awful.spawn.with_shell(
"wmctrl -i -r " .. tostring(c.window) .. " -b remove,maximized_vert")
return true
end,
-- Checks if the window is properly partially maximized, then fully maximizes it back externally
function()
local c = client.get()[1]
if c.maximized then return end
assert(c.maximized_horizontal)
assert(not c.maximized_vertical)
awful.spawn.with_shell(
"wmctrl -i -r " .. tostring(c.window) .. " -b add,maximized_vert")
return true
end,
-- Unmaximizes the window externally
function()
local c = client.get()[1]
if not c.maximized then return end
awful.spawn.with_shell(
"wmctrl -i -r " .. tostring(c.window) .. " -b toggle,maximized_vert,maximized_horz", false)
return true
end,
-- Checks that partial maximization is restored, then kills the client.
function()
local c = client.get()[1]
if c.maximized then return end
assert(c.maximized_horizontal)
assert(not c.maximized_vertical)
c:kill()
return true
end
})
else
print("Ignored partial maximization tests because wmctrl is not found.")
end
local counter = 0
local function geometry_handler(c, context, hints)