1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

tests: add tests for trezor.msg and trezor.ui.display

This commit is contained in:
Pavol Rusnak 2016-11-06 17:39:30 +01:00
parent 33b5436dcc
commit 161bb90e03
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 91 additions and 0 deletions

19
tests/test_trezor.msg.py Normal file
View File

@ -0,0 +1,19 @@
from common import *
from trezor.crypto import random
from trezor import msg
class TestMsg(unittest.TestCase):
def test_set_get_interfaces(self):
ifaces = msg.get_interfaces()
self.assertEqual(ifaces, ())
for n in range(1, 9):
ifaces = tuple((random.uniform(0x10000) for _ in range(n)))
msg.set_interfaces(ifaces)
ifaces2 = msg.get_interfaces()
self.assertEqual(ifaces, ifaces2)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,72 @@
from common import *
from trezor.crypto import random
from trezor.ui import display
class TestDisplay(unittest.TestCase):
def test_clear(self):
display.clear()
def test_refresh(self):
display.refresh()
def test_bar(self):
display.bar(0, 0, 10, 10, 0xFFFF)
def test_bar_radius(self):
display.bar_radius(0, 0, 10, 10, 0xFFFF, 0x0000, 16)
def test_image(self):
pass
def test_icon(self):
pass
def test_text(self):
display.text(120, 120, 'Test', 0, 0xFFFF, 0x0000)
def test_text_center(self):
display.text_center(120, 120, 'Test', 0, 0xFFFF, 0x0000)
def test_text_right(self):
display.text_right(120, 120, 'Test', 0, 0xFFFF, 0x0000)
def test_text_width(self):
display.text_width('Test', 0)
def test_qrcode(self):
display.qrcode(0, 0, 'Test', 4)
def test_loader(self):
display.loader(333, 0, 0xFFFF, 0x0000)
def test_orientation(self):
for o in [0, 90, 180, 270]:
display.orientation(o)
o2 = display.orientation()
self.assertEqual(o, o2)
def test_backlight(self):
for b in range(256):
display.backlight(b)
b2 = display.backlight()
self.assertEqual(b, b2)
def test_offset(self):
for x in range(-4, 5):
for y in range(-4, 5):
o = (x * 57, y * 57)
display.offset(o)
o2 = display.offset()
self.assertEqual(o, o2)
def test_raw(self):
pass
def test_save(self):
pass
if __name__ == '__main__':
unittest.main()