From 57d1d82ead6392a104a9e9d6c7f1f4f14ad54e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 14 Jan 2022 22:11:17 +0100 Subject: [PATCH] test/utils: Add helper to set custom monitors config Make the existing implementation a wrapper to avoid changing monitor config tests. Part-of: --- src/tests/meta-test-utils.c | 23 +++++++++++++++++++++++ src/tests/meta-test-utils.h | 4 ++++ src/tests/monitor-test-utils.c | 18 +----------------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/tests/meta-test-utils.c b/src/tests/meta-test-utils.c index 0b400b175..9701ce250 100644 --- a/src/tests/meta-test-utils.c +++ b/src/tests/meta-test-utils.c @@ -25,6 +25,7 @@ #include #include +#include "backends/meta-monitor-config-store.h" #include "core/display-private.h" #include "core/window-private.h" #include "meta-test/meta-context-test.h" @@ -591,3 +592,25 @@ meta_test_get_plugin_name (void) else return "libdefault"; } + +void +meta_set_custom_monitor_config (MetaBackend *backend, + const char *filename) +{ + MetaMonitorManager *monitor_manager = + meta_backend_get_monitor_manager (backend); + MetaMonitorConfigManager *config_manager = monitor_manager->config_manager; + MetaMonitorConfigStore *config_store; + GError *error = NULL; + const char *path; + + g_assert_nonnull (config_manager); + + config_store = meta_monitor_config_manager_get_store (config_manager); + + path = g_test_get_filename (G_TEST_DIST, "tests", "monitor-configs", + filename, NULL); + if (!meta_monitor_config_store_set_custom (config_store, path, NULL, + &error)) + g_error ("Failed to set custom config: %s", error->message); +} diff --git a/src/tests/meta-test-utils.h b/src/tests/meta-test-utils.h index 20c714998..cf9df9d41 100644 --- a/src/tests/meta-test-utils.h +++ b/src/tests/meta-test-utils.h @@ -108,4 +108,8 @@ void meta_test_client_destroy (MetaTestClient *client); META_EXPORT const char * meta_test_get_plugin_name (void); +META_EXPORT +void meta_set_custom_monitor_config (MetaBackend *backend, + const char *filename); + #endif /* TEST_UTILS_H */ diff --git a/src/tests/monitor-test-utils.c b/src/tests/monitor-test-utils.c index 723d99167..7f4f092f3 100644 --- a/src/tests/monitor-test-utils.c +++ b/src/tests/monitor-test-utils.c @@ -41,23 +41,7 @@ test_get_gpu (void) void set_custom_monitor_config (const char *filename) { - MetaBackend *backend = meta_get_backend (); - MetaMonitorManager *monitor_manager = - meta_backend_get_monitor_manager (backend); - MetaMonitorConfigManager *config_manager = monitor_manager->config_manager; - MetaMonitorConfigStore *config_store; - GError *error = NULL; - const char *path; - - g_assert_nonnull (config_manager); - - config_store = meta_monitor_config_manager_get_store (config_manager); - - path = g_test_get_filename (G_TEST_DIST, "tests", "monitor-configs", - filename, NULL); - if (!meta_monitor_config_store_set_custom (config_store, path, NULL, - &error)) - g_error ("Failed to set custom config: %s", error->message); + meta_set_custom_monitor_config (meta_get_backend (), filename); } char *