From 2da1900d85ab678c182507277bf3a93dc09b197c Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 26 Feb 2017 14:20:08 -0500 Subject: [PATCH 1/3] tests: Add gravity to the test client --- tests/_client.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/_client.lua b/tests/_client.lua index 99c0297a..684c17cd 100644 --- a/tests/_client.lua +++ b/tests/_client.lua @@ -16,6 +16,9 @@ local function open_window(class, title, options) default_height = 100, title = title } + if options.gravity then + window:set_gravity(tonumber(options.gravity)) + end if options.snid and options.snid ~= "" then window:set_startup_id(options.snid) end @@ -106,7 +109,8 @@ local function get_snid(sn_rules, callback) return snid end -return function(class, title, sn_rules, callback, resize_increment) +return function(class, title, sn_rules, callback, resize_increment, args) + args = args or {} class = class or "test_app" title = title or "Awesome test client" @@ -120,6 +124,10 @@ return function(class, title, sn_rules, callback, resize_increment) if resize_increment then options = options .. "resize_increment," end + if args.gravity then + assert(type(args.gravity)=="number","Use `lgi.Gdk.Gravity.NORTH_WEST`") + options = options .. "gravity=" .. args.gravity .. "," + end local data = class .. "\n" .. title .. "\n" .. options .. "\n" local success, msg = pipe:write_all(data) assert(success, tostring(msg)) From e7232c0dc274fd73b2a535849999ba10cc943063 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 26 Feb 2017 14:24:27 -0500 Subject: [PATCH 2/3] test: Use the test client in test-maximize --- tests/test-maximize.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test-maximize.lua b/tests/test-maximize.lua index e67a27b5..0e9f2eed 100644 --- a/tests/test-maximize.lua +++ b/tests/test-maximize.lua @@ -2,13 +2,15 @@ local runner = require("_runner") local awful = require("awful") +local test_client = require("_client") +local lgi = require("lgi") local original_geo = nil local steps = { function(count) if count == 1 then - awful.spawn("xterm") + test_client(nil,nil,nil,nil,nil,{gravity=lgi.Gdk.Gravity.NORTH_WEST}) else local c = client.get()[1] if c then From 2eef92a891a993547d655b814e5c28572ba98ec7 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 14 May 2017 10:10:03 +0200 Subject: [PATCH 3/3] test-maximize: Improve error messages Signed-off-by: Uli Schlachter --- tests/test-maximize.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/test-maximize.lua b/tests/test-maximize.lua index 0e9f2eed..8d5aa711 100644 --- a/tests/test-maximize.lua +++ b/tests/test-maximize.lua @@ -5,6 +5,11 @@ local awful = require("awful") local test_client = require("_client") local lgi = require("lgi") +local function geo_to_str(g) + return "pos=" .. g.x .. "," .. g.y .. + ";size=" .. g.width .. "x" .. g.height +end + local original_geo = nil local steps = { @@ -68,9 +73,8 @@ local steps = { local new_geo = c:geometry() - for k,v in pairs(original_geo) do - assert(new_geo[k] == v) - end + assert(geo_to_str(original_geo) == geo_to_str(new_geo), + geo_to_str(original_geo) .. " == " .. geo_to_str(new_geo)) c.fullscreen = true @@ -99,9 +103,8 @@ local steps = { local new_geo = c:geometry() - for k,v in pairs(original_geo) do - assert(new_geo[k] == v) - end + assert(geo_to_str(original_geo) == geo_to_str(new_geo), + geo_to_str(original_geo) .. " == " .. geo_to_str(new_geo)) c.floating = true @@ -136,9 +139,8 @@ local steps = { local new_geo = c:geometry() - for k,v in pairs(original_geo) do - assert(new_geo[k] == v) - end + assert(geo_to_str(original_geo) == geo_to_str(new_geo), + geo_to_str(original_geo) .. " == " .. geo_to_str(new_geo)) return true end