tests/wayland: Add connector lease with leased connector test

Add a test that:
- Creates 2 clients
- Leases a connector using the first client
- Tries to lease the same connector using the second client
- Checks that the first lease succeeded
- Checks that the second lease failed

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4031>
This commit is contained in:
José Expósito 2024-09-09 08:44:30 +02:00 committed by Marge Bot
parent e6178fae6d
commit c804222e40
2 changed files with 59 additions and 0 deletions

View File

@ -70,6 +70,21 @@ test_drm_lease_lease_request (void)
meta_wayland_test_client_finish (wayland_test_client);
}
static void
test_drm_lease_lease_leased_connector (void)
{
MetaWaylandTestClient *wayland_test_client;
wayland_test_client = meta_wayland_test_client_new_with_args (test_context,
"drm-lease",
"lease-leased-connector",
NULL);
g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
"Failed to create lease from connector list:*");
meta_wayland_test_client_finish (wayland_test_client);
g_test_assert_expected_messages ();
}
static void
init_tests (void)
{
@ -79,6 +94,8 @@ init_tests (void)
test_drm_lease_release_device);
g_test_add_func ("/wayland/drm-lease/lease-request",
test_drm_lease_lease_request);
g_test_add_func ("/wayland/drm-lease/lease-leased-connector",
test_drm_lease_lease_leased_connector);
}
static void

View File

@ -678,6 +678,46 @@ test_drm_lease_lease_request (WaylandDisplay *display)
return EXIT_SUCCESS;
}
static int
test_drm_lease_lease_leased_connector (WaylandDisplay *display)
{
DrmLeaseClient *client1;
DrmLeaseClient *client2;
DrmLeaseLease *lease1;
DrmLeaseLease *lease2;
guint connectors[] = {0};
int num_connectors = G_N_ELEMENTS (connectors);
/* Create and submit 2 leases with the same connector */
client1 = drm_lease_client_new (display);
client2 = drm_lease_client_new (display);
lease1 = drm_lease_lease_new (client1, 0, connectors, num_connectors);
lease2 = drm_lease_lease_new (client2, 0, connectors, num_connectors);
drm_lease_lease_submit (lease1);
drm_lease_lease_submit (lease2);
/* Check that the first one succeeded */
event_queue_assert_event (client1->event_queue, CONNECTOR_WITHDRAWN);
event_queue_assert_event (client1->event_queue, DEVICE_DONE);
event_queue_assert_event (client1->event_queue, LEASE_FD);
event_queue_assert_empty (client1->event_queue);
/* Check that the second one failed */
event_queue_assert_event (client2->event_queue, CONNECTOR_WITHDRAWN);
event_queue_assert_event (client2->event_queue, DEVICE_DONE);
event_queue_assert_event (client2->event_queue, LEASE_FINISHED);
event_queue_assert_empty (client2->event_queue);
drm_lease_lease_free (lease1);
drm_lease_lease_free (lease2);
drm_lease_client_free (client1);
drm_lease_client_free (client2);
return EXIT_SUCCESS;
}
int
main (int argc,
char **argv)
@ -697,6 +737,8 @@ main (int argc,
return test_drm_lease_release_device (display);
else if (g_strcmp0 (test_case, "lease-request") == 0)
return test_drm_lease_lease_request (display);
else if (g_strcmp0 (test_case, "lease-leased-connector") == 0)
return test_drm_lease_lease_leased_connector (display);
return EXIT_FAILURE;
}