summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2019-06-12 23:55:54 +0100
committerVincent Sanders <vince@kyllikki.org>2019-06-12 23:55:54 +0100
commit1951c0f8094ab74abd1873e622a8a79f2627c7fc (patch)
tree4097c476e73d05a00e9090d4e0f12caa1a518fa8 /test
parentc90bd806a68a4d5e80ff985ad626e14cc8605204 (diff)
downloadnetsurf-1951c0f8094ab74abd1873e622a8a79f2627c7fc.tar.gz
netsurf-1951c0f8094ab74abd1873e622a8a79f2627c7fc.tar.bz2
allow repeat loops to specify values and navigation to use them
Diffstat (limited to 'test')
-rwxr-xr-xtest/monkey_driver.py44
1 files changed, 34 insertions, 10 deletions
diff --git a/test/monkey_driver.py b/test/monkey_driver.py
index 03906d805..091540ea7 100755
--- a/test/monkey_driver.py
+++ b/test/monkey_driver.py
@@ -228,12 +228,21 @@ def run_test_step_action_window_close(ctx, step):
def run_test_step_action_navigate(ctx, step):
print(get_indent(ctx) + "Action: " + step["action"])
assert_browser(ctx)
- assert(step.get('url') is not None)
+ if 'url' in step.keys():
+ url = step['url']
+ elif 'repeaturl' in step.keys():
+ repeat = ctx['repeats'].get(step['repeaturl'])
+ assert(repeat is not None)
+ assert(repeat.get('values') is not None)
+ url = repeat['values'][repeat['i']]
+ else:
+ url = None
+ assert(url is not None)
tag = step['window']
- print(get_indent(ctx) + " " + tag + " --> " + step['url'])
+ print(get_indent(ctx) + " " + tag + " --> " + url)
win = ctx['windows'].get(tag)
assert(win is not None)
- win.go(step['url'])
+ win.go(url)
def run_test_step_action_stop(ctx, step):
print(get_indent(ctx) + "Action: " + step["action"])
@@ -284,17 +293,32 @@ def run_test_step_action_repeat(ctx, step):
print(get_indent(ctx) + "Action: " + step["action"])
tag = step['tag']
assert(ctx['repeats'].get(tag) is None)
- ctx['repeats'][tag] = {
- "i": step["min"],
- "step": step["step"],
- "loop": True,
- }
+ ctx['repeats'][tag] = { "loop": True, }
+
+ if 'min' in step.keys():
+ ctx['repeats'][tag]["i"] = step["min"]
+ else:
+ ctx['repeats'][tag]["i"] = 0
+
+ if 'step' in step.keys():
+ ctx['repeats'][tag]["step"] = step["step"]
+ else:
+ ctx['repeats'][tag]["step"] = 1
+
+ if 'values' in step.keys():
+ ctx['repeats'][tag]['values'] = step["values"]
+ else:
+ ctx['repeats'][tag]['values'] = None
+
while ctx['repeats'][tag]["loop"]:
ctx['repeats'][tag]["start"] = time.time()
ctx["depth"] += 1
for s in step["steps"]:
run_test_step(ctx, s)
ctx['repeats'][tag]["i"] += ctx['repeats'][tag]["step"]
+ if ctx['repeats'][tag]['values'] is not None:
+ if ctx['repeats'][tag]["i"] >= len(ctx['repeats'][tag]['values']):
+ ctx['repeats'][tag]["loop"] = False
ctx["depth"] -= 1
def run_test_step_action_plot_check(ctx, step):
@@ -340,7 +364,7 @@ def run_test_step_action_timer_restart(ctx, step):
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))
+ print("{} {} restarted at: {:.2f}s".format(get_indent(ctx), timer, taken))
ctx['timers'][timer]["taken"] = taken
ctx['timers'][timer]["start"] = time.time()
@@ -350,7 +374,7 @@ def run_test_step_action_timer_stop(ctx, step):
assert_browser(ctx)
assert(ctx['timers'].get(timer) is not None)
taken = time.time() - ctx['timers'][timer]["start"]
- print(get_indent(ctx) + " " + timer + " took: " + str(taken) + "s")
+ print("{} {} took: {:.2f}s".format(get_indent(ctx), timer, taken))
ctx['timers'][timer]["taken"] = taken
def run_test_step_action_timer_check(ctx, step):