mirror of
https://github.com/love2d/love.git
synced 2026-08-12 00:20:52 +02:00
tests: compare screenshot test output to a reference image, on desktops.
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 831 B |
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user