1
0
mirror of https://github.com/brl/mutter.git synced 2025-03-26 21:23:55 +00:00

tests/runner: Add 'resize_monitor' metatest command

This will allow tests to change monitor resolution. The first argument
is the monitor ID; there is always one monitor added by default, and it
has the id 0. It's currently not possible to add more monitors, so
passing '0' is the only valid way to resize monitors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
This commit is contained in:
Jonas Ådahl 2022-08-03 18:57:10 +02:00 committed by Marge Bot
parent 06d9ed3da7
commit 5c26d786f5
2 changed files with 24 additions and 0 deletions

@ -70,6 +70,7 @@ void meta_virtual_monitor_info_free (MetaVirtualMonitorInfo *info);
MetaCrtc * meta_virtual_monitor_get_crtc (MetaVirtualMonitor *virtual_monitor);
META_EXPORT_TEST
MetaCrtcMode * meta_virtual_monitor_get_crtc_mode (MetaVirtualMonitor *virtual_monitor);
META_EXPORT_TEST

@ -989,6 +989,29 @@ test_case_do (TestCase *test,
if (!meta_test_client_do (client, error, argv[0], argv[2], argv[3], NULL))
return FALSE;
}
else if (strcmp (argv[0], "resize_monitor") == 0)
{
MetaBackend *backend = meta_context_get_backend (test->context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaCrtcMode *crtc_mode;
const MetaCrtcModeInfo *crtc_mode_info;
if (argc != 4)
BAD_COMMAND ("usage: %s <monitor-id> <width> <height>", argv[0]);
if (strcmp (argv[1], "0") != 0 &&
strcmp (argv[1], "primary") != 0)
BAD_COMMAND ("Unknown monitor %s", argv[1]);
crtc_mode = meta_virtual_monitor_get_crtc_mode (test->virtual_monitor);
crtc_mode_info = meta_crtc_mode_get_info (crtc_mode);
meta_virtual_monitor_set_mode (test->virtual_monitor,
atoi (argv[2]),
atoi (argv[3]),
crtc_mode_info->refresh_rate);
meta_monitor_manager_reload (monitor_manager);
}
else
{
BAD_COMMAND("Unknown command %s", argv[0]);