From 08555a4fedaf5e759b798ef507c417ae35345c0b Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 26 May 2017 12:26:36 +0200 Subject: [PATCH 1/3] test-maximize: Restore old border width When the border width changes, we move the client according to its gravity. This can cause problems with the following code. Fix this by restoring the original border width again, which undoes the move. Signed-off-by: Uli Schlachter --- tests/test-maximize.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test-maximize.lua b/tests/test-maximize.lua index 48fc01f7..21ff9c18 100644 --- a/tests/test-maximize.lua +++ b/tests/test-maximize.lua @@ -75,6 +75,9 @@ local steps = { assert(c.border_width == test_width) + -- Restore old border width + c.border_width = test_width - 1 + return true end, From 3e0eefe3bc239ffa3ffe39b9711f1068786b29cb Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 26 May 2017 12:32:04 +0200 Subject: [PATCH 2/3] Add a test case for some recent bug This test would have caught https://github.com/awesomeWM/awesome/issues/1607. Signed-off-by: Uli Schlachter --- tests/test-maximize.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test-maximize.lua b/tests/test-maximize.lua index 21ff9c18..84831e0d 100644 --- a/tests/test-maximize.lua +++ b/tests/test-maximize.lua @@ -26,7 +26,7 @@ end local steps = { function(count) if count == 1 then - test_client(nil,nil,nil,nil,nil,{gravity=lgi.Gdk.Gravity.NORTH_WEST}) + test_client(nil,nil,nil,nil,nil,{gravity=lgi.Gdk.Gravity.STATIC}) else local c = client.get()[1] if c then @@ -71,6 +71,11 @@ local steps = { c.border_width = test_width c.fullscreen = true + + -- Test that the client covers the full screen + assert(geo_to_str(c:geometry()) == geo_to_str(c.screen.geometry), + geo_to_str(c:geometry()) .. " == " .. geo_to_str(c.screen.geometry)) + c.fullscreen = false assert(c.border_width == test_width) From e90f3ef25390d5dbf3d0dbf696c1876f71360842 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 26 May 2017 12:40:53 +0200 Subject: [PATCH 3/3] test-maximize.lua: Test all gravities Signed-off-by: Uli Schlachter --- tests/test-maximize.lua | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/tests/test-maximize.lua b/tests/test-maximize.lua index 84831e0d..72c30b86 100644 --- a/tests/test-maximize.lua +++ b/tests/test-maximize.lua @@ -4,6 +4,7 @@ local runner = require("_runner") local awful = require("awful") local test_client = require("_client") local lgi = require("lgi") +local gears = require("gears") local function geo_to_str(g) return "pos=" .. g.x .. "," .. g.y .. @@ -12,21 +13,15 @@ end local original_geo = nil -local counter = 0 +local steps = {} -local function geometry_handler(c, context, hints) - hints = hints or {} - assert(type(c) == "client") - assert(type(context) == "string") - assert(type(hints.toggle) == "boolean") - assert(type(hints.status) == "boolean") - counter = counter + 1 -end - -local steps = { +for _, gravity in ipairs { "NORTH_WEST", "NORTH", "NORTH_EAST", "WEST", + "CENTER", "EAST", "SOUTH_WEST", "SOUTH", "SOUTH_EAST", "STATIC" } do + gears.table.merge(steps, { function(count) if count == 1 then - test_client(nil,nil,nil,nil,nil,{gravity=lgi.Gdk.Gravity.STATIC}) + print("testing gravity " .. gravity) + test_client(nil,nil,nil,nil,nil,{gravity=lgi.Gdk.Gravity[gravity]}) else local c = client.get()[1] if c then @@ -164,7 +159,22 @@ local steps = { c:kill() return true - end, + end +}) +end + +local counter = 0 + +local function geometry_handler(c, context, hints) + hints = hints or {} + assert(type(c) == "client") + assert(type(context) == "string") + assert(type(hints.toggle) == "boolean") + assert(type(hints.status) == "boolean") + counter = counter + 1 +end + +gears.table.merge(steps, { -- Now, start some clients maximized function() if #client.get() > 0 then return end @@ -249,7 +259,7 @@ local steps = { return true end -} +}) runner.run_steps(steps)