diff --git a/.travis.yml b/.travis.yml index d78877fb..c448255d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,7 @@ addons: - dbus-x11 - xterm - xdotool + - wmctrl - xterm - xvfb - zsh diff --git a/docs/01-readme.md b/docs/01-readme.md index e64c19a9..d6385fa9 100644 --- a/docs/01-readme.md +++ b/docs/01-readme.md @@ -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 diff --git a/tests/run.sh b/tests/run.sh index 75e305d6..3a704656 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -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=$! diff --git a/tests/test-maximize.lua b/tests/test-maximize.lua index 132961fd..f3f249e8 100644 --- a/tests/test-maximize.lua +++ b/tests/test-maximize.lua @@ -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)