[mutter/wip/carlosg/move-pointer-onscreen: 10/12] test/utils: Add helper to set custom monitors config




commit 57d1d82ead6392a104a9e9d6c7f1f4f14ad54e48
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Jan 14 22:11:17 2022 +0100

    test/utils: Add helper to set custom monitors config
    
    Make the existing implementation a wrapper to avoid changing monitor
    config tests.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>

 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 0b400b175a..9701ce2500 100644
--- a/src/tests/meta-test-utils.c
+++ b/src/tests/meta-test-utils.c
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <X11/Xlib-xcb.h>
 
+#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 20c7149986..cf9df9d41b 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 723d991674..7f4f092f3e 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 *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]