system.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. -- love.system
  2. -- love.system.getClipboardText
  3. love.test.system.getClipboardText = function(test)
  4. -- ignore if not using window
  5. if love.test.windowmode == false then return test:skipTest('clipboard only available in window mode') end
  6. -- setup
  7. love.system.setClipboardText('helloworld')
  8. -- test
  9. test:assertEquals('helloworld', love.system.getClipboardText(), 'check clipboard match')
  10. end
  11. -- love.system.getOS
  12. love.test.system.getOS = function(test)
  13. local os = love.system.getOS()
  14. test:assertMatch({'OS X', 'Windows', 'Linux', 'Android', 'iOS'}, os, 'check value matches')
  15. end
  16. -- love.system.getPowerInfo
  17. love.test.system.getPowerInfo = function(test)
  18. local state, percent, seconds = love.system.getPowerInfo()
  19. test:assertMatch({'unknown', 'battery', 'nobattery', 'charging', 'charged'}, state, 'check value matches')
  20. if percent ~= nil then
  21. test:assertRange(percent, 0, 100, 'check value within range')
  22. end
  23. if seconds ~= nil then
  24. test:assertRange(seconds, 0, 100, 'check value within range')
  25. end
  26. end
  27. -- love.system.getProcessorCount
  28. love.test.system.getProcessorCount = function(test)
  29. test:assertGreaterEqual(0, love.system.getProcessorCount(), 'check not nil') -- youd hope right
  30. end
  31. -- love.system.hasBackgroundMusic
  32. love.test.system.hasBackgroundMusic = function(test)
  33. test:assertNotEquals(nil, love.system.hasBackgroundMusic(), 'check not nil')
  34. end
  35. -- love.system.openURL
  36. love.test.system.openURL = function(test)
  37. test:skipTest('gets annoying to test everytime')
  38. --test:assertNotEquals(nil, love.system.openURL('https://love2d.org'), 'check open URL')
  39. end
  40. -- love.system.getClipboardText
  41. love.test.system.setClipboardText = function(test)
  42. -- ignore if not using window
  43. if love.test.windowmode == false then return test:skipTest('clipboard only available in window mode') end
  44. -- test
  45. love.system.setClipboardText('helloworld')
  46. test:assertEquals('helloworld', love.system.getClipboardText(), 'check set text')
  47. end
  48. -- love.system.vibrate
  49. -- @NOTE cant really test this
  50. love.test.system.vibrate = function(test)
  51. test:skipTest('cant really test this')
  52. end