summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2019-05-18 23:45:52 +0100
committerVincent Sanders <vince@kyllikki.org>2019-05-18 23:45:52 +0100
commitea9bc4e2bef98278e4df2b84666c6419d74d2f52 (patch)
tree93cb9dde560c00f58f2ed3aff119b8cb9cf950fc
parentcb178b43bebd3217325fcd4de7ee6826ff48e002 (diff)
downloadnetsurf-ea9bc4e2bef98278e4df2b84666c6419d74d2f52.tar.gz
netsurf-ea9bc4e2bef98278e4df2b84666c6419d74d2f52.tar.bz2
allow block to use elapsed timer as a condition
-rwxr-xr-xtest/monkey_driver.py37
1 files changed, 28 insertions, 9 deletions
diff --git a/test/monkey_driver.py b/test/monkey_driver.py
index 61286ff96..0cac26062 100755
--- a/test/monkey_driver.py
+++ b/test/monkey_driver.py
@@ -108,17 +108,28 @@ def assert_browser(ctx):
def conds_met(ctx, conds):
for cond in conds:
- status = cond['status']
- window = cond['window']
- assert(status == "complete") # TODO: Add more status support?
- if window == "*all*":
- for win in ctx['windows'].items():
- if win[1].throbbing:
+ if 'window' in cond.keys():
+ status = cond['status']
+ window = cond['window']
+ assert(status == "complete") # TODO: Add more status support?
+ if window == "*all*":
+ for win in ctx['windows'].items():
+ if win[1].throbbing:
+ return False
+ else:
+ win = ctx['windows'][window]
+ if win.throbbing:
return False
+ elif 'timer' in cond.keys():
+ timer = cond['timer']
+ elapsed = cond['elapsed']
+ assert_browser(ctx)
+ assert(ctx['timers'].get(timer) is not None)
+ taken = time.time() - ctx['timers'][timer]["start"]
+ assert(taken < elapsed)
else:
- win = ctx['windows'][window]
- if win.throbbing:
- return False
+ raise AssertionError("Unknown condition: {}".format(repr(cond)))
+
return True
def run_test_step_action_launch(ctx, step):
@@ -249,6 +260,13 @@ def run_test_step_action_timer_start(ctx, step):
ctx['timers'][tag] = {}
ctx['timers'][tag]["start"] = time.time()
+def run_test_step_action_timer_restart(ctx, step):
+ print(get_indent(ctx) + "Action: " + step["action"])
+ timer = step['timer']
+ assert_browser(ctx)
+ assert(ctx['timers'].get(timer) is not None)
+ ctx['timers'][timer]["start"] = time.time()
+
def run_test_step_action_timer_stop(ctx, step):
print(get_indent(ctx) + "Action: " + step["action"])
timer = step['timer']
@@ -344,6 +362,7 @@ step_handlers = {
"block": run_test_step_action_block,
"repeat": run_test_step_action_repeat,
"timer-start": run_test_step_action_timer_start,
+ "timer-restart":run_test_step_action_timer_restart,
"timer-stop": run_test_step_action_timer_stop,
"timer-check": run_test_step_action_timer_check,
"plot-check": run_test_step_action_plot_check,