From 46bd4543929e815ca1db071292155fc4b353c5b0 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Fri, 4 Dec 2020 20:34:23 +0000 Subject: [PATCH] simulator: test: Grey box stopwatch test Currently we can act on the controls but we cannot "see" the display in the test suite. That leads us to a slightly odd form of "grey box" testing. It's functionally black box testing but some of the asserts have to reach inside the components instead of looking at the display. Signed-off-by: Daniel Thompson --- wasp/boards/simulator/test_smoke.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/wasp/boards/simulator/test_smoke.py b/wasp/boards/simulator/test_smoke.py index 62d570b..d86b4e7 100644 --- a/wasp/boards/simulator/test_smoke.py +++ b/wasp/boards/simulator/test_smoke.py @@ -44,3 +44,24 @@ def test_app(system, name): for i in range(4): system.step() system.switch(system.quick_ring[0]) + +def test_stopwatch(system): + system.switch(system.apps['Timer']) + + system.step() + + wasp.watch.button.value(0) + system.step() + assert(system.app._started_at > 0) + wasp.watch.button.value(1) + + system.step() + system.step() + system.step() + + wasp.watch.button.value(0) + system.step() + assert(system.app._started_at == 0) + wasp.watch.button.value(1) + + system.step()