Skip to content

Commit

Permalink
Test: Add necessary skips for mobile devices in love.window tests.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MikuAuahDark committed Mar 16, 2024
1 parent 83e93d1 commit d60ebf6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
6 changes: 3 additions & 3 deletions testing/classes/TestMethod.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 24 additions & 2 deletions testing/tests/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit d60ebf6

Please sign in to comment.