summaryrefslogtreecommitdiff
path: root/test/test-utils-glib.c
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2018-04-16 19:39:04 +0100
committerSimon McVittie <smcv@collabora.com>2018-06-21 17:42:07 +0100
commit50a724b6fc8f68ad9baf6e6d04601d6b94278e3a (patch)
tree3cc099d09389c396c4be94c42a428365e15bb15d /test/test-utils-glib.c
parentf366c4748ae0bb357b4d3071f30df62bbc88251d (diff)
downloaddbus-50a724b6fc8f68ad9baf6e6d04601d6b94278e3a.tar.gz
tests: Add a GAsyncReadyCallback that stores the GAsyncResult
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
Diffstat (limited to 'test/test-utils-glib.c')
-rw-r--r--test/test-utils-glib.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c
index ec9971c5..94e28c89 100644
--- a/test/test-utils-glib.c
+++ b/test/test-utils-glib.c
@@ -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);
+}