1 /* GLib testing framework examples and tests
3 * Copyright (C) 2008-2009 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: David Zeuthen <davidz@redhat.com>
27 #include "gdbus-sessionbus.h"
31 /* TODO: clean up and move to gtestutils.c
33 * This is needed because libdbus-1 does not give predictable error messages - e.g. you
34 * get a different error message on connecting to a bus if the socket file is there vs
35 * if the socket file is missing.
38 #define _g_assert_error_domain(err, dom) do { if (!err || (err)->domain != dom) \
39 g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
40 #err, err, dom, -1); } while (0)
42 #define _g_assert_property_notify(object, property_name) \
45 if (!G_IS_OBJECT (object)) \
47 g_assertion_message (G_LOG_DOMAIN, \
51 "Not a GObject instance"); \
53 if (g_object_class_find_property (G_OBJECT_GET_CLASS (object), \
54 property_name) == NULL) \
56 g_assertion_message (G_LOG_DOMAIN, \
60 "Property " property_name " does not " \
63 if (_g_assert_property_notify_run (object, property_name)) \
65 g_assertion_message (G_LOG_DOMAIN, \
69 "Timed out waiting for notification " \
70 "on property " property_name); \
75 #define _g_assert_signal_received(object, signal_name) \
78 if (!G_IS_OBJECT (object)) \
80 g_assertion_message (G_LOG_DOMAIN, \
84 "Not a GObject instance"); \
86 if (g_signal_lookup (signal_name, \
87 G_TYPE_FROM_INSTANCE (object)) == 0) \
89 g_assertion_message (G_LOG_DOMAIN, \
93 "Signal `" signal_name "' does not " \
96 if (_g_assert_signal_received_run (object, signal_name)) \
98 g_assertion_message (G_LOG_DOMAIN, \
102 "Timed out waiting for signal `" \
108 gboolean _g_assert_property_notify_run (gpointer object,
109 const gchar *property_name);
112 gboolean _g_assert_signal_received_run (gpointer object,
113 const gchar *signal_name);
115 GDBusConnection *_g_bus_get_priv (GBusType bus_type,
116 GCancellable *cancellable,
120 #define _g_object_wait_for_single_ref(object) \
123 if (!G_IS_OBJECT (object)) \
125 g_assertion_message (G_LOG_DOMAIN, \
129 "Not a GObject instance"); \
131 if (_g_object_wait_for_single_ref_do (object)) \
133 g_assertion_message (G_LOG_DOMAIN, \
137 "Timed out waiting for single ref"); \
142 gboolean _g_object_wait_for_single_ref_do (gpointer object);
146 #endif /* __TESTS_H__ */