keyboard.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. -- love.keyboard
  2. -- @NOTE we can't test this module fully as it's hardware dependent
  3. -- however we can test methods do what is expected and can handle certain params
  4. --------------------------------------------------------------------------------
  5. --------------------------------------------------------------------------------
  6. ------------------------------------METHODS-------------------------------------
  7. --------------------------------------------------------------------------------
  8. --------------------------------------------------------------------------------
  9. -- love.keyboard.getKeyFromScancode
  10. love.test.keyboard.getKeyFromScancode = function(test)
  11. test:assertEquals('function', type(love.keyboard.getKeyFromScancode))
  12. end
  13. -- love.keyboard.getScancodeFromKey
  14. love.test.keyboard.getScancodeFromKey = function(test)
  15. test:assertEquals('function', type(love.keyboard.getScancodeFromKey))
  16. end
  17. -- love.keyboard.hasKeyRepeat
  18. love.test.keyboard.hasKeyRepeat = function(test)
  19. local enabled = love.keyboard.hasKeyRepeat()
  20. test:assertNotNil(enabled)
  21. end
  22. -- love.keyboard.hasScreenKeyboard
  23. love.test.keyboard.hasScreenKeyboard = function(test)
  24. local enabled = love.keyboard.hasScreenKeyboard()
  25. test:assertNotNil(enabled)
  26. end
  27. -- love.keyboard.hasTextInput
  28. love.test.keyboard.hasTextInput = function(test)
  29. local enabled = love.keyboard.hasTextInput()
  30. test:assertNotNil(enabled)
  31. end
  32. -- love.keyboard.isDown
  33. love.test.keyboard.isDown = function(test)
  34. local keydown = love.keyboard.isDown('a')
  35. test:assertNotNil(keydown)
  36. end
  37. -- love.keyboard.isScancodeDown
  38. love.test.keyboard.isScancodeDown = function(test)
  39. local keydown = love.keyboard.isScancodeDown('a')
  40. test:assertNotNil(keydown)
  41. end
  42. -- love.keyboard.setKeyRepeat
  43. love.test.keyboard.setKeyRepeat = function(test)
  44. love.keyboard.setKeyRepeat(true)
  45. local enabled = love.keyboard.hasKeyRepeat()
  46. test:assertEquals(true, enabled, 'check key repeat set')
  47. end
  48. -- love.keyboard.setTextInput
  49. love.test.keyboard.setTextInput = function(test)
  50. love.keyboard.setTextInput(false)
  51. test:assertEquals(false, love.keyboard.hasTextInput(), 'check disable text input')
  52. end