1/* GLib testing framework examples and tests
2 *
3 * Copyright (C) 2008-2009 Red Hat, Inc.
4 *
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.1 of the License, or (at your option) any later version.
9 *
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.
14 *
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/>.
17 *
18 * Author: David Zeuthen <davidz@redhat.com>
19 */
20
21#ifndef __TESTS_H__
22#define __TESTS_H__
23
24#include <gio/gio.h>
25#include "gdbus-sessionbus.h"
26
27G_BEGIN_DECLS
28
29/* TODO: clean up and move to gtestutils.c
30 *
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.
34 */
35
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)
39
40#define _g_assert_property_notify(object, property_name) \
41 do \
42 { \
43 if (!G_IS_OBJECT (object)) \
44 { \
45 g_assertion_message (G_LOG_DOMAIN, \
46 __FILE__, \
47 __LINE__, \
48 G_STRFUNC, \
49 "Not a GObject instance"); \
50 } \
51 if (g_object_class_find_property (G_OBJECT_GET_CLASS (object), \
52 property_name) == NULL) \
53 { \
54 g_assertion_message (G_LOG_DOMAIN, \
55 __FILE__, \
56 __LINE__, \
57 G_STRFUNC, \
58 "Property " property_name " does not " \
59 "exist on object"); \
60 } \
61 if (_g_assert_property_notify_run (object, property_name)) \
62 { \
63 g_assertion_message (G_LOG_DOMAIN, \
64 __FILE__, \
65 __LINE__, \
66 G_STRFUNC, \
67 "Timed out waiting for notification " \
68 "on property " property_name); \
69 } \
70 } \
71 while (FALSE)
72
73#define _g_assert_signal_received(object, signal_name) \
74 do \
75 { \
76 if (!G_IS_OBJECT (object)) \
77 { \
78 g_assertion_message (G_LOG_DOMAIN, \
79 __FILE__, \
80 __LINE__, \
81 G_STRFUNC, \
82 "Not a GObject instance"); \
83 } \
84 if (g_signal_lookup (signal_name, \
85 G_TYPE_FROM_INSTANCE (object)) == 0) \
86 { \
87 g_assertion_message (G_LOG_DOMAIN, \
88 __FILE__, \
89 __LINE__, \
90 G_STRFUNC, \
91 "Signal '" signal_name "' does not " \
92 "exist on object"); \
93 } \
94 if (_g_assert_signal_received_run (object, signal_name)) \
95 { \
96 g_assertion_message (G_LOG_DOMAIN, \
97 __FILE__, \
98 __LINE__, \
99 G_STRFUNC, \
100 "Timed out waiting for signal '" \
101 signal_name "'"); \
102 } \
103 } \
104 while (FALSE)
105
106gboolean _g_assert_property_notify_run (gpointer object,
107 const gchar *property_name);
108
109
110gboolean _g_assert_signal_received_run (gpointer object,
111 const gchar *signal_name);
112
113GDBusConnection *_g_bus_get_priv (GBusType bus_type,
114 GCancellable *cancellable,
115 GError **error);
116
117void ensure_gdbus_testserver_up (GDBusConnection *connection,
118 GMainContext *context);
119
120G_END_DECLS
121
122#endif /* __TESTS_H__ */
123

source code of gtk/subprojects/glib/gio/tests/gdbus-tests.h