diff --git a/testing/output/expected/love.test.graphics.captureScreenshot-1.png b/testing/output/expected/love.test.graphics.captureScreenshot-1.png new file mode 100644 index 000000000..f26a3a081 Binary files /dev/null and b/testing/output/expected/love.test.graphics.captureScreenshot-1.png differ diff --git a/testing/tests/graphics.lua b/testing/tests/graphics.lua index a7bf8e970..860d82099 100644 --- a/testing/tests/graphics.lua +++ b/testing/tests/graphics.lua @@ -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