From 9e894d8fdd19c58bed7c39efd9fd3f8d80a58fd7 Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Wed, 3 Jul 2019 10:02:28 +0300 Subject: [PATCH] test-awful-placement: Make the test repeatable In order to test the behavior of awful.placement.no_overlap with unselected tags, the test sequence must be able to run multiple times. Fix the test code to make this possible (currently it just performs the same sequence 3 times, the code to actually test the behavior with different tags will be added later). Indentation is unchanged to make the changes obvious in diff; the next commit will contain formatting changes without anything else. Signed-off-by: Sergey Vlasov --- tests/test-awful-placement.lua | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/test-awful-placement.lua b/tests/test-awful-placement.lua index be1a49c2..c20a6c1b 100644 --- a/tests/test-awful-placement.lua +++ b/tests/test-awful-placement.lua @@ -44,14 +44,15 @@ local function default_test(c, geometry) return true end -local client_count = 0 local client_data = {} local function add_client(args) - client_count = client_count + 1 - local client_index = client_count + local data = {} + table.insert(client_data, data) + local client_index = #client_data table.insert(tests, function(count) local name = string.format("client%010d", client_index) if count <= 1 then + data.prev_client_count = #client.get() local geometry = args.geometry(mouse.screen.workarea) test_client(class, name, nil, nil, nil, { size = { @@ -59,10 +60,9 @@ local function add_client(args) height = geometry.height } }) - client_data[client_index] = { geometry = geometry } + data.geometry = geometry return nil - elseif #client.get() >= client_index then - local data = client_data[client_index] + elseif #client.get() > data.prev_client_count then local c = data.c if not c then c = client.get()[1] @@ -75,6 +75,9 @@ local function add_client(args) end) end +-- Repeat testing 3 times. +for _, _ in ipairs{1, 2, 3} do + -- The first 100x100 window should be placed at the top left corner. add_client { geometry = function(wa) @@ -165,6 +168,23 @@ add_client { end } +-- Kill test clients to prepare for the next iteration. +table.insert(tests, function(count) + if count <= 1 then + for _, data in ipairs(client_data) do + if data.c then + data.c:kill() + data.c = nil + end + end + end + if #client.get() == 0 then + return true + end +end) + +end + runner.run_steps(tests) -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80