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