From 0f0659e0e8c5d09b8b87b2309f0620a49f868db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 12 Mar 2025 12:30:50 +0800 Subject: [PATCH] tests: Add overlay cursor test This test checks a particular issue, where a pointer moved in a way resulting in the cursor position not changing, then moving again, changing the cursor position, not damaging the area of the original position, causing the cursor to get "stuck" until damaged due to some other reason. Part-of: --- src/tests/cursor-overlay-tests.c | 108 ++++++++++++++++++ src/tests/meson.build | 8 ++ .../backends_cursor-overlay_damage_0.ref.png | Bin 0 -> 837 bytes 3 files changed, 116 insertions(+) create mode 100644 src/tests/cursor-overlay-tests.c create mode 100644 src/tests/ref-tests/backends_cursor-overlay_damage_0.ref.png diff --git a/src/tests/cursor-overlay-tests.c b/src/tests/cursor-overlay-tests.c new file mode 100644 index 000000000..2cbe1eee2 --- /dev/null +++ b/src/tests/cursor-overlay-tests.c @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2025 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * + */ + +#include "config.h" + +#include "backends/meta-backend-private.h" +#include "backends/meta-renderer.h" +#include "tests/meta-test/meta-context-test.h" +#include "tests/meta-test/meta-test-monitor.h" +#include "tests/meta-ref-test.h" +#include "tests/meta-test-utils.h" + +static MetaContext *test_context; + +static ClutterStageView * +get_view (void) +{ + MetaBackend *backend = meta_context_get_backend (test_context); + MetaRenderer *renderer = meta_backend_get_renderer (backend); + GList *views; + + views = meta_renderer_get_views (renderer); + g_assert_cmpuint (g_list_length (views), ==, 1); + + return CLUTTER_STAGE_VIEW (views->data); +} + +static void +meta_test_cursor_overlay_damage (void) +{ + MetaBackend *backend = meta_context_get_backend (test_context); + ClutterSeat *seat = meta_backend_get_default_seat (backend); + g_autoptr (MetaVirtualMonitor) test_monitor = NULL; + g_autoptr (ClutterVirtualInputDevice) virtual_pointer = NULL; + g_autoptr (GError) error = NULL; + + test_monitor = meta_create_test_monitor (test_context, 100, 100, 60.0); + g_assert_nonnull (test_monitor); + g_assert_no_error (error); + + virtual_pointer = clutter_seat_create_virtual_device (seat, + CLUTTER_POINTER_DEVICE); + clutter_virtual_input_device_notify_absolute_motion (virtual_pointer, + g_get_monotonic_time (), + 50.0f, 50.0f); + + meta_flush_input (test_context); + meta_wait_for_paint (test_context); + + clutter_virtual_input_device_notify_absolute_motion (virtual_pointer, + g_get_monotonic_time (), + 50.0f, 50.0f); + + meta_flush_input (test_context); + meta_wait_for_paint (test_context); + + clutter_virtual_input_device_notify_absolute_motion (virtual_pointer, + g_get_monotonic_time (), + 75.0f, 75.0f); + + meta_flush_input (test_context); + + meta_ref_test_verify_view_undamaged (get_view (), + g_test_get_path (), 0, + meta_ref_test_determine_ref_test_flag ()); +} + +static void +init_tests (void) +{ + g_test_add_func ("/backends/cursor-overlay/damage", + meta_test_cursor_overlay_damage); +} + +int +main (int argc, + char **argv) +{ + g_autoptr (MetaContext) context = NULL; + + context = meta_create_test_context (META_CONTEXT_TEST_TYPE_HEADLESS, + META_CONTEXT_TEST_FLAG_NO_X11); + g_assert_true (meta_context_configure (context, &argc, &argv, NULL)); + meta_context_test_set_background_color (META_CONTEXT_TEST (context), + COGL_COLOR_INIT (255, 255, 255, 255)); + + test_context = context; + + init_tests (); + + return meta_context_test_run_tests (META_CONTEXT_TEST (context), + META_TEST_RUN_FLAG_NONE); +} diff --git a/src/tests/meson.build b/src/tests/meson.build index 0bc6370e2..570c853fa 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -512,6 +512,14 @@ test_cases += [ 'meta-thread-impl-test.h', ], }, + { + 'name': 'cursor-overlay-tests', + 'suite': 'backends/native', + 'sources': [ + 'cursor-overlay-tests.c', + wayland_test_utils, + ], + }, { 'name': 'cursor-tests', 'suite': 'backends/native', diff --git a/src/tests/ref-tests/backends_cursor-overlay_damage_0.ref.png b/src/tests/ref-tests/backends_cursor-overlay_damage_0.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..90bc723e8ab6ddb3a35c4ffb8e12808eb860a055 GIT binary patch literal 837 zcmeAS@N?(olHy`uVBq!ia0vp^DIm$Ixj+P9{?@<$HkPxfnCu(WCF+%Q8e z36;Q2@78Qi7TjRbx4Slmf9K8T_m`g7@TcO0w#ua_?TCF>{NoS&7und*!Rn%;ki;m+ z-4Wq%gh@$EVDJiQ+1E1u-==eVlg{KIt))w*u=*EQMqaz6;yESAbCN`I*Z;09k0aKv zU+<-v>?3ph=w6xQUYA2SHg4XWyjJ(!Q=@BFyg3T%>h|s49ew9?;hOXNj;_{;xc?|r zY0aa!r-!s&gj%gpic3B6Yg4%A#(mG8{-{2DzpSim+s>UoD=$lY{`Sqx+S=OK`15n? zX&kHX=0#`w`}_Cz^)1qP^|fl>`|5euGfbk^PJ92m{^%sW|DF>KpFMn-n40S9bu(}K z?z``f9zFW)+qNm6o;^Dz@%VS$(x8tv>%&$*Jt%bT?!Ei>fB)ULwJbaP_0OL>Z@;y( zwav}R;ZWq`<9ql1z5C+8S<8;i&^i4{CZa2~*KP6X)85&+d*k-+-Fx@;ZSJNA@80=& z?cA_o!vDp3$LI4dosu~#E;d$IPj6e4?%LAjmpd0}cuso!IC<^XYf=_xAEu^8n#u67 zH#Y{Yx|ze~_~FM7iJRr-<@UA9Ke rojrSX$S1vJF%hiAKN^abY;&TRYS=qqzF_cl^>bP0l+XkKBkF>w literal 0 HcmV?d00001