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, see <http://www.gnu.org/licenses/>.
18 * Author: David Zeuthen <davidz@redhat.com>
25 #include "gdbus-sessionbus.h"
29 /* TODO: clean up and move to gtestutils.c
31 * This is needed because libdbus-1 does not give predictable error messages - e.g. you
32 * get a different error message on connecting to a bus if the socket file is there vs
33 * if the socket file is missing.
36 #define _g_assert_error_domain(err, dom) do { if (!err || (err)->domain != dom) \
37 g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
38 #err, err, dom, -1); } while (0)
40 #define _g_assert_property_notify(object, property_name) \
43 if (!G_IS_OBJECT (object)) \
45 g_assertion_message (G_LOG_DOMAIN, \
49 "Not a GObject instance"); \
51 if (g_object_class_find_property (G_OBJECT_GET_CLASS (object), \
52 property_name) == NULL) \
54 g_assertion_message (G_LOG_DOMAIN, \
58 "Property " property_name " does not " \
61 if (_g_assert_property_notify_run (object, property_name)) \
63 g_assertion_message (G_LOG_DOMAIN, \
67 "Timed out waiting for notification " \
68 "on property " property_name); \
73 #define _g_assert_signal_received(object, signal_name) \
76 if (!G_IS_OBJECT (object)) \
78 g_assertion_message (G_LOG_DOMAIN, \
82 "Not a GObject instance"); \
84 if (g_signal_lookup (signal_name, \
85 G_TYPE_FROM_INSTANCE (object)) == 0) \
87 g_assertion_message (G_LOG_DOMAIN, \
91 "Signal '" signal_name "' does not " \
94 if (_g_assert_signal_received_run (object, signal_name)) \
96 g_assertion_message (G_LOG_DOMAIN, \
100 "Timed out waiting for signal '" \
106 gboolean
_g_assert_property_notify_run (gpointer object
,
107 const gchar
*property_name
);
110 gboolean
_g_assert_signal_received_run (gpointer object
,
111 const gchar
*signal_name
);
113 GDBusConnection
*_g_bus_get_priv (GBusType bus_type
,
114 GCancellable
*cancellable
,
117 void ensure_gdbus_testserver_up (void);
121 #endif /* __TESTS_H__ */