summaryrefslogtreecommitdiff
path: root/test/monkey_driver.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/monkey_driver.py')
-rwxr-xr-xtest/monkey_driver.py34
1 files changed, 22 insertions, 12 deletions
diff --git a/test/monkey_driver.py b/test/monkey_driver.py
index 0cac26062..f1ba115c0 100755
--- a/test/monkey_driver.py
+++ b/test/monkey_driver.py
@@ -107,30 +107,37 @@ def assert_browser(ctx):
assert(not ctx['browser'].stopped)
def conds_met(ctx, conds):
+ # for each condition listed determine if they have been met
+ # efectively this is condition1 | condition2
for cond in conds:
- if 'window' in cond.keys():
+ if '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"]
+ if (taken >= elapsed):
+ return True
+ elif 'window' in cond.keys():
status = cond['status']
window = cond['window']
assert(status == "complete") # TODO: Add more status support?
if window == "*all*":
+ # all windows must be not throbbing
+ throbbing = False
for win in ctx['windows'].items():
if win[1].throbbing:
- return False
+ throbbing = True
+ if not throbbing:
+ return True
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)
+ if win.throbbing is False:
+ return True
else:
raise AssertionError("Unknown condition: {}".format(repr(cond)))
- return True
+ return False
def run_test_step_action_launch(ctx, step):
print(get_indent(ctx) + "Action: " + step["action"])
@@ -265,6 +272,9 @@ def run_test_step_action_timer_restart(ctx, step):
timer = step['timer']
assert_browser(ctx)
assert(ctx['timers'].get(timer) is not None)
+ taken = time.time() - ctx['timers'][timer]["start"]
+ print(get_indent(ctx) + " {} restarted at: {:.2f}s".format(timer, taken))
+ ctx['timers'][timer]["taken"] = taken
ctx['timers'][timer]["start"] = time.time()
def run_test_step_action_timer_stop(ctx, step):