]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
tests: Add a GAsyncReadyCallback that stores the GAsyncResult
authorSimon McVittie <smcv@collabora.com>
Mon, 16 Apr 2018 18:39:04 +0000 (19:39 +0100)
committerSimon McVittie <smcv@collabora.com>
Thu, 21 Jun 2018 16:42:07 +0000 (17:42 +0100)
It seems I eventually introduce this into every project where I've
added GLib-based unit tests. Today it's dbus' turn.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105656

test/test-utils-glib.c
test/test-utils-glib.h

index ec9971c53cc037f825ae73b58102038fe56cb1a9..94e28c8981a27c409d625dadf0092c2fe4dd10b2 100644 (file)
@@ -819,3 +819,19 @@ test_check_tcp_works (void)
   return TRUE;
 #endif
 }
+
+/*
+ * Store the result of an async operation. @user_data is a pointer to a
+ * variable that can store @result, initialized to %NULL.
+ */
+void
+test_store_result_cb (GObject *source_object G_GNUC_UNUSED,
+                      GAsyncResult *result,
+                      gpointer user_data)
+{
+  GAsyncResult **result_p = user_data;
+
+  g_assert_nonnull (result_p);
+  g_assert_null (*result_p);
+  *result_p = g_object_ref (result);
+}
index a2712c059220e45956ec2d7291932ee3f2d7b93a..d36f4301576d794ca6343bff63764463c47a1515 100644 (file)
@@ -123,4 +123,8 @@ backported_g_steal_pointer (gpointer pointer_to_pointer)
 
 gboolean test_check_tcp_works (void);
 
+void test_store_result_cb (GObject *source_object,
+                           GAsyncResult *result,
+                           gpointer user_data);
+
 #endif