Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/41ecb495d0d27e2911a08c52330d1e58483c345c
...commit
http://git.netsurf-browser.org/netsurf.git/commit/41ecb495d0d27e2911a08c52330d1e58483c345c
...tree
http://git.netsurf-browser.org/netsurf.git/tree/41ecb495d0d27e2911a08c52330d1e58483c345c
The branch, master has been updated
via 41ecb495d0d27e2911a08c52330d1e58483c345c (commit)
via 45097c7f396df40b9c0cf71f2dd3dbeb50fc10c8 (commit)
via 69d1d5f626c637aef352cfd35eeb800760f909b1 (commit)
from 404fc65771a3b13d5376ea000b3549ee541cc91c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=41ecb495d0d27e2911a08c52330d1e58483c345c
commit 41ecb495d0d27e2911a08c52330d1e58483c345c
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
monkeyfarmer, driver: Add support for clicking on things
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/test/monkey_driver.py b/test/monkey_driver.py
index 7a1bd79..7296c8a 100755
--- a/test/monkey_driver.py
+++ b/test/monkey_driver.py
@@ -380,6 +380,56 @@ def run_test_step_action_repeat(ctx, step):
ctx["depth"] -= 1
+def run_test_step_action_click(ctx, step):
+ print(get_indent(ctx) + "Action: " + step["action"])
+ assert_browser(ctx)
+ win = ctx['windows'][step['window']]
+ targets = step['target']
+ if type(targets) == dict:
+ targets = [targets]
+ button = step.get('button', 'left').upper()
+ kind = step.get('kind', 'single').upper()
+ all_text_list = []
+ bitmaps = []
+ for plot in win.redraw():
+ if plot[0] == 'TEXT':
+ all_text_list.append((int(plot[2]), int(plot[4]), "
".join(plot[6:])))
+ if plot[0] == 'BITMAP':
+ bitmaps.append((int(plot[2]), int(plot[4]), int(plot[6]),
int(plot[8])))
+
+ x = None
+ y = None
+
+ for target in targets:
+ if 'bitmap' in target:
+ if x is not None:
+ assert False, "Found more than one thing to click on, oh well"
+ bmap = int(target['bitmap'])
+ assert bmap < 0 or bmap >= len(bitmaps)
+ x = bitmaps[bmap][0] + bitmaps[bmap][2] / 2
+ y = bitmaps[bmap][1] + bitmaps[bmap][3] / 2
+ elif 'text' in target:
+ if x is not None:
+ assert False, "Found more than one thing to click on, oh well"
+ text = target['text']
+ for textentry in all_text_list:
+ if text in textentry[2]:
+ if x is not None:
+ assert False, "Text {} found more than
once".format(text)
+ x = textentry[0] + 2
+ y = textentry[1] + 2
+
+ # Now we want to click on the x/y coordinate given
+ print(get_indent(ctx) + " Clicking at {}, {} (button={}
kind={})".format(x, y, button, kind))
+ win.click(x, y, button, kind)
+
+
+def run_test_step_action_wait_loading(ctx, step):
+ print(get_indent(ctx) + "Action: " + step["action"])
+ assert_browser(ctx)
+ win = ctx['windows'][step['window']]
+ win.wait_start_loading()
+
def run_test_step_action_plot_check(ctx, step):
print(get_indent(ctx) + "Action: " + step["action"])
assert_browser(ctx)
@@ -398,13 +448,13 @@ def run_test_step_action_plot_check(ctx, step):
all_text = " ".join(all_text_list)
for check in checks:
if 'text-contains' in check.keys():
- print("Check {} in {}".format(repr(check['text-contains']),
repr(all_text)))
+ print(" Check {} in
{}".format(repr(check['text-contains']), repr(all_text)))
assert check['text-contains'] in all_text
elif 'text-not-contains' in check.keys():
- print("Check {} NOT in
{}".format(repr(check['text-not-contains']), repr(all_text)))
+ print(" Check {} NOT in
{}".format(repr(check['text-not-contains']), repr(all_text)))
assert check['text-not-contains'] not in all_text
elif 'bitmap-count' in check.keys():
- print("Check bitmap count is
{}".format(int(check['bitmap-count'])))
+ print(" Check bitmap count is
{}".format(int(check['bitmap-count'])))
assert len(bitmaps) == int(check['bitmap-count'])
else:
raise AssertionError("Unknown check: {}".format(repr(check)))
@@ -559,6 +609,8 @@ STEP_HANDLERS = {
"timer-stop": run_test_step_action_timer_stop,
"timer-check": run_test_step_action_timer_check,
"plot-check": run_test_step_action_plot_check,
+ "click": run_test_step_action_click,
+ "wait-loading": run_test_step_action_wait_loading,
"add-auth": run_test_step_action_add_auth,
"remove-auth": run_test_step_action_remove_auth,
"add-cert": run_test_step_action_add_cert,
diff --git a/test/monkeyfarmer.py b/test/monkeyfarmer.py
index 21be110..a26e28d 100644
--- a/test/monkeyfarmer.py
+++ b/test/monkeyfarmer.py
@@ -434,6 +434,9 @@ class BrowserWindow:
self.browser.farmer.tell_monkey("WINDOW RELOAD %s%s" % (self.winid,
all))
self.wait_start_loading()
+ def click(self, x, y, button="LEFT", kind="SINGLE"):
+ self.browser.farmer.tell_monkey("WINDOW CLICK WIN %s X %s Y %s BUTTON
%s KIND %s" % (self.winid, x, y, button, kind))
+
def js_exec(self, src):
self.browser.farmer.tell_monkey("WINDOW EXEC WIN %s %s" % (self.winid,
src))
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=45097c7f396df40b9c0cf71f2dd3dbeb50fc10c8
commit 45097c7f396df40b9c0cf71f2dd3dbeb50fc10c8
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
monkeyfarmer: Probably make handling of monkey more robust
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/test/monkeyfarmer.py b/test/monkeyfarmer.py
index 1f28d62..21be110 100644
--- a/test/monkeyfarmer.py
+++ b/test/monkeyfarmer.py
@@ -83,7 +83,7 @@ class MonkeyFarmer(asyncore.dispatcher):
self.monkey.wait()
print("Handling an exit {}".format(self.monkey.returncode))
print("The following are present in the queue:
{}".format(self.lines))
- self.lines.insert(0, "GENERIC EXIT {}".format(
+ self.lines.append("GENERIC EXIT {}".format(
self.monkey.returncode).encode('utf-8'))
print("The queue is now: {}".format(self.lines))
return
@@ -97,7 +97,7 @@ class MonkeyFarmer(asyncore.dispatcher):
if b"\n" in self.incoming:
lines = self.incoming.split(b"\n")
self.incoming = lines.pop()
- self.lines = lines
+ self.lines.extend(lines)
def writable(self):
return len(self.buffer) > 0
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=69d1d5f626c637aef352cfd35eeb800760f909b1
commit 69d1d5f626c637aef352cfd35eeb800760f909b1
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
monkey: Support clicking in windows
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/docs/using-monkey.md b/docs/using-monkey.md
index f4fff43..d031a77 100644
--- a/docs/using-monkey.md
+++ b/docs/using-monkey.md
@@ -142,6 +142,16 @@ Commands
This will send a `JS` message back.
+* `WINDOW CLICK WIN` _%id%_ `X` _%num%_ `Y` _%num%_ `BUTTON` _%str%_ `KIND`
_%str%_
+
+ Cause a browser window to experience a mouse click. The coordinates should
+ be in plot coordinates, so you can use redraw plot commands to find things
+ and then click on them. The `BUTTON` value should be one of `LEFT`
+ or `RIGHT`, and the `KIND` is `SINGLE`, `DOUBLE`, or `TRIPLE`.
+
+ This command will not output anything itself, it's expected only to do
things
+ as a result of the click (e.g. navigating when clicking a link).
+
### Login commands
* `LOGIN USERNAME` _%id%_ _%str%_
diff --git a/frontends/monkey/browser.c b/frontends/monkey/browser.c
index d6dd951..b691994 100644
--- a/frontends/monkey/browser.c
+++ b/frontends/monkey/browser.c
@@ -613,6 +613,48 @@ monkey_window_handle_exec(int argc, char **argv)
}
+static void
+monkey_window_handle_click(int argc, char **argv)
+{
+ /* `WINDOW CLICK WIN` _%id%_ `X` _%num%_ `Y` _%num%_ `BUTTON` _%str%_
`KIND` _%str%_ */
+ /* 0 1 2 3 4 5 6 7 8 9
10 11 */
+ struct gui_window *gw;
+ if (argc != 12) {
+ moutf(MOUT_ERROR, "WINDOW CLICK ARGS BAD\n");
+ }
+
+ gw = monkey_find_window_by_num(atoi(argv[2]));
+
+ if (gw == NULL) {
+ moutf(MOUT_ERROR, "WINDOW NUM BAD");
+ } else {
+ int x = atoi(argv[5]);
+ int y = atoi(argv[7]);
+ browser_mouse_state mouse;
+ const char *button = argv[9];
+ const char *kind = argv[11];
+ if (strcmp(button, "LEFT") == 0) {
+ mouse = BROWSER_MOUSE_CLICK_1;
+ } else if (strcmp(button, "RIGHT") == 0) {
+ mouse = BROWSER_MOUSE_CLICK_2;
+ } else {
+ moutf(MOUT_ERROR, "WINDOW BUTTON BAD");
+ return;
+ }
+ if (strcmp(kind, "SINGLE") == 0) {
+ /* Nothing */
+ } else if (strcmp(kind, "DOUBLE") == 0) {
+ mouse |= BROWSER_MOUSE_DOUBLE_CLICK;
+ } else if (strcmp(kind, "TRIPLE") == 0) {
+ mouse |= BROWSER_MOUSE_TRIPLE_CLICK;
+ } else {
+ moutf(MOUT_ERROR, "WINDOW KIND BAD");
+ return;
+ }
+ browser_window_mouse_click(gw->bw, mouse, x, y);
+ }
+}
+
void
monkey_window_handle_command(int argc, char **argv)
{
@@ -633,6 +675,8 @@ monkey_window_handle_command(int argc, char **argv)
monkey_window_handle_reload(argc, argv);
} else if (strcmp(argv[1], "EXEC") == 0) {
monkey_window_handle_exec(argc, argv);
+ } else if (strcmp(argv[1], "CLICK") == 0) {
+ monkey_window_handle_click(argc, argv);
} else {
moutf(MOUT_ERROR, "WINDOW COMMAND UNKNOWN %s\n", argv[1]);
}
-----------------------------------------------------------------------
Summary of changes:
docs/using-monkey.md | 10 ++++++++
frontends/monkey/browser.c | 44 +++++++++++++++++++++++++++++++++
test/monkey_driver.py | 58 +++++++++++++++++++++++++++++++++++++++++---
test/monkeyfarmer.py | 7 ++++--
4 files changed, 114 insertions(+), 5 deletions(-)
diff --git a/docs/using-monkey.md b/docs/using-monkey.md
index f4fff43..d031a77 100644
--- a/docs/using-monkey.md
+++ b/docs/using-monkey.md
@@ -142,6 +142,16 @@ Commands
This will send a `JS` message back.
+* `WINDOW CLICK WIN` _%id%_ `X` _%num%_ `Y` _%num%_ `BUTTON` _%str%_ `KIND`
_%str%_
+
+ Cause a browser window to experience a mouse click. The coordinates should
+ be in plot coordinates, so you can use redraw plot commands to find things
+ and then click on them. The `BUTTON` value should be one of `LEFT`
+ or `RIGHT`, and the `KIND` is `SINGLE`, `DOUBLE`, or `TRIPLE`.
+
+ This command will not output anything itself, it's expected only to do
things
+ as a result of the click (e.g. navigating when clicking a link).
+
### Login commands
* `LOGIN USERNAME` _%id%_ _%str%_
diff --git a/frontends/monkey/browser.c b/frontends/monkey/browser.c
index d6dd951..b691994 100644
--- a/frontends/monkey/browser.c
+++ b/frontends/monkey/browser.c
@@ -613,6 +613,48 @@ monkey_window_handle_exec(int argc, char **argv)
}
+static void
+monkey_window_handle_click(int argc, char **argv)
+{
+ /* `WINDOW CLICK WIN` _%id%_ `X` _%num%_ `Y` _%num%_ `BUTTON` _%str%_
`KIND` _%str%_ */
+ /* 0 1 2 3 4 5 6 7 8 9
10 11 */
+ struct gui_window *gw;
+ if (argc != 12) {
+ moutf(MOUT_ERROR, "WINDOW CLICK ARGS BAD\n");
+ }
+
+ gw = monkey_find_window_by_num(atoi(argv[2]));
+
+ if (gw == NULL) {
+ moutf(MOUT_ERROR, "WINDOW NUM BAD");
+ } else {
+ int x = atoi(argv[5]);
+ int y = atoi(argv[7]);
+ browser_mouse_state mouse;
+ const char *button = argv[9];
+ const char *kind = argv[11];
+ if (strcmp(button, "LEFT") == 0) {
+ mouse = BROWSER_MOUSE_CLICK_1;
+ } else if (strcmp(button, "RIGHT") == 0) {
+ mouse = BROWSER_MOUSE_CLICK_2;
+ } else {
+ moutf(MOUT_ERROR, "WINDOW BUTTON BAD");
+ return;
+ }
+ if (strcmp(kind, "SINGLE") == 0) {
+ /* Nothing */
+ } else if (strcmp(kind, "DOUBLE") == 0) {
+ mouse |= BROWSER_MOUSE_DOUBLE_CLICK;
+ } else if (strcmp(kind, "TRIPLE") == 0) {
+ mouse |= BROWSER_MOUSE_TRIPLE_CLICK;
+ } else {
+ moutf(MOUT_ERROR, "WINDOW KIND BAD");
+ return;
+ }
+ browser_window_mouse_click(gw->bw, mouse, x, y);
+ }
+}
+
void
monkey_window_handle_command(int argc, char **argv)
{
@@ -633,6 +675,8 @@ monkey_window_handle_command(int argc, char **argv)
monkey_window_handle_reload(argc, argv);
} else if (strcmp(argv[1], "EXEC") == 0) {
monkey_window_handle_exec(argc, argv);
+ } else if (strcmp(argv[1], "CLICK") == 0) {
+ monkey_window_handle_click(argc, argv);
} else {
moutf(MOUT_ERROR, "WINDOW COMMAND UNKNOWN %s\n", argv[1]);
}
diff --git a/test/monkey_driver.py b/test/monkey_driver.py
index 7a1bd79..7296c8a 100755
--- a/test/monkey_driver.py
+++ b/test/monkey_driver.py
@@ -380,6 +380,56 @@ def run_test_step_action_repeat(ctx, step):
ctx["depth"] -= 1
+def run_test_step_action_click(ctx, step):
+ print(get_indent(ctx) + "Action: " + step["action"])
+ assert_browser(ctx)
+ win = ctx['windows'][step['window']]
+ targets = step['target']
+ if type(targets) == dict:
+ targets = [targets]
+ button = step.get('button', 'left').upper()
+ kind = step.get('kind', 'single').upper()
+ all_text_list = []
+ bitmaps = []
+ for plot in win.redraw():
+ if plot[0] == 'TEXT':
+ all_text_list.append((int(plot[2]), int(plot[4]), "
".join(plot[6:])))
+ if plot[0] == 'BITMAP':
+ bitmaps.append((int(plot[2]), int(plot[4]), int(plot[6]),
int(plot[8])))
+
+ x = None
+ y = None
+
+ for target in targets:
+ if 'bitmap' in target:
+ if x is not None:
+ assert False, "Found more than one thing to click on, oh well"
+ bmap = int(target['bitmap'])
+ assert bmap < 0 or bmap >= len(bitmaps)
+ x = bitmaps[bmap][0] + bitmaps[bmap][2] / 2
+ y = bitmaps[bmap][1] + bitmaps[bmap][3] / 2
+ elif 'text' in target:
+ if x is not None:
+ assert False, "Found more than one thing to click on, oh well"
+ text = target['text']
+ for textentry in all_text_list:
+ if text in textentry[2]:
+ if x is not None:
+ assert False, "Text {} found more than
once".format(text)
+ x = textentry[0] + 2
+ y = textentry[1] + 2
+
+ # Now we want to click on the x/y coordinate given
+ print(get_indent(ctx) + " Clicking at {}, {} (button={}
kind={})".format(x, y, button, kind))
+ win.click(x, y, button, kind)
+
+
+def run_test_step_action_wait_loading(ctx, step):
+ print(get_indent(ctx) + "Action: " + step["action"])
+ assert_browser(ctx)
+ win = ctx['windows'][step['window']]
+ win.wait_start_loading()
+
def run_test_step_action_plot_check(ctx, step):
print(get_indent(ctx) + "Action: " + step["action"])
assert_browser(ctx)
@@ -398,13 +448,13 @@ def run_test_step_action_plot_check(ctx, step):
all_text = " ".join(all_text_list)
for check in checks:
if 'text-contains' in check.keys():
- print("Check {} in {}".format(repr(check['text-contains']),
repr(all_text)))
+ print(" Check {} in
{}".format(repr(check['text-contains']), repr(all_text)))
assert check['text-contains'] in all_text
elif 'text-not-contains' in check.keys():
- print("Check {} NOT in
{}".format(repr(check['text-not-contains']), repr(all_text)))
+ print(" Check {} NOT in
{}".format(repr(check['text-not-contains']), repr(all_text)))
assert check['text-not-contains'] not in all_text
elif 'bitmap-count' in check.keys():
- print("Check bitmap count is
{}".format(int(check['bitmap-count'])))
+ print(" Check bitmap count is
{}".format(int(check['bitmap-count'])))
assert len(bitmaps) == int(check['bitmap-count'])
else:
raise AssertionError("Unknown check: {}".format(repr(check)))
@@ -559,6 +609,8 @@ STEP_HANDLERS = {
"timer-stop": run_test_step_action_timer_stop,
"timer-check": run_test_step_action_timer_check,
"plot-check": run_test_step_action_plot_check,
+ "click": run_test_step_action_click,
+ "wait-loading": run_test_step_action_wait_loading,
"add-auth": run_test_step_action_add_auth,
"remove-auth": run_test_step_action_remove_auth,
"add-cert": run_test_step_action_add_cert,
diff --git a/test/monkeyfarmer.py b/test/monkeyfarmer.py
index 1f28d62..a26e28d 100644
--- a/test/monkeyfarmer.py
+++ b/test/monkeyfarmer.py
@@ -83,7 +83,7 @@ class MonkeyFarmer(asyncore.dispatcher):
self.monkey.wait()
print("Handling an exit {}".format(self.monkey.returncode))
print("The following are present in the queue:
{}".format(self.lines))
- self.lines.insert(0, "GENERIC EXIT {}".format(
+ self.lines.append("GENERIC EXIT {}".format(
self.monkey.returncode).encode('utf-8'))
print("The queue is now: {}".format(self.lines))
return
@@ -97,7 +97,7 @@ class MonkeyFarmer(asyncore.dispatcher):
if b"\n" in self.incoming:
lines = self.incoming.split(b"\n")
self.incoming = lines.pop()
- self.lines = lines
+ self.lines.extend(lines)
def writable(self):
return len(self.buffer) > 0
@@ -434,6 +434,9 @@ class BrowserWindow:
self.browser.farmer.tell_monkey("WINDOW RELOAD %s%s" % (self.winid,
all))
self.wait_start_loading()
+ def click(self, x, y, button="LEFT", kind="SINGLE"):
+ self.browser.farmer.tell_monkey("WINDOW CLICK WIN %s X %s Y %s BUTTON
%s KIND %s" % (self.winid, x, y, button, kind))
+
def js_exec(self, src):
self.browser.farmer.tell_monkey("WINDOW EXEC WIN %s %s" % (self.winid,
src))
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org