From bb4e76d85222c263c4486ad1722df44200fcabf2 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Sun, 5 Apr 2020 09:46:25 +0100 Subject: [PATCH] wasp: testapp: Add an option to force an exception We will shortly be adding machinary to handle application errors more gracefully. This is a useful way to force an application error! --- wasp/apps/testapp.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/wasp/apps/testapp.py b/wasp/apps/testapp.py index e7016d7..3beca50 100644 --- a/wasp/apps/testapp.py +++ b/wasp/apps/testapp.py @@ -9,7 +9,7 @@ class TestApp(): """ def __init__(self): - self.tests = ('Touch', 'String', 'Button') + self.tests = ('Touch', 'String', 'Button', 'Crash') self.test = self.tests[0] def foreground(self): @@ -28,6 +28,8 @@ class TestApp(): self.benchmark_string() elif self.test == 'Button': draw.string('{}: {}'.format(button, state), 0, 108, width=240) + elif self.test == 'Crash': + self.crash() def swipe(self, event): tests = self.tests @@ -69,7 +71,13 @@ class TestApp(): def draw(self): """Redraw the display from scratch.""" wasp.watch.display.mute(True) - wasp.watch.drawable.fill() - wasp.watch.drawable.string('{} test'.format(self.test), + draw = wasp.watch.drawable + draw.fill() + draw.string('{} test'.format(self.test), 0, 6, width=240) + + if self.test == 'Crash': + draw.string("Press button to", 12, 24+24) + draw.string("throw exception.", 12, 24+48) + wasp.watch.display.mute(False)