summaryrefslogtreecommitdiffstats
path: root/extra/dbus-glib/regression-test-for-fd.o.patch
blob: a65e8a4443469b408c4b087d53909e99f2e35505 (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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
From 2a85bd434e6d8dba9615a53d288a0a72d6b5e0cf Mon Sep 17 00:00:00 2001
From: Simon McVittie <simon.mcvittie@collabora.co.uk>
Date: Thu, 02 Jun 2011 12:50:20 +0000
Subject: Regression test for fd.o #37852

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37852
Reviewed-by: Colin Walters <walters@verbum.org>
---
diff --git a/test/core/my-object.c b/test/core/my-object.c
index ec0e301..0ff5562 100644
--- a/test/core/my-object.c
+++ b/test/core/my-object.c
@@ -23,6 +23,7 @@ enum
 enum
 {
   FROBNICATE,
+  OBJECTIFIED,
   SIG0,
   SIG1,
   SIG2,
@@ -171,6 +172,15 @@ my_object_class_init (MyObjectClass *mobject_class)
                   g_cclosure_marshal_VOID__INT,
                   G_TYPE_NONE, 1, G_TYPE_INT);
 
+  signals[OBJECTIFIED] =
+    g_signal_new ("objectified",
+                  G_OBJECT_CLASS_TYPE (mobject_class),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+                  0,
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__OBJECT,
+                  G_TYPE_NONE, 1, G_TYPE_OBJECT);
+
   signals[SIG0] =
     g_signal_new ("sig0",
 		  G_OBJECT_CLASS_TYPE (mobject_class),
@@ -866,3 +876,10 @@ my_object_terminate (MyObject *obj, GError **error)
   g_main_loop_quit (loop);
   return TRUE;
 }
+
+void
+my_object_emit_objectified (MyObject *obj,
+    GObject *other)
+{
+  g_signal_emit (obj, signals[OBJECTIFIED], 0, other);
+}
diff --git a/test/core/my-object.h b/test/core/my-object.h
index 657140d..3657aa0 100644
--- a/test/core/my-object.h
+++ b/test/core/my-object.h
@@ -116,4 +116,6 @@ void my_object_async_throw_error (MyObject *obj, DBusGMethodInvocation *context)
 
 void my_object_unsafe_disable_legacy_property_access (MyObject *obj);
 
+void my_object_emit_objectified (MyObject *obj, GObject *other);
+
 #endif
diff --git a/test/core/registrations.c b/test/core/registrations.c
index a316313..d46b15a 100644
--- a/test/core/registrations.c
+++ b/test/core/registrations.c
@@ -50,6 +50,7 @@ typedef struct {
     GObject *object;
     DBusMessage *frobnicate1_message;
     DBusMessage *frobnicate2_message;
+    gboolean received_objectified;
 } Fixture;
 
 static void
@@ -324,6 +325,71 @@ test_clean_slate (Fixture *f,
   f->frobnicate2_message = NULL;
 }
 
+static DBusHandlerResult
+objectified_cb (DBusConnection *conn,
+    DBusMessage *message,
+    void *user_data)
+{
+  Fixture *f = user_data;
+
+  if (dbus_message_is_signal (message,
+        "org.freedesktop.DBus.GLib.Tests.MyObject", "Objectified"))
+    {
+      const char *sender = dbus_message_get_sender (message);
+      const char *path = dbus_message_get_path (message);
+      dbus_bool_t ok;
+      DBusError e;
+
+      dbus_error_init (&e);
+
+      g_assert (sender != NULL);
+      g_assert (path != NULL);
+
+      g_assert_cmpstr (path, ==, "/foo");
+      g_assert_cmpstr (sender, ==, dbus_bus_get_unique_name (
+            dbus_g_connection_get_connection (f->bus)));
+
+      path = NULL;
+      ok = dbus_message_get_args (message, &e,
+          DBUS_TYPE_OBJECT_PATH, &path,
+          DBUS_TYPE_INVALID);
+
+      if (dbus_error_is_set (&e))
+        g_error ("%s: %s", e.name, e.message);
+
+      g_assert (ok);
+      g_assert_cmpstr (path, ==, "/foo");
+
+      f->received_objectified = TRUE;
+    }
+
+  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static void
+test_marshal_object (Fixture *f,
+    gconstpointer test_data G_GNUC_UNUSED)
+{
+  dbus_bool_t mem;
+
+  g_test_bug ("37852");
+
+  dbus_g_connection_register_g_object (f->bus, "/foo", f->object);
+  g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") ==
+      f->object);
+
+  dbus_bus_add_match (dbus_g_connection_get_connection (f->bus),
+      "type='signal'", NULL);
+  mem = dbus_connection_add_filter (dbus_g_connection_get_connection (f->bus),
+      objectified_cb, f, NULL);
+  g_assert (mem);
+
+  my_object_emit_objectified ((MyObject *) f->object, f->object);
+
+  while (!f->received_objectified)
+    g_main_context_iteration (NULL, TRUE);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -349,6 +415,8 @@ main (int argc, char **argv)
       setup, test_twice, teardown);
   g_test_add ("/registrations/clean-slate", Fixture, NULL,
       setup, test_clean_slate, teardown);
+  g_test_add ("/registrations/marshal-object", Fixture, NULL,
+      setup, test_marshal_object, teardown);
 
   return g_test_run ();
 }
diff --git a/test/core/test-service-glib.xml b/test/core/test-service-glib.xml
index 94a836a..1b595cc 100644
--- a/test/core/test-service-glib.xml
+++ b/test/core/test-service-glib.xml
@@ -184,6 +184,10 @@
     <!-- Export signals -->
     <signal name="Frobnicate"/>
 
+    <signal name="Objectified">
+      <arg type="o"/>
+    </signal>
+
     <method name="Terminate">
     </method>
   </interface>
--
cgit v0.8.3-6-g21f6