tests: Extend the test client to handle minimization.
The goal is to make the coverage less flacky by explicitly handling some events.
This commit is contained in:
parent
50b9b10437
commit
6615772d10
|
@ -10,10 +10,11 @@ end
|
||||||
|
|
||||||
local test_client_source = [[
|
local test_client_source = [[
|
||||||
pcall(require, 'luarocks.loader')
|
pcall(require, 'luarocks.loader')
|
||||||
local lgi = require 'lgi'
|
local lgi = require 'lgi'
|
||||||
local Gdk = lgi.require('Gdk')
|
local GLib = lgi.require('GLib')
|
||||||
local Gtk = lgi.require('Gtk')
|
local Gdk = lgi.require('Gdk')
|
||||||
local Gio = lgi.require('Gio')
|
local Gtk = lgi.require('Gtk')
|
||||||
|
local Gio = lgi.require('Gio')
|
||||||
Gtk.init()
|
Gtk.init()
|
||||||
|
|
||||||
local function open_window(class, title, options)
|
local function open_window(class, title, options)
|
||||||
|
@ -40,6 +41,8 @@ local function open_window(class, title, options)
|
||||||
end
|
end
|
||||||
if options.maximize_before then
|
if options.maximize_before then
|
||||||
window:maximize()
|
window:maximize()
|
||||||
|
elseif options.unminimize_after then
|
||||||
|
window:iconify()
|
||||||
end
|
end
|
||||||
window:set_wmclass(class, class)
|
window:set_wmclass(class, class)
|
||||||
window:show_all()
|
window:show_all()
|
||||||
|
@ -47,6 +50,14 @@ local function open_window(class, title, options)
|
||||||
window:maximize()
|
window:maximize()
|
||||||
elseif options.unmaximize_after then
|
elseif options.unmaximize_after then
|
||||||
window:unmaximize()
|
window:unmaximize()
|
||||||
|
elseif options.minimize_after then
|
||||||
|
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, function()
|
||||||
|
window:iconify()
|
||||||
|
end)
|
||||||
|
elseif options.unminimize_after then
|
||||||
|
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, function()
|
||||||
|
window:deiconify()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
if options.resize_after_width and options.resize_after_height then
|
if options.resize_after_width and options.resize_after_height then
|
||||||
window:resize(
|
window:resize(
|
||||||
|
@ -152,6 +163,13 @@ return function(class, title, sn_rules, callback, resize_increment, args)
|
||||||
if args.unmaximize_after then
|
if args.unmaximize_after then
|
||||||
options = options .. "unmaximize_after,"
|
options = options .. "unmaximize_after,"
|
||||||
end
|
end
|
||||||
|
if args.unminimize_after then
|
||||||
|
options = options .. "unminimize_after,"
|
||||||
|
end
|
||||||
|
if args.minimize_after then
|
||||||
|
options = options .. "minimize_after,"
|
||||||
|
end
|
||||||
|
|
||||||
if args.size then
|
if args.size then
|
||||||
options = table.concat {
|
options = table.concat {
|
||||||
options,
|
options,
|
||||||
|
|
|
@ -371,8 +371,38 @@ gears.table.merge(steps, {
|
||||||
|
|
||||||
if not c or counter ~= 2 then return end
|
if not c or counter ~= 2 then return end
|
||||||
|
|
||||||
|
c:kill()
|
||||||
|
|
||||||
|
client.disconnect_signal("request::geometry", geometry_handler)
|
||||||
|
|
||||||
|
test_client(nil,nil,nil,nil,nil,{minimize_after=true})
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end,
|
||||||
|
function()
|
||||||
|
-- Test minimization.
|
||||||
|
if #client.get() ~= 1 or not client.get()[1].minimized then return end
|
||||||
|
|
||||||
|
assert(client.get()[1].minimized)
|
||||||
|
client.get()[1]:kill()
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
function()
|
||||||
|
if #client.get() > 0 then return end
|
||||||
|
|
||||||
|
test_client(nil,nil,nil,nil,nil,{unminimize_after=true})
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
function()
|
||||||
|
if #client.get() ~= 1 or client.get()[1].minimized then return end
|
||||||
|
|
||||||
|
assert(not client.get()[1].minimized)
|
||||||
|
client.get()[1]:kill()
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
runner.run_steps(steps)
|
runner.run_steps(steps)
|
||||||
|
|
Loading…
Reference in New Issue