tests: compare screenshot test output to a reference image, on desktops.

This commit is contained in:
Sasha Szpakowski
2024-03-16 23:11:14 -03:00
parent a3c84ba409
commit 89f43ff48d
2 changed files with 17 additions and 3 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

+17 -3
View File
@@ -1452,15 +1452,29 @@ end
-- love.graphics.captureScreenshot
love.test.graphics.captureScreenshot = function(test)
love.graphics.captureScreenshot('example-screenshot.png')
test:waitFrames(10)
test:waitFrames(1)
-- need to wait until end of the frame for the screenshot
test:assertNotNil(love.filesystem.openFile('example-screenshot.png', 'r'))
test:assertTrue(love.filesystem.exists('example-screenshot.png'))
love.filesystem.remove('example-screenshot.png')
-- test callback version
local cbdata = nil
local prevtextcommand = TextCommand
TextCommand = "Capturing screenshot"
love.graphics.captureScreenshot(function (idata)
test:assertNotEquals(nil, idata, 'check we have image data')
cbdata = idata
end)
test:waitFrames(10)
test:waitFrames(1)
TextCommand = prevtextcommand
test:assertNotNil(cbdata)
if love.system.getOS() == "iOS" or love.system.getOS() == "Android" then
-- Mobile operating systems don't let us control the window resolution,
-- so we can't compare the reference image properly.
test:assertTrue(true, 'skip test')
else
test:compareImg(cbdata)
end
end