From e088fe9aed5c0500b21de7466930314ef15726c8 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 6 Sep 2022 00:43:26 -0700 Subject: [PATCH] tests: Improve the awful.screenshot test coverage. --- tests/test-screenshot.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/test-screenshot.lua b/tests/test-screenshot.lua index af84fd2e9..2e60f46f3 100644 --- a/tests/test-screenshot.lua +++ b/tests/test-screenshot.lua @@ -5,6 +5,7 @@ local awful = require("awful") local wibox = require("wibox") local spawn = require("awful.spawn") local gsurface = require("gears.surface") +local gdebug = require("gears.debug") local lgi = require('lgi') local cairo = lgi.cairo local gdk = lgi.require('Gdk', '3.0') @@ -478,4 +479,38 @@ table.insert(steps, function() return true end) +table.insert(steps, function() + local ss = awful.screenshot { auto_save_delay = 10 } + + -- Reach into some `if`. + assert(not ss.selected_geometry) + assert(not ss.surface) + assert(#ss.surfaces == 0) + ss.auto_save_delay = 0 + ss.minimum_size = 2 + ss.minimum_size = {width = 1, height = 1} + ss.minimum_size = nil + assert(ss.surface) + assert(next(ss.surfaces) ~= nil) + + local count = 0 + + local err = gdebug.print_error + + function gdebug.print_error() + count = count + 1 + end + + -- Cause some validation failures. + ss.prefix = "//////" + assert(count == 1) + ss.directory = "/tmp/////" + ss.directory = "/tmp" + ss.directory = "/root/" + assert(count == 2) + + gdebug.print_error = err + return true +end) + require("_runner").run_steps(steps)