[mutter] tests/ref-test-sanity: Port to MetaContext



commit 648a8b9861e16d82fe808bda6ed41ec90945da6d
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Mar 2 19:56:26 2021 +0100

    tests/ref-test-sanity: Port to MetaContext
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>

 src/tests/ref-test-sanity.c | 43 ++++++++++---------------------------------
 1 file changed, 10 insertions(+), 33 deletions(-)
---
diff --git a/src/tests/ref-test-sanity.c b/src/tests/ref-test-sanity.c
index 74cecfd0c2..af7b0185a1 100644
--- a/src/tests/ref-test-sanity.c
+++ b/src/tests/ref-test-sanity.c
@@ -20,12 +20,8 @@
 
 #include "backends/meta-virtual-monitor.h"
 #include "backends/native/meta-renderer-native.h"
-#include "compositor/meta-plugin-manager.h"
-#include "core/main-private.h"
-#include "meta/main.h"
-#include "meta/meta-enums.h"
+#include "tests/meta-context-test.h"
 #include "tests/meta-ref-test.h"
-#include "tests/test-utils.h"
 
 static MetaVirtualMonitor *virtual_monitor;
 
@@ -73,22 +69,6 @@ tear_down_test_environment (void)
   meta_monitor_manager_reload (monitor_manager);
 }
 
-static gboolean
-run_tests (gpointer data)
-{
-  int ret;
-
-  setup_test_environment ();
-
-  ret = g_test_run ();
-
-  tear_down_test_environment ();
-
-  meta_quit (ret != 0);
-
-  return ret;
-}
-
 static ClutterStageView *
 get_view (void)
 {
@@ -151,20 +131,17 @@ int
 main (int    argc,
       char **argv)
 {
-  test_init (&argc, &argv);
-  init_ref_test_sanity_tests ();
+  g_autoptr (MetaContext) context = NULL;
 
-  meta_plugin_manager_load (test_get_plugin_name ());
+  context = meta_create_test_context (META_CONTEXT_TEST_TYPE_HEADLESS);
+  g_assert (meta_context_configure (context, &argc, &argv, NULL));
 
-  meta_override_compositor_configuration (META_COMPOSITOR_TYPE_WAYLAND,
-                                          META_TYPE_BACKEND_NATIVE,
-                                          "headless", TRUE,
-                                          NULL);
-
-  meta_init ();
-  meta_register_with_session ();
+  init_ref_test_sanity_tests ();
 
-  g_idle_add (run_tests, NULL);
+  g_signal_connect (context, "before-tests",
+                    G_CALLBACK (setup_test_environment), NULL);
+  g_signal_connect (context, "after-tests",
+                    G_CALLBACK (tear_down_test_environment), NULL);
 
-  return meta_run ();
+  return meta_context_test_run_tests (META_CONTEXT_TEST (context));
 }


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