tests/clutter/conform: Add a test for event delivery
Add a test for everything related to event delivery. The first test we
add here is making sure we don't regress on the bug fixed with commit
edc226a04d
.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2697>
This commit is contained in:
parent
fe01e423a3
commit
260ea37312
69
src/tests/clutter/conform/event-delivery.c
Normal file
69
src/tests/clutter/conform/event-delivery.c
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#include <clutter/clutter.h>
|
||||||
|
|
||||||
|
#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);
|
||||||
|
)
|
@ -34,6 +34,7 @@ clutter_conform_tests_classes_tests = [
|
|||||||
clutter_conform_tests_general_tests = [
|
clutter_conform_tests_general_tests = [
|
||||||
'binding-pool',
|
'binding-pool',
|
||||||
'color',
|
'color',
|
||||||
|
'event-delivery',
|
||||||
'frame-clock',
|
'frame-clock',
|
||||||
'frame-clock-timeline',
|
'frame-clock-timeline',
|
||||||
'grab',
|
'grab',
|
||||||
|
Loading…
Reference in New Issue
Block a user