summaryrefslogtreecommitdiff
path: root/tests/lib/util.h
blob: 725a59e6d9332dba58c737b57c0946ff758bf043 (plain)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* Simple utility code used by the regression tests.
 *
 * Copyright © 2008-2010 Collabora Ltd. <http://www.collabora.co.uk/>
 * Copyright © 2008 Nokia Corporation
 *
 * Copying and distribution of this file, with or without modification,
 * are permitted in any medium without royalty provided the copyright
 * notice and this notice are preserved.
 */

#ifndef __TP_TESTS_LIB_UTIL_H__
#define __TP_TESTS_LIB_UTIL_H__

#include <telepathy-glib/telepathy-glib.h>

gint tp_tests_run_with_bus (void);

GDBusConnection *tp_tests_dbus_dup_or_die (void);

void tp_tests_proxy_run_until_dbus_queue_processed (gpointer proxy);

void tp_tests_proxy_run_until_prepared (gpointer proxy,
    const GQuark *features);
gboolean tp_tests_proxy_run_until_prepared_or_failed (gpointer proxy,
    const GQuark *features,
    GError **error);

#define test_assert_empty_strv(strv) \
  _test_assert_empty_strv (__FILE__, __LINE__, strv)
void _test_assert_empty_strv (const char *file, int line, gconstpointer strv);

#define tp_tests_assert_strv_equals(actual, expected) \
  _tp_tests_assert_strv_equals (__FILE__, __LINE__, \
      #actual, actual, \
      #expected, expected)
void _tp_tests_assert_strv_equals (const char *file, int line,
  const char *actual_desc, gconstpointer actual_strv,
  const char *expected_desc, gconstpointer expected_strv);

#define tp_tests_assert_bytes_equals(actual, expected, expected_length) \
  _tp_tests_assert_bytes_equal (__FILE__, __LINE__, \
      actual, expected, expected_length)
void _tp_tests_assert_bytes_equal (const gchar *file, int line,
  GBytes *actual, gconstpointer expected_data, gsize expected_length);

void tp_tests_create_conn (GType conn_type,
    const gchar *account,
    gboolean connect,
    TpBaseConnection **service_conn,
    TpConnection **client_conn);

void tp_tests_create_and_connect_conn (GType conn_type,
    const gchar *account,
    TpBaseConnection **service_conn,
    TpConnection **client_conn);

gpointer tp_tests_object_new_static_class (GType type,
    ...) G_GNUC_NULL_TERMINATED;

void tp_tests_run_until_result (GAsyncResult **result);
void tp_tests_result_ready_cb (GObject *object,
    GAsyncResult *res, gpointer user_data);

void tp_tests_abort_after (guint sec);

void tp_tests_init (int *argc,
    char ***argv);

GValue *_tp_create_local_socket (TpSocketAddressType address_type,
    TpSocketAccessControl access_control,
    GSocketService **service,
    gchar **unix_address,
    gchar **unix_tmpdir,
    GError **error);

void _tp_destroy_socket_control_list (gpointer data);

void tp_tests_connection_assert_disconnect_succeeds (TpConnection *connection);

TpContact *tp_tests_connection_run_until_contact_by_id (
    TpConnection *connection,
    const gchar *id,
    const GQuark *features);

void tp_tests_channel_assert_expect_members (TpChannel *channel,
    TpIntset *expected_members);

TpConnection *tp_tests_connection_new (GDBusConnection *dbus,
    const gchar *bus_name,
    const gchar *object_path,
    GError **error);

TpAccount *tp_tests_account_new (GDBusConnection *dbus,
    const gchar *object_path,
    GError **error);

TpChannel *tp_tests_channel_new (TpConnection *conn,
    const gchar *object_path,
    const gchar *optional_channel_type,
    TpEntityType optional_entity_type,
    TpHandle optional_handle,
    GError **error);

TpChannel *tp_tests_channel_new_from_properties (TpConnection *conn,
    const gchar *object_path,
    const GHashTable *immutable_properties,
    GError **error);

GHashTable * tp_tests_dup_channel_props_asv (TpChannel *channel);

#define tp_tests_await_last_unref(op) \
  G_STMT_START \
    { \
      gpointer _tmp; \
      \
      _tmp = *(op); \
      *(op) = NULL; \
      \
      _tp_tests_await_last_unref (_tmp, __FILE__, __LINE__); \
    } \
  G_STMT_END
void _tp_tests_await_last_unref (gpointer obj,
    const gchar *file,
    int line);

#define tp_tests_assert_last_unref(op) \
  G_STMT_START \
    { \
      gpointer _tmp; \
      \
      _tmp = *(op); \
      *(op) = NULL; \
      \
      _tp_tests_assert_last_unref (_tmp, __FILE__, __LINE__); \
    } \
  G_STMT_END
void _tp_tests_assert_last_unref (gpointer obj,
    const gchar *file,
    int line);

GDBusConnection *tp_tests_get_private_bus (void);

#endif /* #ifndef __TP_TESTS_LIB_UTIL_H__ */