From 6615772d10b27f828dc2ba1713de131c7eb217fc Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 28 Oct 2021 20:24:47 -0700 Subject: [PATCH] tests: Extend the test client to handle minimization. The goal is to make the coverage less flacky by explicitly handling some events. --- tests/_client.lua | 26 ++++++++++++++++++++++---- tests/test-maximize.lua | 32 +++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/tests/_client.lua b/tests/_client.lua index d86d9d252..5b58f7923 100644 --- a/tests/_client.lua +++ b/tests/_client.lua @@ -10,10 +10,11 @@ end local test_client_source = [[ pcall(require, 'luarocks.loader') -local lgi = require 'lgi' -local Gdk = lgi.require('Gdk') -local Gtk = lgi.require('Gtk') -local Gio = lgi.require('Gio') +local lgi = require 'lgi' +local GLib = lgi.require('GLib') +local Gdk = lgi.require('Gdk') +local Gtk = lgi.require('Gtk') +local Gio = lgi.require('Gio') Gtk.init() local function open_window(class, title, options) @@ -40,6 +41,8 @@ local function open_window(class, title, options) end if options.maximize_before then window:maximize() + elseif options.unminimize_after then + window:iconify() end window:set_wmclass(class, class) window:show_all() @@ -47,6 +50,14 @@ local function open_window(class, title, options) window:maximize() elseif options.unmaximize_after then 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 if options.resize_after_width and options.resize_after_height then window:resize( @@ -152,6 +163,13 @@ return function(class, title, sn_rules, callback, resize_increment, args) if args.unmaximize_after then options = options .. "unmaximize_after," 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 options = table.concat { options, diff --git a/tests/test-maximize.lua b/tests/test-maximize.lua index 8f28b25d1..2b478e814 100644 --- a/tests/test-maximize.lua +++ b/tests/test-maximize.lua @@ -371,8 +371,38 @@ gears.table.merge(steps, { 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 - 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)