Skip to content

Commit d60ebf6

Browse files
committed
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.
1 parent 83e93d1 commit d60ebf6

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

testing/classes/TestMethod.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,12 @@ TestMethod = {
273273
local filename = 'love.test.graphics.' .. self.method .. '-' .. tostring(self.imgs) .. '.png'
274274
local expected_path = 'resources/expected_output/' .. filename
275275
local ok, chunk = pcall(love.filesystem.read, 'data', expected_path)
276-
if ok == false then return self:assertEquals(true, false, chunk) end
277-
local image_contents = chunk
276+
if ok == false then return self:assertEquals(true, false, chunk) end
277+
local image_contents = chunk
278278
ok, chunk = pcall(love.image.newImageData, chunk)
279279
if ok == false then return self:assertEquals(true, false, chunk) end
280280
-- Copy the expected file output to tempoutput/expected to keep HTML output working.
281-
love.filesystem.write('tempoutput/expected/' .. filename, image_contents)
281+
love.filesystem.write('tempoutput/expected/' .. filename, image_contents)
282282
local expected = chunk
283283
local iw = imgdata:getWidth()-2
284284
local ih = imgdata:getHeight()-2

testing/tests/window.lua

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ end
9494
-- @NOTE could prob add more checks on the flags here based on conf.lua
9595
love.test.window.getMode = function(test)
9696
local w, h, flags = love.window.getMode()
97-
test:assertEquals(360, w, 'check w')
98-
test:assertEquals(240, h, 'check h')
97+
if love._os ~= 'iOS' and love._os ~= 'Android' then
98+
test:assertEquals(360, w, 'check w')
99+
test:assertEquals(240, h, 'check h')
100+
end
99101
test:assertFalse(flags["fullscreen"], 'check fullscreen')
100102
end
101103

@@ -164,6 +166,11 @@ end
164166

165167
-- love.window.isMaximized
166168
love.test.window.isMaximized = function(test)
169+
if love._os == 'iOS' or love._os == 'Android' then
170+
test:skipTest('maximize is not available in mobile')
171+
return
172+
end
173+
167174
test:assertFalse(love.window.isMaximized(), 'check window not maximized')
168175
love.window.maximize()
169176
test:waitFrames(10)
@@ -175,6 +182,11 @@ end
175182

176183
-- love.window.isMinimized
177184
love.test.window.isMinimized = function(test)
185+
if love._os == 'iOS' or love._os == 'Android' then
186+
test:skipTest('minimize pauses execution in mobile')
187+
return
188+
end
189+
178190
-- check not minimized to start
179191
test:assertFalse(love.window.isMinimized(), 'check window not minimized')
180192
-- try to minimize
@@ -204,6 +216,11 @@ end
204216

205217
-- love.window.maximize
206218
love.test.window.maximize = function(test)
219+
if love._os == 'iOS' or love._os == 'Android' then
220+
test:skipTest('maximize is not available in mobile')
221+
return
222+
end
223+
207224
test:assertFalse(love.window.isMaximized(), 'check window not maximized')
208225
-- check maximizing is set
209226
love.window.maximize()
@@ -216,6 +233,11 @@ end
216233

217234
-- love.window.minimize
218235
love.test.window.minimize = function(test)
236+
if love._os == 'iOS' or love._os == 'Android' then
237+
test:skipTest('minimize pauses execution in mobile')
238+
return
239+
end
240+
219241
test:assertFalse(love.window.isMinimized(), 'check window not minimized')
220242
-- check minimizing is set
221243
love.window.minimize()

0 commit comments

Comments
 (0)