1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/* GLib testing framework examples and tests
*
* Copyright (C) 2008-2009 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: David Zeuthen <davidz@redhat.com>
*/
#ifndef __TESTS_H__
#define __TESTS_H__
#include <gio/gio.h>
#include "gdbus-sessionbus.h"
G_BEGIN_DECLS
/* TODO: clean up and move to gtestutils.c
*
* This is needed because libdbus-1 does not give predictable error messages - e.g. you
* get a different error message on connecting to a bus if the socket file is there vs
* if the socket file is missing.
*/
#define _g_assert_error_domain(err, dom) do { if (!err || (err)->domain != dom) \
g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
#err, err, dom, -1); } while (0)
#define _g_assert_property_notify(object, property_name) \
do \
{ \
if (!G_IS_OBJECT (object)) \
{ \
g_assertion_message (G_LOG_DOMAIN, \
__FILE__, \
__LINE__, \
G_STRFUNC, \
"Not a GObject instance"); \
} \
if (g_object_class_find_property (G_OBJECT_GET_CLASS (object), \
property_name) == NULL) \
{ \
g_assertion_message (G_LOG_DOMAIN, \
__FILE__, \
__LINE__, \
G_STRFUNC, \
"Property " property_name " does not " \
"exist on object"); \
} \
if (_g_assert_property_notify_run (object, property_name)) \
{ \
g_assertion_message (G_LOG_DOMAIN, \
__FILE__, \
__LINE__, \
G_STRFUNC, \
"Timed out waiting for notification " \
"on property " property_name); \
} \
} \
while (FALSE)
#define _g_assert_signal_received(object, signal_name) \
do \
{ \
if (!G_IS_OBJECT (object)) \
{ \
g_assertion_message (G_LOG_DOMAIN, \
__FILE__, \
__LINE__, \
G_STRFUNC, \
"Not a GObject instance"); \
} \
if (g_signal_lookup (signal_name, \
G_TYPE_FROM_INSTANCE (object)) == 0) \
{ \
g_assertion_message (G_LOG_DOMAIN, \
__FILE__, \
__LINE__, \
G_STRFUNC, \
"Signal '" signal_name "' does not " \
"exist on object"); \
} \
if (_g_assert_signal_received_run (object, signal_name)) \
{ \
g_assertion_message (G_LOG_DOMAIN, \
__FILE__, \
__LINE__, \
G_STRFUNC, \
"Timed out waiting for signal '" \
signal_name "'"); \
} \
} \
while (FALSE)
gboolean _g_assert_property_notify_run (gpointer object,
const gchar *property_name);
gboolean _g_assert_signal_received_run (gpointer object,
const gchar *signal_name);
GDBusConnection *_g_bus_get_priv (GBusType bus_type,
GCancellable *cancellable,
GError **error);
G_END_DECLS
#endif /* __TESTS_H__ */
|