-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
119 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
-- love.joystick | ||
-- @NOTE we can't test this module fully as it's hardware dependent | ||
-- however we can test methods do what is expected and can handle certain params | ||
|
||
-------------------------------------------------------------------------------- | ||
-------------------------------------------------------------------------------- | ||
------------------------------------METHODS------------------------------------- | ||
-------------------------------------------------------------------------------- | ||
-------------------------------------------------------------------------------- | ||
|
||
|
||
-- love.joystick.getGamepadMappingString | ||
love.test.joystick.getGamepadMappingString = function(test) | ||
local mapping = love.joystick.getGamepadMappingString('faker') | ||
test:assertEquals(nil, mapping, 'check no mapping for fake gui') | ||
end | ||
|
||
|
||
-- love.joystick.getJoystickCount | ||
love.test.joystick.getJoystickCount = function(test) | ||
local count = love.joystick.getJoystickCount() | ||
test:assertEquals(0, count, 'check no joysticks') | ||
end | ||
|
||
|
||
-- love.joystick.getJoysticks | ||
love.test.joystick.getJoysticks = function(test) | ||
local joysticks = love.joystick.getJoysticks() | ||
test:assertEquals(0, #joysticks, 'check no joysticks') | ||
end | ||
|
||
|
||
-- love.joystick.loadGamepadMappings | ||
love.test.joystick.loadGamepadMappings = function(test) | ||
local ok, err = pcall(love.joystick.loadGamepadMappings, 'fakefile.txt') | ||
test:assertEquals(false, ok, 'check invalid file') | ||
love.joystick.loadGamepadMappings('resources/mappings.txt') | ||
end | ||
|
||
|
||
-- love.joystick.saveGamepadMappings | ||
love.test.joystick.saveGamepadMappings = function(test) | ||
love.joystick.loadGamepadMappings('resources/mappings.txt') | ||
local mapping = love.joystick.saveGamepadMappings() | ||
test:assertGreaterEqual(0, #mapping, 'check something mapped') | ||
end | ||
|
||
|
||
-- love.joystick.setGamepadMapping | ||
love.test.joystick.setGamepadMapping = function(test) | ||
local guid = '030000005e040000130b000011050000' | ||
local mappings = { | ||
love.joystick.setGamepadMapping(guid, 'a', 'button', 1, nil), | ||
love.joystick.setGamepadMapping(guid, 'b', 'button', 2, nil), | ||
love.joystick.setGamepadMapping(guid, 'x', 'button', 3, nil), | ||
love.joystick.setGamepadMapping(guid, 'y', 'button', 4, nil), | ||
love.joystick.setGamepadMapping(guid, 'back', 'button', 5, nil), | ||
love.joystick.setGamepadMapping(guid, 'start', 'button', 6, nil), | ||
love.joystick.setGamepadMapping(guid, 'guide', 'button', 7, nil), | ||
love.joystick.setGamepadMapping(guid, 'leftstick', 'button', 8, nil), | ||
love.joystick.setGamepadMapping(guid, 'leftshoulder', 'button', 9, nil), | ||
love.joystick.setGamepadMapping(guid, 'rightstick', 'button', 10, nil), | ||
love.joystick.setGamepadMapping(guid, 'rightshoulder', 'button', 11, nil), | ||
love.joystick.setGamepadMapping(guid, 'dpup', 'button', 12, nil), | ||
love.joystick.setGamepadMapping(guid, 'dpdown', 'button', 13, nil), | ||
love.joystick.setGamepadMapping(guid, 'dpleft', 'button', 14, nil), | ||
love.joystick.setGamepadMapping(guid, 'dpright', 'button', 15, nil), | ||
love.joystick.setGamepadMapping(guid, 'dpup', 'button', 12, 'u'), | ||
love.joystick.setGamepadMapping(guid, 'dpdown', 'button', 13, 'd'), | ||
love.joystick.setGamepadMapping(guid, 'dpleft', 'button', 14, 'l'), | ||
love.joystick.setGamepadMapping(guid, 'dpright', 'button', 15, 'r'), | ||
love.joystick.setGamepadMapping(guid, 'dpup', 'hat', 12, 'lu'), | ||
love.joystick.setGamepadMapping(guid, 'dpdown', 'hat', 13, 'ld'), | ||
love.joystick.setGamepadMapping(guid, 'dpleft', 'hat', 14, 'ru'), | ||
love.joystick.setGamepadMapping(guid, 'dpright', 'hat', 15, 'rd'), | ||
love.joystick.setGamepadMapping(guid, 'leftstick', 'axis', 8, 'c') | ||
} | ||
for m=1,#mappings do | ||
test:assertEquals(true, mappings[m], 'check mapping #' .. tostring(m)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
-- love.touch | ||
-- @NOTE we can't test this module fully as it's hardware dependent | ||
-- however we can test methods do what is expected and can handle certain params | ||
|
||
-------------------------------------------------------------------------------- | ||
-------------------------------------------------------------------------------- | ||
------------------------------------METHODS------------------------------------- | ||
-------------------------------------------------------------------------------- | ||
-------------------------------------------------------------------------------- | ||
|
||
|
||
-- love.touch.getPosition | ||
-- @TODO is there a way to fake the touchid pointer? | ||
love.test.touch.getPosition = function(test) | ||
test:assertNotNil(love.touch.getPosition) | ||
test:assertEquals('function', type(love.touch.getPosition)) | ||
end | ||
|
||
|
||
-- love.touch.getPressure | ||
-- @TODO is there a way to fake the touchid pointer? | ||
love.test.touch.getPressure = function(test) | ||
test:assertNotNil(love.touch.getPressure) | ||
test:assertEquals('function', type(love.touch.getPressure)) | ||
end | ||
|
||
|
||
-- love.touch.getTouches | ||
love.test.touch.getTouches = function(test) | ||
local touches = love.touch.getTouches() | ||
test:assertNotNil(touches) | ||
test:assertEquals(0, #touches, 'check no touches') | ||
end |