diff --git a/src/tests/clutter/conform/event-delivery.c b/src/tests/clutter/conform/event-delivery.c new file mode 100644 index 000000000..e1dba7e0d --- /dev/null +++ b/src/tests/clutter/conform/event-delivery.c @@ -0,0 +1,69 @@ +#include + +#include "tests/clutter-test-utils.h" + +static void +on_after_update (ClutterStage *stage, + ClutterStageView *view, + gboolean *was_updated) +{ + *was_updated = TRUE; +} + +static gboolean +on_event_return_stop (ClutterActor *actor, + ClutterEvent *event, + unsigned int *n_events) +{ + (*n_events)++; + + return CLUTTER_EVENT_STOP; +} + +static void +wait_stage_updated (gboolean *was_updated) +{ + *was_updated = FALSE; + while (!*was_updated) + g_main_context_iteration (NULL, TRUE); +} + +static void +event_delivery_consecutive_touch_begin_end (void) +{ + ClutterActor *stage = clutter_test_get_stage (); + ClutterSeat *seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); + g_autoptr (ClutterVirtualInputDevice) virtual_pointer = NULL; + int64_t now_us; + gboolean was_updated; + unsigned int n_captured_touch_events = 0; + + virtual_pointer = clutter_seat_create_virtual_device (seat, CLUTTER_POINTER_DEVICE); + now_us = g_get_monotonic_time (); + + g_signal_connect (stage, "after-update", G_CALLBACK (on_after_update), + &was_updated); + g_signal_connect (stage, "captured-event::touch", G_CALLBACK (on_event_return_stop), + &n_captured_touch_events); + + clutter_actor_show (stage); + + was_updated = FALSE; + clutter_virtual_input_device_notify_touch_down (virtual_pointer, now_us, 0, 5, 5); + clutter_virtual_input_device_notify_touch_up (virtual_pointer, now_us, 0); + clutter_virtual_input_device_notify_touch_down (virtual_pointer, now_us, 0, 5, 5); + g_assert_true (!was_updated); + wait_stage_updated (&was_updated); + g_assert_cmpint (n_captured_touch_events, ==, 3); + + clutter_virtual_input_device_notify_touch_up (virtual_pointer, now_us, 0); + wait_stage_updated (&was_updated); + g_assert_cmpint (n_captured_touch_events, ==, 4); + + g_signal_handlers_disconnect_by_func (stage, on_event_return_stop, &n_captured_touch_events); + g_signal_handlers_disconnect_by_func (stage, on_after_update, &was_updated); +} + +CLUTTER_TEST_SUITE ( + CLUTTER_TEST_UNIT ("/event/delivery/consecutive-touch-begin-end", event_delivery_consecutive_touch_begin_end); +) diff --git a/src/tests/clutter/conform/meson.build b/src/tests/clutter/conform/meson.build index 093686329..b10299e7a 100644 --- a/src/tests/clutter/conform/meson.build +++ b/src/tests/clutter/conform/meson.build @@ -34,6 +34,7 @@ clutter_conform_tests_classes_tests = [ clutter_conform_tests_general_tests = [ 'binding-pool', 'color', + 'event-delivery', 'frame-clock', 'frame-clock-timeline', 'grab',