Add some more cases to the app-id unit tests
[glib.git] / gio / tests / gdbus-tests.h
blob6e31d7b439f2ad2b86c4880b90cc6ee5b2d2f96c
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>
21 #ifndef __TESTS_H__
22 #define __TESTS_H__
24 #include <gio/gio.h>
25 #include "gdbus-sessionbus.h"
27 G_BEGIN_DECLS
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) \
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)
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 "'"); \
104 while (FALSE)
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,
115 GError **error);
117 void ensure_gdbus_testserver_up (void);
119 G_END_DECLS
121 #endif /* __TESTS_H__ */