<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 27 January 2015 at 21:49, Bryce Harrington <span dir="ltr"><<a href="mailto:bryce@osg.samsung.com" target="_blank">bryce@osg.samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Fri, Dec 05, 2014 at 02:36:50PM +0100, Marek Chalupa wrote:<br>
> These tests are using pointer and keyboard simulated events<br>
> to interact with client.<br>
><br>
> Signed-off-by: Marek Chalupa <<a href="mailto:mchqwerty@gmail.com" target="_blank">mchqwerty@gmail.com</a>><br>
<br>
</span>Hi Marek,<br>
<br>
This patch series has a number of different improvements for tests, and<br>
looks like a good candidate for 1.7.  It got thorough review and there<br>
were some changes suggested; would you be able to re-post a v2 with<br>
those changes done this week?<br>
<span><font color="#888888"><br></font></span></blockquote><div><br></div><div>Hi, unfortunately not. There are few things that IMO will take some time to fix and get right. Basically, the whole logic of test surfaces should be modified according to suggested changes. And even if I'd made it till the end of this week, I'd like to have some time to test it before posting it here, so I think It'll be better to leave this series out from 1.7.<br><br></div><div>Regards,<br>Marek<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><font color="#888888">
Bryce<br>
</font></span><div><div><br>
> ---<br>
> Makefile.am              |   7 ++-<br>
>  tests/interactive-test.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++<br>
>  2 files changed, 141 insertions(+), 1 deletion(-)<br>
>  create mode 100644 tests/interactive-test.c<br>
><br>
> diff --git a/Makefile.am b/Makefile.am<br>
> index 57882cd..f59b52a 100644<br>
> --- a/Makefile.am<br>
> +++ b/Makefile.am<br>
> @@ -932,7 +932,8 @@ weston_tests =                                    \<br>
>       presentation.weston                     \<br>
>       roles.weston                            \<br>
>       subsurface.weston                       \<br>
> -     test-suite-tests.weston<br>
> +     test-suite-tests.weston                 \<br>
> +     interactive.weston<br>
><br>
><br>
>  AM_TESTS_ENVIRONMENT = \<br>
> @@ -1053,6 +1054,10 @@ test_suite_tests_weston_SOURCES = tests/test-suite-test.c<br>
>  test_suite_tests_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)<br>
>  test_suite_tests_weston_LDADD = <a href="http://libtest-client.la" target="_blank">libtest-client.la</a><br>
><br>
> +interactive_weston_SOURCES = tests/interactive-test.c<br>
> +interactive_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)<br>
> +interactive_weston_LDADD = <a href="http://libtest-client.la" target="_blank">libtest-client.la</a><br>
> +<br>
>  if ENABLE_EGL<br>
>  weston_tests += buffer-count.weston<br>
>  buffer_count_weston_SOURCES = tests/buffer-count-test.c<br>
> diff --git a/tests/interactive-test.c b/tests/interactive-test.c<br>
> new file mode 100644<br>
> index 0000000..07b3686<br>
> --- /dev/null<br>
> +++ b/tests/interactive-test.c<br>
> @@ -0,0 +1,135 @@<br>
> +/*<br>
> + * Copyright © 2014 Red Hat, Inc.<br>
> + *<br>
> + * Permission to use, copy, modify, distribute, and sell this software and<br>
> + * its documentation for any purpose is hereby granted without fee, provided<br>
> + * that the above copyright notice appear in all copies and that both that<br>
> + * copyright notice and this permission notice appear in supporting<br>
> + * documentation, and that the name of the copyright holders not be used in<br>
> + * advertising or publicity pertaining to distribution of the software<br>
> + * without specific, written prior permission.  The copyright holders make<br>
> + * no representations about the suitability of this software for any<br>
> + * purpose.  It is provided "as is" without express or implied warranty.<br>
> + *<br>
> + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS<br>
> + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND<br>
> + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY<br>
> + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER<br>
> + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF<br>
> + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN<br>
> + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.<br>
> + */<br>
> +<br>
> +#include <unistd.h><br>
> +#include <time.h><br>
> +#include <linux/input.h><br>
> +<br>
> +#include "weston-test-client-helper.h"<br>
> +<br>
> +/* relative position where to grab the client when dragging*/<br>
> +#define GRAB_SHIFT_X 150<br>
> +#define GRAB_SHIFT_Y 45<br>
> +<br>
> +static void<br>
> +drag_and_check(struct client *client, int x, int y)<br>
> +{<br>
> +     wl_test_get_geometry(client->test->wl_test, client->surface->wl_surface);<br>
> +     client_roundtrip(client);<br>
> +<br>
> +     fprintf(stderr, "dragging from %dx%d to %dx%d\n",<br>
> +             client->test->geometry.x, client->test->geometry.y,<br>
> +             x, y);<br>
> +     fflush(stderr);<br>
> +<br>
> +     pointer_simulate_drag(client,<br>
> +                           client->test->geometry.x + GRAB_SHIFT_X,<br>
> +                           client->test->geometry.y + GRAB_SHIFT_Y,<br>
> +                           x + GRAB_SHIFT_X, y + GRAB_SHIFT_Y);<br>
> +     client_roundtrip(client);<br>
> +<br>
> +     wl_test_get_geometry(client->test->wl_test, client->surface->wl_surface);<br>
> +     client_roundtrip(client);<br>
> +<br>
> +     assert(!window_is_maximized(client->toytoolkit->window));<br>
> +     assert(!window_is_fullscreen(client->toytoolkit->window));<br>
> +     assert(client->test->geometry.x == x);<br>
> +     assert(client->test->geometry.y == y);<br>
> +}<br>
> +<br>
> +#define MSEC_TO_USEC(n) ((n) * 1000)<br>
> +<br>
> +TEST(move_client_by_pointer_test)<br>
> +{<br>
> +     int x, y, i;<br>
> +     const int width = 300;<br>
> +     const int height = 300;<br>
> +     struct client *client = toytoolkit_client_create(100, 100, width, height);<br>
> +<br>
> +     srand(time(NULL));<br>
> +<br>
> +     /* random stuff */<br>
> +     for (i = 0; i < 10; ++i) {<br>
> +             x = rand() % (client->output->width - width);<br>
> +             y = rand() % (client->output->height - height);<br>
> +<br>
> +             drag_and_check(client, x, y);<br>
> +             /* sleep a while so that we won't do double click */<br>
> +             usleep(MSEC_TO_USEC(300));<br>
> +     }<br>
> +}<br>
> +<br>
> +TEST(focus_tests_one_client)<br>
> +{<br>
> +     struct client *c1 = toytoolkit_client_create(100, 100, 300, 200);<br>
> +     int dw, dh;<br>
> +<br>
> +     /* if we'll get a motion, then we're out of frame */<br>
> +     c1->input->pointer->x = -1;<br>
> +     c1->input->pointer->y = -1;<br>
> +<br>
> +     /* just for sure ... */<br>
> +     wl_test_get_geometry(c1->test->wl_test, c1->surface->wl_surface);<br>
> +     client_roundtrip(c1);<br>
> +     assert(c1->test->geometry.x == 100);<br>
> +     assert(c1->test->geometry.y == 100);<br>
> +<br>
> +     /* move pointer away from c1 */<br>
> +     pointer_simulate_move(c1, 0, 0, 50, 50);<br>
> +     assert(c1->input->pointer->focus == NULL);<br>
> +     assert(c1->input->keyboard->focus == NULL);<br>
> +<br>
> +     /* move pointer to the c1's top-left corner (to bar) */<br>
> +     pointer_simulate_move(c1, 50, 50,<br>
> +                           100 + GRAB_SHIFT_X, 100 + GRAB_SHIFT_Y);<br>
> +<br>
> +     /* make sure we're in frame */<br>
> +     assert(c1->input->pointer->x == -1);<br>
> +     assert(c1->input->pointer->y == -1);<br>
> +<br>
> +     /* frame is not an input region ... */<br>
> +     assert(c1->input->pointer->focus == NULL);<br>
> +     assert(c1->input->keyboard->focus == NULL);<br>
> +<br>
> +     pointer_click(c1, BTN_LEFT);<br>
> +     client_roundtrip(c1);<br>
> +     assert(c1->input->pointer->focus == NULL);<br>
> +     assert(c1->input->keyboard->focus == c1->surface->wl_surface);<br>
> +<br>
> +     /* move away from window */<br>
> +     pointer_simulate_move(c1, 100, 100, 50, 50);<br>
> +     assert(c1->input->pointer->focus == NULL);<br>
> +     assert(c1->input->keyboard->focus == c1->surface->wl_surface);<br>
> +<br>
> +     /* move to input region */<br>
> +     window_get_decoration_size(c1->toytoolkit->window, &dw, &dh);<br>
> +     pointer_simulate_move(c1, 50, 50, 110 + dw, 110 + dh);<br>
> +     assert(c1->input->pointer->focus == c1->surface->wl_surface);<br>
> +     assert(c1->input->keyboard->focus == c1->surface->wl_surface);<br>
> +     assert(c1->input->pointer->x == dw + 10);<br>
> +     assert(c1->input->pointer->y == dh + 10);<br>
> +<br>
> +     /* move away again */<br>
> +     pointer_simulate_move(c1, 110, 110, 50, 50);<br>
> +     assert(c1->input->keyboard->focus == c1->surface->wl_surface);<br>
> +     assert(c1->input->pointer->focus == NULL);<br>
> +}<br>
</div></div></blockquote></div><br></div></div>