2016-12-12 18:47:35 +01:00
|
|
|
--- Test if the wallpaper function do not cause errors
|
|
|
|
|
|
|
|
local runner = require("_runner")
|
|
|
|
local wp = require("gears.wallpaper")
|
|
|
|
local color = require("gears.color")
|
|
|
|
local cairo = require( "lgi" ).cairo
|
|
|
|
local surface = require("gears.surface")
|
|
|
|
|
|
|
|
local steps = {}
|
|
|
|
|
|
|
|
local colors = {
|
|
|
|
"#000030",
|
|
|
|
{
|
|
|
|
type = "linear" ,
|
|
|
|
from = { 0, 0 },
|
|
|
|
to = { 0, 100 },
|
|
|
|
stops = {
|
|
|
|
{ 0, "#ff0000" },
|
|
|
|
{ 1, "#0000ff" }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
color("#043000"),
|
|
|
|
"#302E00",
|
|
|
|
"#002C30",
|
|
|
|
color("#300030AA"),
|
|
|
|
"#301C00",
|
|
|
|
"#140030",
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Dummy wallpaper
|
|
|
|
local img = cairo.ImageSurface.create(cairo.Format.ARGB32, 100, 100)
|
|
|
|
local cr = cairo.Context(img)
|
|
|
|
cr:set_source(color(colors[2]))
|
|
|
|
cr:rectangle(0,0,100,100)
|
|
|
|
cr:fill()
|
|
|
|
cr:paint()
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
|
|
|
assert(img)
|
|
|
|
assert(surface.load_uncached(img))
|
|
|
|
|
|
|
|
local w, h = surface.get_size(surface.load_uncached(img))
|
|
|
|
|
|
|
|
assert(w == 100)
|
|
|
|
assert(h == 100)
|
|
|
|
|
|
|
|
wp.fit(img, nil, nil)
|
|
|
|
|
|
|
|
wp.fit(img, screen[1], nil)
|
|
|
|
|
|
|
|
-- There is a delayed call for the last call, let it be processed before
|
|
|
|
-- adding more
|
|
|
|
return true
|
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
2016-12-27 21:39:08 +01:00
|
|
|
wp.fit(img, screen[1], "#00ff00")
|
2016-12-12 18:47:35 +01:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- There is a delayed call for the last call, let it be processed before
|
|
|
|
-- adding more
|
|
|
|
return true
|
2016-12-12 18:47:35 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
2016-12-27 21:39:08 +01:00
|
|
|
wp.centered(img, nil, nil)
|
|
|
|
wp.centered(img, screen[1], nil)
|
2016-12-12 18:47:35 +01:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- There is a delayed call for the last call, let it be processed before
|
|
|
|
-- adding more
|
|
|
|
return true
|
2016-12-12 18:47:35 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
2016-12-27 21:39:08 +01:00
|
|
|
wp.centered(img, screen[1], "#00ff00")
|
2016-12-12 18:47:35 +01:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
2016-12-12 18:47:35 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
2016-12-27 21:39:08 +01:00
|
|
|
wp.maximized(img, nil, nil, nil)
|
2016-12-12 18:47:35 +01:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- There is a delayed call for the last call, let it be processed before
|
|
|
|
-- adding more
|
|
|
|
return true
|
2016-12-12 18:47:35 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
2016-12-27 21:39:08 +01:00
|
|
|
wp.maximized(img, screen[1], nil, nil)
|
2016-12-12 18:47:35 +01:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- There is a delayed call for the last call, let it be processed before
|
|
|
|
-- adding more
|
|
|
|
return true
|
2016-12-12 18:47:35 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
wp.maximized(img, screen[1], false, nil)
|
|
|
|
wp.maximized(img, screen[1], true, nil)
|
2016-12-12 18:47:35 +01:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- There is a delayed call for the last call, let it be processed before
|
|
|
|
-- adding more
|
|
|
|
return true
|
2016-12-12 18:47:35 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
wp.maximized(img, screen[1], false, {x=10, y= 10})
|
|
|
|
wp.maximized(img, screen[1], true, {x=10, y= 10})
|
2016-12-12 18:47:35 +01:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
2016-12-12 18:47:35 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
2016-12-27 21:39:08 +01:00
|
|
|
wp.tiled(img, nil, nil)
|
|
|
|
wp.tiled(img, screen[1], nil)
|
2016-12-12 18:47:35 +01:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- There is a delayed call for the last call, let it be processed before
|
|
|
|
-- adding more
|
|
|
|
return true
|
2016-12-12 18:47:35 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
2016-12-27 21:39:08 +01:00
|
|
|
wp.tiled(img, screen[1], {x=10, y= 10})
|
2016-12-12 18:47:35 +01:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
2016-12-12 18:47:35 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
table.insert(steps, function()
|
2016-12-27 21:39:08 +01:00
|
|
|
for _, c in ipairs(colors) do
|
|
|
|
wp.set(c)
|
|
|
|
end
|
2016-12-12 18:47:35 +01:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
2016-12-12 18:47:35 +01:00
|
|
|
end)
|
|
|
|
|
2021-05-24 08:13:26 +02:00
|
|
|
-- Make sure passing `nil` doesn't crash Awesome.
|
|
|
|
table.insert(steps, function()
|
|
|
|
|
|
|
|
root._wallpaper(nil)
|
|
|
|
root.wallpaper(nil)
|
|
|
|
|
|
|
|
return true
|
|
|
|
end)
|
|
|
|
|
2016-12-12 18:47:35 +01:00
|
|
|
|
|
|
|
runner.run_steps(steps)
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|