tests/stacking: Add support for moving the cursor and clicking
Also test that clicking on a window will focus and raise it. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2748>
This commit is contained in:
parent
619fc55408
commit
f6d96a6118
@ -488,6 +488,7 @@ stacking_tests = [
|
||||
'always-on-top',
|
||||
'focus-default-window-globally-active-input',
|
||||
'workspace-unmanaging-window',
|
||||
'click-to-focus-and-raise',
|
||||
]
|
||||
|
||||
foreach stacking_test: stacking_tests
|
||||
|
33
src/tests/stacking/click-to-focus-and-raise.metatest
Normal file
33
src/tests/stacking/click-to-focus-and-raise.metatest
Normal file
@ -0,0 +1,33 @@
|
||||
resize_monitor primary 800 600
|
||||
|
||||
new_client w wayland
|
||||
|
||||
create w/1 csd
|
||||
resize w/1 100 100
|
||||
show w/1
|
||||
|
||||
create w/2 csd
|
||||
resize w/2 100 100
|
||||
show w/2
|
||||
|
||||
wait_reconfigure
|
||||
|
||||
move w/1 0 0
|
||||
move w/2 100 0
|
||||
|
||||
wait_reconfigure
|
||||
|
||||
assert_stacking w/1 w/2
|
||||
assert_focused w/2
|
||||
|
||||
assert_position w/1 0 0
|
||||
assert_size w/1 100 100
|
||||
assert_position w/2 100 0
|
||||
assert_size w/2 100 100
|
||||
|
||||
move_cursor_to 50 50
|
||||
click
|
||||
wait
|
||||
|
||||
assert_stacking w/2 w/1
|
||||
assert_focused w/1
|
@ -43,6 +43,7 @@ typedef struct {
|
||||
GMainLoop *loop;
|
||||
gulong x11_display_opened_handler_id;
|
||||
MetaVirtualMonitor *virtual_monitor;
|
||||
ClutterVirtualInputDevice *pointer;
|
||||
} TestCase;
|
||||
|
||||
static gboolean
|
||||
@ -76,6 +77,8 @@ test_case_new (MetaContext *context)
|
||||
{
|
||||
TestCase *test = g_new0 (TestCase, 1);
|
||||
MetaDisplay *display = meta_context_get_display (context);
|
||||
MetaBackend *backend = meta_context_get_backend (context);
|
||||
ClutterSeat *seat = meta_backend_get_default_seat (backend);
|
||||
|
||||
if (display->x11_display)
|
||||
{
|
||||
@ -93,6 +96,8 @@ test_case_new (MetaContext *context)
|
||||
test->clients = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
test->loop = g_main_loop_new (NULL, FALSE);
|
||||
test->virtual_monitor = meta_create_test_monitor (context, 800, 600, 60.0);
|
||||
test->pointer = clutter_seat_create_virtual_device (seat,
|
||||
CLUTTER_POINTER_DEVICE);
|
||||
|
||||
return test;
|
||||
}
|
||||
@ -1170,6 +1175,34 @@ test_case_do (TestCase *test,
|
||||
|
||||
meta_display_focus_default_window (display, timestamp);
|
||||
}
|
||||
else if (strcmp (argv[0], "move_cursor_to") == 0)
|
||||
{
|
||||
if (argc != 3)
|
||||
BAD_COMMAND("usage: %s <x> <y>", argv[0]);
|
||||
|
||||
float x = atof (argv[1]);
|
||||
float y = atof (argv[2]);
|
||||
|
||||
clutter_virtual_input_device_notify_absolute_motion (test->pointer,
|
||||
CLUTTER_CURRENT_TIME,
|
||||
x, y);
|
||||
meta_flush_input (test->context);
|
||||
}
|
||||
else if (strcmp (argv[0], "click") == 0)
|
||||
{
|
||||
if (argc != 1)
|
||||
BAD_COMMAND("usage: %s", argv[0]);
|
||||
|
||||
clutter_virtual_input_device_notify_button (test->pointer,
|
||||
CLUTTER_CURRENT_TIME,
|
||||
CLUTTER_BUTTON_PRIMARY,
|
||||
CLUTTER_BUTTON_STATE_PRESSED);
|
||||
clutter_virtual_input_device_notify_button (test->pointer,
|
||||
CLUTTER_CURRENT_TIME,
|
||||
CLUTTER_BUTTON_PRIMARY,
|
||||
CLUTTER_BUTTON_STATE_RELEASED);
|
||||
meta_flush_input (test->context);
|
||||
}
|
||||
else
|
||||
{
|
||||
BAD_COMMAND("Unknown command %s", argv[0]);
|
||||
@ -1220,6 +1253,7 @@ test_case_destroy (TestCase *test,
|
||||
|
||||
g_hash_table_destroy (test->clients);
|
||||
g_object_unref (test->virtual_monitor);
|
||||
g_object_unref (test->pointer);
|
||||
g_free (test);
|
||||
|
||||
return TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user