tests: Fix the tests then notify-send is not installed.

Fix #2684
This commit is contained in:
Emmanuel Lepage Vallee 2019-03-02 13:26:57 -05:00
parent b0cf594de5
commit 0b820b077d
1 changed files with 200 additions and 183 deletions

View File

@ -92,21 +92,45 @@ local function destroyed_callback(n, reason)
table.insert(destroyed, n)
end
naughty.connect_signal("destroyed", destroyed_callback)
-- Test vertical overlapping
local function test_overlap()
local wa = mouse.screen.workarea
for _, n1 in ipairs(active) do
assert(n1.box)
assert(n1.id)
-- Check for overlapping the workarea
assert(n1.box.y+default_height < wa.y+wa.height)
assert(n1.box.y >= wa.y)
-- Check for overlapping each other
for _, n2 in ipairs(active) do
assert(n2.box)
if n1 ~= n2 then
local geo1, geo2 = n1.box:geometry(), n2.box:geometry()
assert(geo1.height == geo2.height)
assert(geo1.height + 2*n1.box.border_width + naughty.config.spacing
== default_height)
if n1.position == n2.position then
assert(
geo1.y >= geo2.y+default_height or
geo2.y >= geo1.y+default_height
)
end
end
end
end
end
-- Set the default size.
table.insert(steps, function()
if not has_cmd_notify then return true end
spawn{ 'notify-send', 'title', 'message', '-t', '25000' }
return true
end)
table.insert(steps, function()
if not has_cmd_notify then return true end
if #active ~= 1 then return end
local n = active[1]
local n = naughty.notification {
title = "title",
message = "message"
}
assert(n.box)
local offset = 2*n.box.border_width
@ -116,6 +140,29 @@ table.insert(steps, function()
assert(default_width > 0)
assert(default_height > 0)
n:destroy()
-- This one doesn't count.
active, destroyed, reasons, counter = {}, {}, {}, 0
return true
end)
naughty.connect_signal("destroyed", destroyed_callback)
if has_cmd_notify then
table.insert(steps, function()
spawn{ 'notify-send', 'title', 'message', '-t', '25000' }
return true
end)
table.insert(steps, function()
if #active ~= 1 then return end
local n = active[1]
assert(n.box)
-- Make sure the expiration timer is started
assert(n.timer)
assert(n.timer.started)
@ -251,38 +298,6 @@ table.insert(steps, function()
return true
end)
-- Test vertical overlapping
local function test_overlap()
local wa = mouse.screen.workarea
for _, n1 in ipairs(active) do
assert(n1.box)
assert(n1.id)
-- Check for overlapping the workarea
assert(n1.box.y+default_height < wa.y+wa.height)
assert(n1.box.y >= wa.y)
-- Check for overlapping each other
for _, n2 in ipairs(active) do
assert(n2.box)
if n1 ~= n2 then
local geo1, geo2 = n1.box:geometry(), n2.box:geometry()
assert(geo1.height == geo2.height)
assert(geo1.height + 2*n1.box.border_width + naughty.config.spacing
== default_height)
if n1.position == n2.position then
assert(
geo1.y >= geo2.y+default_height or
geo2.y >= geo1.y+default_height
)
end
end
end
end
end
-- Check the lack of overlapping and the presence of the expected content.
table.insert(steps, function()
local wa = mouse.screen.workarea
@ -322,6 +337,8 @@ table.insert(steps, function()
return true
end)
end
local positions = {
"top_left" , "top_middle" , "top_right" ,
"bottom_left" , "bottom_middle" , "bottom_right" ,