From 3d2160b4736d6e4ef2be31b37f5e099f0a69fb41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 2 Mar 2021 16:38:33 +0100 Subject: [PATCH] tests/unit-tests: Port to MetaContext Part-of: --- src/tests/unit-tests.c | 57 +++++++++++------------------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/src/tests/unit-tests.c b/src/tests/unit-tests.c index 88e3a5b8a..c7c9943e6 100644 --- a/src/tests/unit-tests.c +++ b/src/tests/unit-tests.c @@ -25,19 +25,15 @@ #include #include -#include "compositor/meta-plugin-manager.h" #include "core/boxes-private.h" -#include "core/main-private.h" -#include "meta/meta-enums.h" +#include "meta/meta-context.h" #include "tests/boxes-tests.h" -#include "tests/meta-backend-test.h" +#include "tests/meta-context-test.h" #include "tests/monitor-config-migration-unit-tests.h" #include "tests/monitor-unit-tests.h" #include "tests/monitor-store-unit-tests.h" #include "tests/monitor-transform-tests.h" -#include "tests/test-utils.h" #include "tests/wayland-unit-tests.h" -#include "wayland/meta-wayland.h" typedef struct _MetaTestLaterOrderCallbackData { @@ -217,33 +213,8 @@ meta_test_adjacent_to (void) g_assert (!meta_rectangle_is_adjacent_to (&base, ¬_adjacent[i])); } -static gboolean -run_tests (gpointer data) -{ - MetaBackend *backend = meta_get_backend (); - MetaSettings *settings = meta_backend_get_settings (backend); - gboolean ret; - - meta_settings_override_experimental_features (settings); - - meta_settings_enable_experimental_feature ( - settings, - META_EXPERIMENTAL_FEATURE_SCALE_MONITOR_FRAMEBUFFER); - - pre_run_monitor_tests (); - pre_run_wayland_tests (); - - ret = g_test_run (); - - finish_monitor_tests (); - - meta_quit (ret != 0); - - return FALSE; -} - static void -init_tests (int argc, char **argv) +init_tests (void) { g_test_add_func ("/util/meta-later/order", meta_test_util_later_order); g_test_add_func ("/util/meta-later/schedule-from-later", @@ -262,19 +233,19 @@ init_tests (int argc, char **argv) int main (int argc, char *argv[]) { - test_init (&argc, &argv); - init_tests (argc, argv); + g_autoptr (MetaContext) context = NULL; - meta_plugin_manager_load (test_get_plugin_name ()); + context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED); + g_assert (meta_context_configure (context, &argc, &argv, NULL)); - meta_override_compositor_configuration (META_COMPOSITOR_TYPE_WAYLAND, - META_TYPE_BACKEND_TEST, - NULL); + init_tests (); - meta_init (); - meta_register_with_session (); + g_signal_connect (context, "before-tests", + G_CALLBACK (pre_run_monitor_tests), NULL); + g_signal_connect (context, "before-tests", + G_CALLBACK (pre_run_wayland_tests), NULL); + g_signal_connect (context, "after-tests", + G_CALLBACK (finish_monitor_tests), NULL); - g_idle_add (run_tests, NULL); - - return meta_run (); + return meta_context_test_run_tests (META_CONTEXT_TEST (context)); }