From d60ebf6d700ee0e0a2f6704d0762c553e5cb1ddb Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Sat, 16 Mar 2024 14:13:10 +0800 Subject: [PATCH] Test: Add necessary skips for mobile devices in love.window tests. In particular: * `love.window.getMode()` width and height always return the fullscreen dimensions. * Maximization function is undefined/unavailable. * Minimizing in mobile causes the test suites to be paused. --- testing/classes/TestMethod.lua | 6 +++--- testing/tests/window.lua | 26 ++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/testing/classes/TestMethod.lua b/testing/classes/TestMethod.lua index f7ace98ec..6716abc1a 100644 --- a/testing/classes/TestMethod.lua +++ b/testing/classes/TestMethod.lua @@ -273,12 +273,12 @@ TestMethod = { local filename = 'love.test.graphics.' .. self.method .. '-' .. tostring(self.imgs) .. '.png' local expected_path = 'resources/expected_output/' .. filename local ok, chunk = pcall(love.filesystem.read, 'data', expected_path) - if ok == false then return self:assertEquals(true, false, chunk) end - local image_contents = chunk + if ok == false then return self:assertEquals(true, false, chunk) end + local image_contents = chunk ok, chunk = pcall(love.image.newImageData, chunk) if ok == false then return self:assertEquals(true, false, chunk) end -- Copy the expected file output to tempoutput/expected to keep HTML output working. - love.filesystem.write('tempoutput/expected/' .. filename, image_contents) + love.filesystem.write('tempoutput/expected/' .. filename, image_contents) local expected = chunk local iw = imgdata:getWidth()-2 local ih = imgdata:getHeight()-2 diff --git a/testing/tests/window.lua b/testing/tests/window.lua index 98cfc2f43..f70d1d856 100644 --- a/testing/tests/window.lua +++ b/testing/tests/window.lua @@ -94,8 +94,10 @@ end -- @NOTE could prob add more checks on the flags here based on conf.lua love.test.window.getMode = function(test) local w, h, flags = love.window.getMode() - test:assertEquals(360, w, 'check w') - test:assertEquals(240, h, 'check h') + if love._os ~= 'iOS' and love._os ~= 'Android' then + test:assertEquals(360, w, 'check w') + test:assertEquals(240, h, 'check h') + end test:assertFalse(flags["fullscreen"], 'check fullscreen') end @@ -164,6 +166,11 @@ end -- love.window.isMaximized love.test.window.isMaximized = function(test) + if love._os == 'iOS' or love._os == 'Android' then + test:skipTest('maximize is not available in mobile') + return + end + test:assertFalse(love.window.isMaximized(), 'check window not maximized') love.window.maximize() test:waitFrames(10) @@ -175,6 +182,11 @@ end -- love.window.isMinimized love.test.window.isMinimized = function(test) + if love._os == 'iOS' or love._os == 'Android' then + test:skipTest('minimize pauses execution in mobile') + return + end + -- check not minimized to start test:assertFalse(love.window.isMinimized(), 'check window not minimized') -- try to minimize @@ -204,6 +216,11 @@ end -- love.window.maximize love.test.window.maximize = function(test) + if love._os == 'iOS' or love._os == 'Android' then + test:skipTest('maximize is not available in mobile') + return + end + test:assertFalse(love.window.isMaximized(), 'check window not maximized') -- check maximizing is set love.window.maximize() @@ -216,6 +233,11 @@ end -- love.window.minimize love.test.window.minimize = function(test) + if love._os == 'iOS' or love._os == 'Android' then + test:skipTest('minimize pauses execution in mobile') + return + end + test:assertFalse(love.window.isMinimized(), 'check window not minimized') -- check minimizing is set love.window.minimize()