|
Packit |
ae235b |
/* GLib testing framework examples and tests
|
|
Packit |
ae235b |
*
|
|
Packit |
ae235b |
* Copyright (C) 2008-2009 Red Hat, Inc.
|
|
Packit |
ae235b |
*
|
|
Packit |
ae235b |
* This library is free software; you can redistribute it and/or
|
|
Packit |
ae235b |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
ae235b |
* License as published by the Free Software Foundation; either
|
|
Packit |
ae235b |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
ae235b |
*
|
|
Packit |
ae235b |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
ae235b |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
ae235b |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
ae235b |
* Lesser General Public License for more details.
|
|
Packit |
ae235b |
*
|
|
Packit |
ae235b |
* You should have received a copy of the GNU Lesser General
|
|
Packit |
ae235b |
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
ae235b |
*
|
|
Packit |
ae235b |
* Author: David Zeuthen <davidz@redhat.com>
|
|
Packit |
ae235b |
*/
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
#ifndef __TESTS_H__
|
|
Packit |
ae235b |
#define __TESTS_H__
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
#include <gio/gio.h>
|
|
Packit |
ae235b |
#include "gdbus-sessionbus.h"
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
G_BEGIN_DECLS
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
/* TODO: clean up and move to gtestutils.c
|
|
Packit |
ae235b |
*
|
|
Packit |
ae235b |
* This is needed because libdbus-1 does not give predictable error messages - e.g. you
|
|
Packit |
ae235b |
* get a different error message on connecting to a bus if the socket file is there vs
|
|
Packit |
ae235b |
* if the socket file is missing.
|
|
Packit |
ae235b |
*/
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
#define _g_assert_error_domain(err, dom) do { if (!err || (err)->domain != dom) \
|
|
Packit |
ae235b |
g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
|
Packit |
ae235b |
#err, err, dom, -1); } while (0)
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
#define _g_assert_property_notify(object, property_name) \
|
|
Packit |
ae235b |
do \
|
|
Packit |
ae235b |
{ \
|
|
Packit |
ae235b |
if (!G_IS_OBJECT (object)) \
|
|
Packit |
ae235b |
{ \
|
|
Packit |
ae235b |
g_assertion_message (G_LOG_DOMAIN, \
|
|
Packit |
ae235b |
__FILE__, \
|
|
Packit |
ae235b |
__LINE__, \
|
|
Packit |
ae235b |
G_STRFUNC, \
|
|
Packit |
ae235b |
"Not a GObject instance"); \
|
|
Packit |
ae235b |
} \
|
|
Packit |
ae235b |
if (g_object_class_find_property (G_OBJECT_GET_CLASS (object), \
|
|
Packit |
ae235b |
property_name) == NULL) \
|
|
Packit |
ae235b |
{ \
|
|
Packit |
ae235b |
g_assertion_message (G_LOG_DOMAIN, \
|
|
Packit |
ae235b |
__FILE__, \
|
|
Packit |
ae235b |
__LINE__, \
|
|
Packit |
ae235b |
G_STRFUNC, \
|
|
Packit |
ae235b |
"Property " property_name " does not " \
|
|
Packit |
ae235b |
"exist on object"); \
|
|
Packit |
ae235b |
} \
|
|
Packit |
ae235b |
if (_g_assert_property_notify_run (object, property_name)) \
|
|
Packit |
ae235b |
{ \
|
|
Packit |
ae235b |
g_assertion_message (G_LOG_DOMAIN, \
|
|
Packit |
ae235b |
__FILE__, \
|
|
Packit |
ae235b |
__LINE__, \
|
|
Packit |
ae235b |
G_STRFUNC, \
|
|
Packit |
ae235b |
"Timed out waiting for notification " \
|
|
Packit |
ae235b |
"on property " property_name); \
|
|
Packit |
ae235b |
} \
|
|
Packit |
ae235b |
} \
|
|
Packit |
ae235b |
while (FALSE)
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
#define _g_assert_signal_received(object, signal_name) \
|
|
Packit |
ae235b |
do \
|
|
Packit |
ae235b |
{ \
|
|
Packit |
ae235b |
if (!G_IS_OBJECT (object)) \
|
|
Packit |
ae235b |
{ \
|
|
Packit |
ae235b |
g_assertion_message (G_LOG_DOMAIN, \
|
|
Packit |
ae235b |
__FILE__, \
|
|
Packit |
ae235b |
__LINE__, \
|
|
Packit |
ae235b |
G_STRFUNC, \
|
|
Packit |
ae235b |
"Not a GObject instance"); \
|
|
Packit |
ae235b |
} \
|
|
Packit |
ae235b |
if (g_signal_lookup (signal_name, \
|
|
Packit |
ae235b |
G_TYPE_FROM_INSTANCE (object)) == 0) \
|
|
Packit |
ae235b |
{ \
|
|
Packit |
ae235b |
g_assertion_message (G_LOG_DOMAIN, \
|
|
Packit |
ae235b |
__FILE__, \
|
|
Packit |
ae235b |
__LINE__, \
|
|
Packit |
ae235b |
G_STRFUNC, \
|
|
Packit |
ae235b |
"Signal '" signal_name "' does not " \
|
|
Packit |
ae235b |
"exist on object"); \
|
|
Packit |
ae235b |
} \
|
|
Packit |
ae235b |
if (_g_assert_signal_received_run (object, signal_name)) \
|
|
Packit |
ae235b |
{ \
|
|
Packit |
ae235b |
g_assertion_message (G_LOG_DOMAIN, \
|
|
Packit |
ae235b |
__FILE__, \
|
|
Packit |
ae235b |
__LINE__, \
|
|
Packit |
ae235b |
G_STRFUNC, \
|
|
Packit |
ae235b |
"Timed out waiting for signal '" \
|
|
Packit |
ae235b |
signal_name "'"); \
|
|
Packit |
ae235b |
} \
|
|
Packit |
ae235b |
} \
|
|
Packit |
ae235b |
while (FALSE)
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
gboolean _g_assert_property_notify_run (gpointer object,
|
|
Packit |
ae235b |
const gchar *property_name);
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
gboolean _g_assert_signal_received_run (gpointer object,
|
|
Packit |
ae235b |
const gchar *signal_name);
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
GDBusConnection *_g_bus_get_priv (GBusType bus_type,
|
|
Packit |
ae235b |
GCancellable *cancellable,
|
|
Packit |
ae235b |
GError **error);
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
void ensure_gdbus_testserver_up (void);
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
G_END_DECLS
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
#endif /* __TESTS_H__ */
|