summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-12 18:15:15 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-12 18:15:15 (GMT)
commit941d4a264d53642b14e951523be3473765114476 (patch)
tree950d020f3b22d1ea0034edd7896d8c8085bb9398
parente3b2c7bf7d7a4cc7dc2cafc28f35e30f44260a21 (diff)
boards: simulator: Additional tests
Start to work (most of) the code paths in the self test application. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
-rw-r--r--wasp/boards/simulator/display.py23
-rw-r--r--wasp/boards/simulator/test_smoke.py50
2 files changed, 73 insertions, 0 deletions
diff --git a/wasp/boards/simulator/display.py b/wasp/boards/simulator/display.py
index 379760c..0fa6ef7 100644
--- a/wasp/boards/simulator/display.py
+++ b/wasp/boards/simulator/display.py
@@ -173,6 +173,29 @@ class CST816SSim():
self.regs[6] = up_y;
self.raise_interrupt(pins)
+ def press(self, x, y):
+ pins = wasp.watch.Pin.pins
+ self.regs[1] = 5
+ self.regs[4] = x
+ self.regs[6] = y
+ self.raise_interrupt(pins)
+
+ def swipe(self, direction):
+ pins = wasp.watch.Pin.pins
+ if direction ==' up':
+ self.regs[1] = 1
+ elif direction == 'down':
+ self.regs[1] = 2
+ elif direction == 'left':
+ self.regs[1] = 4
+ elif direction == 'right':
+ self.regs[1] = 3
+ elif direction == 'next':
+ # Allow NEXT to be tested on the simulator
+ self.regs[1] = 253
+ self.regs[3] = 0x80
+ self.raise_interrupt(pins)
+
def raise_interrupt(self, pins):
pins['TP_INT'].raise_irq()
diff --git a/wasp/boards/simulator/test_smoke.py b/wasp/boards/simulator/test_smoke.py
index d86b4e7..4d8307b 100644
--- a/wasp/boards/simulator/test_smoke.py
+++ b/wasp/boards/simulator/test_smoke.py
@@ -8,6 +8,9 @@ def step():
time.sleep(0.1)
wasp.system.step = step
+wasp.watch.touch.press = wasp.watch.touch.i2c.sim.press
+wasp.watch.touch.swipe = wasp.watch.touch.i2c.sim.swipe
+
wasp.system.apps = {}
for app in wasp.system.quick_ring + wasp.system.launcher_ring:
wasp.system.apps[app.NAME] = app
@@ -65,3 +68,50 @@ def test_stopwatch(system):
wasp.watch.button.value(1)
system.step()
+
+def test_selftests(system):
+ """Walk though each screen in the Self Test.
+
+ This is a simple "does it crash" test and the only thing we do to stimulate
+ the app is press in the centre of the screen. For most of the tests that
+ will do something useful! For example it will run the benchmark for every
+ one of the benchmark tests.
+ """
+ system.switch(system.apps['Self Test'])
+ system.step()
+
+ start_point = system.app.test
+
+ for i in range(len(system.app.tests)):
+ wasp.watch.touch.press(120, 120)
+ system.step()
+ wasp.watch.touch.swipe('down')
+ system.step()
+
+ assert(start_point == system.app.test)
+
+def test_selftest_crash(system):
+ system.switch(system.apps['Self Test'])
+ system.step()
+
+ def select(name):
+ for i in range(len(system.app.tests)):
+ if system.app.test == name:
+ break
+ wasp.watch.touch.swipe('down')
+ system.step()
+ assert system.app.test == name
+
+ select('Crash')
+
+ wasp.watch.button.value(0)
+ with pytest.raises(Exception):
+ system.step()
+
+ # Get back to a safe state for the next test!
+ try:
+ wasp.watch.button.value(1)
+ system.step()
+ except:
+ pass
+ system.step()