mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
2875a96e92
- update main love readme to include note on tests - added module tests for Sensor, Keyboard, Touch, Joystick, Mouse, and Love (for hooks + basic love-level methods) - general clean-up of main class logic - couple fixes for runner-specific failures (physics.Joint, audio.getActiveSourceCount, mouse.getPosition) - change window.close test to run last
74 lines
2.2 KiB
Lua
74 lines
2.2 KiB
Lua
-- love.keyboard
|
|
-- @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.keyboard.getKeyFromScancode
|
|
love.test.keyboard.getKeyFromScancode = function(test)
|
|
local key = love.keyboard.getKeyFromScancode('a')
|
|
test:assertEquals('a', key, 'check key')
|
|
end
|
|
|
|
|
|
-- love.keyboard.getScancodeFromKey
|
|
love.test.keyboard.getScancodeFromKey = function(test)
|
|
local scancode = love.keyboard.getScancodeFromKey('a')
|
|
test:assertEquals('a', scancode, 'check scancode')
|
|
end
|
|
|
|
|
|
-- love.keyboard.hasKeyRepeat
|
|
love.test.keyboard.hasKeyRepeat = function(test)
|
|
local enabled = love.keyboard.hasKeyRepeat()
|
|
test:assertNotNil(enabled)
|
|
end
|
|
|
|
|
|
-- love.keyboard.hasScreenKeyboard
|
|
love.test.keyboard.hasScreenKeyboard = function(test)
|
|
local enabled = love.keyboard.hasScreenKeyboard()
|
|
test:assertNotNil(enabled)
|
|
end
|
|
|
|
|
|
-- love.keyboard.hasTextInput
|
|
love.test.keyboard.hasTextInput = function(test)
|
|
local enabled = love.keyboard.hasTextInput()
|
|
test:assertNotNil(enabled)
|
|
end
|
|
|
|
|
|
-- love.keyboard.isDown
|
|
love.test.keyboard.isDown = function(test)
|
|
local keydown = love.keyboard.isDown('a')
|
|
test:assertNotNil(keydown)
|
|
end
|
|
|
|
|
|
-- love.keyboard.isScancodeDown
|
|
love.test.keyboard.isScancodeDown = function(test)
|
|
local keydown = love.keyboard.isScancodeDown('a')
|
|
test:assertNotNil(keydown)
|
|
end
|
|
|
|
|
|
-- love.keyboard.setKeyRepeat
|
|
love.test.keyboard.setKeyRepeat = function(test)
|
|
love.keyboard.setKeyRepeat(true)
|
|
local enabled = love.keyboard.hasKeyRepeat()
|
|
test:assertEquals(true, enabled, 'check key repeat set')
|
|
end
|
|
|
|
|
|
-- love.keyboard.setTextInput
|
|
love.test.keyboard.setTextInput = function(test)
|
|
love.keyboard.setTextInput(false)
|
|
test:assertEquals(false, love.keyboard.hasTextInput(), 'check disable text input')
|
|
end
|