Simplify subprocesses in tests
[platform/upstream/glib.git] / gobject / tests / signals.c
index 95c0501..45f4846 100644 (file)
@@ -75,6 +75,7 @@ static GType enum_type;
 static GType flags_type;
 
 static guint simple_id;
+static guint simple2_id;
 
 typedef struct _Test Test;
 typedef struct _TestClass TestClass;
@@ -121,6 +122,14 @@ test_class_init (TestClass *klass)
                 NULL,
                 G_TYPE_NONE,
                 0);
+  simple2_id = g_signal_new ("simple-2",
+                G_TYPE_FROM_CLASS (klass),
+                G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
+                0,
+                NULL, NULL,
+                NULL,
+                G_TYPE_NONE,
+                0);
   g_signal_new ("generic-marshaller-1",
                 G_TYPE_FROM_CLASS (klass),
                 G_SIGNAL_RUN_LAST,
@@ -872,6 +881,45 @@ test_emission_hook (void)
   g_signal_remove_emission_hook (simple_id, hook);
   g_signal_emit_by_name (test1, "simple");
   g_assert_cmpint (count, ==, 2);
+
+  g_object_unref (test1);
+  g_object_unref (test2);
+}
+
+static void
+simple_cb (gpointer instance, gpointer data)
+{
+  GSignalInvocationHint *ihint;
+
+  ihint = g_signal_get_invocation_hint (instance);
+
+  g_assert_cmpstr (g_signal_name (ihint->signal_id), ==, "simple");
+
+  g_signal_emit_by_name (instance, "simple-2");
+}
+
+static void
+simple2_cb (gpointer instance, gpointer data)
+{
+  GSignalInvocationHint *ihint;
+
+  ihint = g_signal_get_invocation_hint (instance);
+
+  g_assert_cmpstr (g_signal_name (ihint->signal_id), ==, "simple-2");
+}
+
+static void
+test_invocation_hint (void)
+{
+  GObject *test;
+
+  test = g_object_new (test_get_type (), NULL);
+
+  g_signal_connect (test, "simple", G_CALLBACK (simple_cb), NULL);
+  g_signal_connect (test, "simple-2", G_CALLBACK (simple2_cb), NULL);
+  g_signal_emit_by_name (test, "simple");
+
+  g_object_unref (test);
 }
 
 static gboolean
@@ -898,6 +946,7 @@ test_introspection (void)
   gint i;
   const gchar *names[] = {
     "simple",
+    "simple-2",
     "generic-marshaller-1",
     "generic-marshaller-2",
     "generic-marshaller-enum-return-signed",
@@ -933,6 +982,8 @@ test_introspection (void)
   g_assert (query.signal_flags == G_SIGNAL_RUN_LAST);
   g_assert (query.return_type == G_TYPE_NONE);
   g_assert_cmpuint (query.n_params, ==, 0);
+
+  g_free (ids);
 }
 
 static void
@@ -1061,6 +1112,7 @@ main (int argc,
   g_test_add_func ("/gobject/signals/introspection", test_introspection);
   g_test_add_func ("/gobject/signals/block-handler", test_block_handler);
   g_test_add_func ("/gobject/signals/stop-emission", test_stop_emission);
+  g_test_add_func ("/gobject/signals/invocation-hint", test_invocation_hint);
 
   return g_test_run ();
 }