1 /* GLib testing framework examples and tests
3 * Copyright (C) 2008-2009 Red Hat, Inc.
5 * SPDX-License-Identifier: LGPL-2.1-or-later
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
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,
119 void ensure_gdbus_testserver_up (GDBusConnection *connection,
120 GMainContext *context);
124 #endif /* __TESTS_H__ */