From 89f43ff48dea0d3bd876661e563a8b4e71f05cb7 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Sat, 16 Mar 2024 23:11:14 -0300 Subject: [PATCH] tests: compare screenshot test output to a reference image, on desktops. --- ...love.test.graphics.captureScreenshot-1.png | Bin 0 -> 831 bytes testing/tests/graphics.lua | 20 +++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 testing/output/expected/love.test.graphics.captureScreenshot-1.png 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 0000000000000000000000000000000000000000..f26a3a081ca0a010a324a7c003c05aa4ae0643af GIT binary patch literal 831 zcmV-F1Hk-=P)><;Wih9PR5Asg5;fZD)&o!5w`H|#V6<9h(<+<$zS-pRXK8gUsJ`(mv@4yh`&mIJA^S~^TNf7B z&fP9{9@^xM)UG;Jg=8K5Cbw!v?d8TK7M;Ik*))GrugiYMj%=PzcE8D)Hs`1n>d{{#pnI|p1E6<4 zmLO#Wh~D{Ff|L;)y7+J(eEf7gib2Q-5M9WQ*`M(#p=FHV(AftwUAln#Sb~rdAiDX8 z&~yP8f{+m$dgY_$PmnPJM6Z0b2pPelr~BwvjR4VpKZA8Buf>{|Nos zI4WAvZ$p<`=5SG!xf>PTax{)2qXns8(!TBFfuG#ZUYqtR$I8jVJy(P(~o{sIxSYR80gR?GkZ002ov JPDHLkV1g&whUfqQ literal 0 HcmV?d00001 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