summaryrefslogtreecommitdiffstats
path: root/test/glib
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <johnp@redhat.com>2005-10-05 20:43:46 +0000
committerJohn (J5) Palmieri <johnp@redhat.com>2005-10-05 20:43:46 +0000
commit86b9f6ad4a6f466e24b5e4c1c320029041c50e3b (patch)
tree83aeb914e341f5e5b29b9a2ba3382caac251d26b /test/glib
parent66e1cb9e68ba37980f7a90c396950be1587cdcd7 (diff)
* glib/dbus-gvalue.c (marshal_variant): call _dbus_gvalue_marshal
instead of marshal basic so we can handle recursive types in a variant * test/glib/test-dbus-glib.c: Add test for marshaling recurive types in variants * test/glib/test-service-glib.c, test-service-glib.xml (my_object_echo_variant [EchoVariant], my_object_process_variant_of_array_of_ints123 [ProcessVariantOfArrayOfInts123]): Add two test methods * python/introspect_parser.py: New module for parsing introspect data. * python/dbus_bindings.pyx: (various places): when throwing errors fix to use errormsg instead of message local variable because Pyrex can get confused with other message variables (initial patch by Robert McQueen <robert.mcqueen at collabora.co.uk>) (MessageIter::parse_signature_block): new method for getting the next block in a signiture. (MessageIter::append_strict): new method for appending values strictly using the passed in signature instead of guessing at the type (MessageItter:: append_dict, append_struct, append_array): use signatures to marshal children if the signature is available * python/exceptions.py (IntrospectionParserException): new exception * python/proxies.py (ProxyMethod::__call__): Marshal args with introspected signatures if available, else we fall back to the old way of doing things. (ProxyObject::_introspect_reply_handler ): parse introspection data * python/service.py (ObjectType::_reflect_on_method): Properly terminate <method> if there are no args in the reflection data * test/python/test-client.py: add tests for talking with the GLib test server. This gives us better coverage for introspection since python to python will always generate arguments as variants. It also allows us to test the robustness of the GLib bindings and interlanguage communications.
Diffstat (limited to 'test/glib')
-rw-r--r--test/glib/test-dbus-glib.c27
-rw-r--r--test/glib/test-service-glib.c41
-rw-r--r--test/glib/test-service-glib.xml9
3 files changed, 77 insertions, 0 deletions
diff --git a/test/glib/test-dbus-glib.c b/test/glib/test-dbus-glib.c
index 368a5762..86c9f7ec 100644
--- a/test/glib/test-dbus-glib.c
+++ b/test/glib/test-dbus-glib.c
@@ -1138,7 +1138,34 @@ main (int argc, char **argv)
g_free (g_ptr_array_index (objs, i));
g_ptr_array_free (objs, TRUE);
}
+
+ {
+ GValue *variant;
+ GArray *array;
+ gint i;
+
+ g_print ("Calling ProcessVariantOfArrayOfInts123\n");
+
+ array = g_array_sized_new (FALSE, FALSE, sizeof(gint), 3);
+ i = 1;
+ g_array_append_val (array, i);
+ i++;
+ g_array_append_val (array, i);
+ i++;
+ g_array_append_val (array, i);
+ variant = g_new0 (GValue, 1);
+ g_value_init (variant, dbus_g_type_get_collection ("GArray", G_TYPE_INT));
+ g_value_set_boxed_take_ownership (variant, array);
+
+ if (!dbus_g_proxy_call (proxy, "ProcessVariantOfArrayOfInts123", &error,
+ G_TYPE_VALUE, variant,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID))
+ lose_gerror ("Failed to send a vairant of array of ints 1, 2 and 3!", error);
+
+ g_value_unset (variant);
+ }
/* Signal handling tests */
g_print ("Testing signal handling\n");
diff --git a/test/glib/test-service-glib.c b/test/glib/test-service-glib.c
index 7230fd94..06cc5957 100644
--- a/test/glib/test-service-glib.c
+++ b/test/glib/test-service-glib.c
@@ -97,6 +97,10 @@ gboolean my_object_emit_signal2 (MyObject *obj, GError **error);
gboolean my_object_emit_frobnicate (MyObject *obj, GError **error);
+gboolean my_object_echo_variant (MyObject *obj, GValue *variant, GValue *ret, GError **error);
+
+gboolean my_object_process_variant_of_array_of_ints123 (MyObject *obj, GValue *variant, GError **error);
+
gboolean my_object_terminate (MyObject *obj, GError **error);
void my_object_async_increment (MyObject *obj, gint32 x, DBusGMethodInvocation *context);
@@ -664,6 +668,43 @@ my_object_get_value (MyObject *obj, guint *ret, GError **error)
}
gboolean
+my_object_echo_variant (MyObject *obj, GValue *variant, GValue *ret, GError **error)
+{
+ g_value_init (ret, G_VALUE_TYPE(variant));
+ g_value_copy (variant, ret);
+
+ return TRUE;
+}
+
+gboolean
+my_object_process_variant_of_array_of_ints123 (MyObject *obj, GValue *variant, GError **error)
+{
+ GArray *array;
+ int i;
+ int j;
+
+ j = 0;
+
+ array = (GArray *)g_value_get_boxed (variant);
+
+ for (i = 0; i <= 2; i++)
+ {
+ j = g_array_index (array, int, i);
+ if (j != i + 1)
+ goto error;
+ }
+
+ return TRUE;
+
+error:
+ *error = g_error_new (MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "Error decoding a variant of type ai (i + 1 = %i, j = %i)",
+ i, j + 1);
+ return FALSE;
+}
+
+gboolean
my_object_emit_frobnicate (MyObject *obj, GError **error)
{
g_signal_emit (obj, signals[FROBNICATE], 0, 42);
diff --git a/test/glib/test-service-glib.xml b/test/glib/test-service-glib.xml
index 1fd6155c..5b589d08 100644
--- a/test/glib/test-service-glib.xml
+++ b/test/glib/test-service-glib.xml
@@ -128,6 +128,15 @@
<arg type="a{sv}" direction="out"/>
</method>
+ <method name="EchoVariant">
+ <arg type="v" direction="in" />
+ <arg type="v" direction="out" />
+ </method>
+
+ <method name="ProcessVariantOfArrayOfInts123">
+ <arg type="v" direction="in" />
+ </method>
+
<method name="EmitFrobnicate">
</method>