[mutter] context/test: Add 'before-tests' and 'after-tests' signals



commit ccd8da336f1b35a704dc84bdb7edceeb178c8014
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Mar 2 16:37:26 2021 +0100

    context/test: Add 'before-tests' and 'after-tests' signals
    
    Will be used to set up and tear down test infrastructure.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>

 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 420aa0ccdd..b9dcf327c7 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;
+
+  g_signal_emit (context, signals[BEFORE_TESTS], 0);
+  ret = g_test_run ();
+  g_signal_emit (context, signals[AFTER_TESTS], 0);
 
-  if (g_test_run () != 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


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