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 <sigprof@gmail.com>
This commit is contained in:
parent
ccaa75f4b4
commit
9e894d8fdd
|
@ -44,14 +44,15 @@ local function default_test(c, geometry)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local client_count = 0
|
|
||||||
local client_data = {}
|
local client_data = {}
|
||||||
local function add_client(args)
|
local function add_client(args)
|
||||||
client_count = client_count + 1
|
local data = {}
|
||||||
local client_index = client_count
|
table.insert(client_data, data)
|
||||||
|
local client_index = #client_data
|
||||||
table.insert(tests, function(count)
|
table.insert(tests, function(count)
|
||||||
local name = string.format("client%010d", client_index)
|
local name = string.format("client%010d", client_index)
|
||||||
if count <= 1 then
|
if count <= 1 then
|
||||||
|
data.prev_client_count = #client.get()
|
||||||
local geometry = args.geometry(mouse.screen.workarea)
|
local geometry = args.geometry(mouse.screen.workarea)
|
||||||
test_client(class, name, nil, nil, nil, {
|
test_client(class, name, nil, nil, nil, {
|
||||||
size = {
|
size = {
|
||||||
|
@ -59,10 +60,9 @@ local function add_client(args)
|
||||||
height = geometry.height
|
height = geometry.height
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
client_data[client_index] = { geometry = geometry }
|
data.geometry = geometry
|
||||||
return nil
|
return nil
|
||||||
elseif #client.get() >= client_index then
|
elseif #client.get() > data.prev_client_count then
|
||||||
local data = client_data[client_index]
|
|
||||||
local c = data.c
|
local c = data.c
|
||||||
if not c then
|
if not c then
|
||||||
c = client.get()[1]
|
c = client.get()[1]
|
||||||
|
@ -75,6 +75,9 @@ local function add_client(args)
|
||||||
end)
|
end)
|
||||||
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.
|
-- The first 100x100 window should be placed at the top left corner.
|
||||||
add_client {
|
add_client {
|
||||||
geometry = function(wa)
|
geometry = function(wa)
|
||||||
|
@ -165,6 +168,23 @@ add_client {
|
||||||
end
|
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)
|
runner.run_steps(tests)
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue