1
0
Fork 0

wasp: testapp: Sort tests alphabetically

This commit is contained in:
Daniel Thompson 2020-04-12 08:40:11 +01:00
parent 50ecff29ef
commit 64a97fce58

View file

@ -12,28 +12,28 @@ class TestApp():
ICON = icons.app ICON = icons.app
def __init__(self): def __init__(self):
self.tests = ('Touch', 'String', 'Wrap', 'Button', 'Crash', 'RLE') self.tests = ('Button', 'Crash', 'RLE', 'String', 'Touch', 'Wrap')
self.test = self.tests[0] self.test = self.tests[0]
self.scroll = wasp.widgets.ScrollIndicator() self.scroll = wasp.widgets.ScrollIndicator()
def foreground(self): def foreground(self):
"""Activate the application.""" """Activate the application."""
self.on_screen = ( -1, -1, -1, -1, -1, -1 ) self.on_screen = ( -1, -1, -1, -1, -1, -1 )
self.draw() self._draw()
wasp.system.request_event(wasp.EventMask.TOUCH | wasp.system.request_event(wasp.EventMask.TOUCH |
wasp.EventMask.SWIPE_UPDOWN | wasp.EventMask.SWIPE_UPDOWN |
wasp.EventMask.BUTTON) wasp.EventMask.BUTTON)
def press(self, button, state): def press(self, button, state):
draw = wasp.watch.drawable draw = wasp.watch.drawable
if self.test == 'Touch': if self.test == 'Button':
draw.string('Button', 0, 108, width=240)
if self.test == 'String':
self.benchmark_string()
elif self.test == 'Button':
draw.string('{}: {}'.format(button, state), 0, 108, width=240) draw.string('{}: {}'.format(button, state), 0, 108, width=240)
elif self.test == 'Crash': elif self.test == 'Crash':
self.crash() self.crash()
elif self.test == 'String':
self._benchmark_string()
elif self.test == 'Touch':
draw.string('Button', 0, 108, width=240)
def swipe(self, event): def swipe(self, event):
tests = self.tests tests = self.tests
@ -48,20 +48,20 @@ class TestApp():
if i < 0: if i < 0:
i = len(tests) - 1 i = len(tests) - 1
self.test = tests[i] self.test = tests[i]
self.draw() self._draw()
def touch(self, event): def touch(self, event):
if self.test == 'Touch': if self.test == 'RLE':
self._benchmark_rle()
elif self.test == 'String':
self._benchmark_string()
elif self.test == 'Touch':
wasp.watch.drawable.string('({}, {})'.format( wasp.watch.drawable.string('({}, {})'.format(
event[1], event[2]), 0, 108, width=240) event[1], event[2]), 0, 108, width=240)
elif self.test == 'String':
self.benchmark_string()
elif self.test == 'Wrap': elif self.test == 'Wrap':
self.benchmark_wrap() self._benchmark_wrap()
elif self.test == 'RLE':
self.benchmark_rle()
def benchmark_rle(self): def _benchmark_rle(self):
draw = wasp.watch.drawable draw = wasp.watch.drawable
draw.fill(0, 0, 30, 240, 240-30) draw.fill(0, 0, 30, 240, 240-30)
self.scroll.draw() self.scroll.draw()
@ -74,7 +74,7 @@ class TestApp():
del t del t
draw.string('{}s'.format(elapsed / 1000000), 12, 24+192) draw.string('{}s'.format(elapsed / 1000000), 12, 24+192)
def benchmark_string(self): def _benchmark_string(self):
draw = wasp.watch.drawable draw = wasp.watch.drawable
draw.fill(0, 0, 30, 240, 240-30) draw.fill(0, 0, 30, 240, 240-30)
self.scroll.draw() self.scroll.draw()
@ -90,7 +90,7 @@ class TestApp():
del t del t
draw.string('{}s'.format(elapsed / 1000000), 12, 24+192) draw.string('{}s'.format(elapsed / 1000000), 12, 24+192)
def benchmark_wrap(self): def _benchmark_wrap(self):
draw = wasp.watch.drawable draw = wasp.watch.drawable
draw.fill(0, 0, 30, 240, 240-30) draw.fill(0, 0, 30, 240, 240-30)
self.scroll.draw() self.scroll.draw()
@ -108,7 +108,7 @@ class TestApp():
del t del t
draw.string('{}s'.format(elapsed / 1000000), 12, 24+192) draw.string('{}s'.format(elapsed / 1000000), 12, 24+192)
def draw(self): def _draw(self):
"""Redraw the display from scratch.""" """Redraw the display from scratch."""
wasp.watch.display.mute(True) wasp.watch.display.mute(True)
draw = wasp.watch.drawable draw = wasp.watch.drawable