summaryrefslogtreecommitdiff
path: root/src/tests/testutil.h
blob: 310415d5942866a16a03d59eac351889bf4ad4d1 (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
/* this really should be in GLib */
#include <gio/gio.h>

#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, callback, user_data) \
  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, callback, user_data)) \
        {                                                               \
          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,
                                        GCallback    callback,
                                        gpointer     user_data);