Re: [PATCH weston v2 5/7] tests: Support setting the test client input dynamically

2018-02-13 Thread Pekka Paalanen
On Thu,  8 Feb 2018 15:37:56 +0200
Alexandros Frantzis  wrote:

> The current test client code waits for all wl_seat globals to arrive
> before checking them and deciding which one is the test seat global to
> use for the input object. Test code that needs to add/remove test seats
> would have to call the client_set_input() function for any seat changes
> to take effect. Although we could allow this by making
> client_set_input() public, we would be exposing unecessary
> implementation details.
> 
> This commit applies any seat changes immediately upon arrival of the
> seat name, freeing test code from needing to call extra functions like
> client_set_input(). To achieve this the call to input_data_devices() is
> moved from client_set_input() to the seat name event handler.
> 
> This commit also moves the check that all seats have names to an
> explicit test. To support this test, inputs corresponding to non-test
> seats are not destroyed (unless their seat global is removed), as
> was previously the case.
> 
> Signed-off-by: Alexandros Frantzis 
> ---
> Changes in v2:
>  - Add explicit test for seat names.
>  - Don't destroy input objects for non-test seats unconditionally.
>  - Simplify devices handling in seat name handler.
> 
>  tests/devices-test.c  | 10 ++
>  tests/weston-test-client-helper.c | 33 ++---
>  tests/weston-test-client-helper.h |  1 +
>  3 files changed, 21 insertions(+), 23 deletions(-)

Hi Alf,

well done! This is much more clear than the previous version, and easy
to review.

Reviewed-by: Pekka Paalanen 


Thanks,
pq


pgpfCfCu6Mbjo.pgp
Description: OpenPGP digital signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2 5/7] tests: Support setting the test client input dynamically

2018-02-08 Thread Alexandros Frantzis
The current test client code waits for all wl_seat globals to arrive
before checking them and deciding which one is the test seat global to
use for the input object. Test code that needs to add/remove test seats
would have to call the client_set_input() function for any seat changes
to take effect. Although we could allow this by making
client_set_input() public, we would be exposing unecessary
implementation details.

This commit applies any seat changes immediately upon arrival of the
seat name, freeing test code from needing to call extra functions like
client_set_input(). To achieve this the call to input_data_devices() is
moved from client_set_input() to the seat name event handler.

This commit also moves the check that all seats have names to an
explicit test. To support this test, inputs corresponding to non-test
seats are not destroyed (unless their seat global is removed), as
was previously the case.

Signed-off-by: Alexandros Frantzis 
---
Changes in v2:
 - Add explicit test for seat names.
 - Don't destroy input objects for non-test seats unconditionally.
 - Simplify devices handling in seat name handler.

 tests/devices-test.c  | 10 ++
 tests/weston-test-client-helper.c | 33 ++---
 tests/weston-test-client-helper.h |  1 +
 3 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/tests/devices-test.c b/tests/devices-test.c
index 450713e7..ce1cea3b 100644
--- a/tests/devices-test.c
+++ b/tests/devices-test.c
@@ -310,3 +310,13 @@ TEST(get_device_after_destroy_multiple)
get_device_after_destroy();
}
 }
+
+TEST(seats_have_names)
+{
+   struct client *cl = create_client_and_test_surface(100, 100, 100, 100);
+   struct input *input;
+
+   wl_list_for_each(input, >inputs, link) {
+   assert(input->seat_name);
+   }
+}
diff --git a/tests/weston-test-client-helper.c 
b/tests/weston-test-client-helper.c
index 5ee032ca..dc69e151 100644
--- a/tests/weston-test-client-helper.c
+++ b/tests/weston-test-client-helper.c
@@ -635,6 +635,15 @@ seat_handle_name(void *data, struct wl_seat *seat, const 
char *name)
input->seat_name = strdup(name);
assert(input->seat_name && "No memory");
 
+   /* We only update the devices and set client input for the test seat */
+   if (strcmp(name, "test-seat") == 0) {
+   assert(!input->client->input &&
+  "Multiple test seats detected!");
+
+   input_update_devices(input);
+   input->client->input = input;
+   }
+
fprintf(stderr, "test-client: got seat %p name: \'%s\'\n",
input, name);
 }
@@ -726,6 +735,7 @@ handle_global(void *data, struct wl_registry *registry,
 _compositor_interface, version);
} else if (strcmp(interface, "wl_seat") == 0) {
input = xzalloc(sizeof *input);
+   input->client = client;
input->global_name = global->name;
input->wl_seat =
wl_registry_bind(registry, id,
@@ -882,26 +892,6 @@ log_handler(const char *fmt, va_list args)
vfprintf(stderr, fmt, args);
 }
 
-/* find the test-seat and set it in client.
- * Destroy other inputs */
-static void
-client_set_input(struct client *cl)
-{
-   struct input *inp, *inptmp;
-   wl_list_for_each_safe(inp, inptmp, >inputs, link) {
-   assert(inp->seat_name && "BUG: input with no name");
-   if (strcmp(inp->seat_name, "test-seat") == 0) {
-   cl->input = inp;
-   input_update_devices(inp);
-   } else {
-   input_destroy(inp);
-   }
-   }
-
-   /* we keep only one input */
-   assert(wl_list_length(>inputs) == 1);
-}
-
 struct client *
 create_client(void)
 {
@@ -927,9 +917,6 @@ create_client(void)
 * events */
client_roundtrip(client);
 
-   /* find the right input for us */
-   client_set_input(client);
-
/* must have WL_SHM_FORMAT_ARGB32 */
assert(client->has_argb);
 
diff --git a/tests/weston-test-client-helper.h 
b/tests/weston-test-client-helper.h
index fb31125c..255bbf66 100644
--- a/tests/weston-test-client-helper.h
+++ b/tests/weston-test-client-helper.h
@@ -74,6 +74,7 @@ struct test {
 };
 
 struct input {
+   struct client *client;
uint32_t global_name;
struct wl_seat *wl_seat;
struct pointer *pointer;
-- 
2.14.1

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel