From 5c26d786f59ea568c7dd9a0d9729342d0eb6aa84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 3 Aug 2022 18:57:10 +0200 Subject: [PATCH] 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: --- src/backends/meta-virtual-monitor.h | 1 + src/tests/test-runner.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/backends/meta-virtual-monitor.h b/src/backends/meta-virtual-monitor.h index c127c46ca..6699c8ece 100644 --- a/src/backends/meta-virtual-monitor.h +++ b/src/backends/meta-virtual-monitor.h @@ -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 diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c index c67780c9c..75d9c765d 100644 --- a/src/tests/test-runner.c +++ b/src/tests/test-runner.c @@ -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 ", 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]);