From ccd8da336f1b35a704dc84bdb7edceeb178c8014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 2 Mar 2021 16:37:26 +0100 Subject: [PATCH] context/test: Add 'before-tests' and 'after-tests' signals Will be used to set up and tear down test infrastructure. Part-of: --- src/tests/meta-context-test.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/tests/meta-context-test.c b/src/tests/meta-context-test.c index 420aa0ccd..b9dcf327c 100644 --- a/src/tests/meta-context-test.c +++ b/src/tests/meta-context-test.c @@ -34,6 +34,15 @@ #include "backends/native/meta-backend-native.h" #endif +enum +{ + BEFORE_TESTS, + AFTER_TESTS, + N_SIGNALS +}; + +static guint signals[N_SIGNALS]; + struct _MetaContextTest { GObject parent; @@ -145,8 +154,13 @@ static gboolean run_tests_idle (gpointer user_data) { MetaContext *context = user_data; + int ret; - if (g_test_run () != 0) + g_signal_emit (context, signals[BEFORE_TESTS], 0); + ret = g_test_run (); + g_signal_emit (context, signals[AFTER_TESTS], 0); + + if (ret != 0) { GError *error; @@ -218,6 +232,23 @@ meta_context_test_class_init (MetaContextTestClass *klass) context_class->setup = meta_context_test_setup; context_class->create_backend = meta_context_test_create_backend; context_class->notify_ready = meta_context_test_notify_ready; + + signals[BEFORE_TESTS] = + g_signal_new ("before-tests", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, + 0); + signals[AFTER_TESTS] = + g_signal_new ("after-tests", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, + 0); } static void