summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2005-07-24 18:04:23 +0000
committerColin Walters <walters@verbum.org>2005-07-24 18:04:23 +0000
commit9ca6f45e86f1e1839967821261c55083becfa40a (patch)
tree1da04ba7b87261169dd2b84d453c6c56fce48bb6 /test
parentde689235e938f0060ecad6fa0ce1933b700f6e71 (diff)
downloaddbus-9ca6f45e86f1e1839967821261c55083becfa40a.tar.gz
2005-07-24 Colin Walters <walters@verbum.org>
* glib/dbus-gvalue.c (signature_iter_to_g_type_array): Don't require typedata; recursive arrays won't have it. * test/glib/test-dbus-glib.c: * test/glib/test-service-glib.c: * test/glib/test-service-glib.xml: Add recursive arrays tests.
Diffstat (limited to 'test')
-rw-r--r--test/glib/test-dbus-glib.c51
-rw-r--r--test/glib/test-service-glib.c101
-rw-r--r--test/glib/test-service-glib.xml5
3 files changed, 157 insertions, 0 deletions
diff --git a/test/glib/test-dbus-glib.c b/test/glib/test-dbus-glib.c
index 962db15e..368a5762 100644
--- a/test/glib/test-dbus-glib.c
+++ b/test/glib/test-dbus-glib.c
@@ -974,6 +974,57 @@ main (int argc, char **argv)
}
{
+ GPtrArray *in_array;
+ GPtrArray *out_array;
+ char **strs;
+ GArray *uints;
+
+ in_array = g_ptr_array_new ();
+
+ strs = g_new0 (char *, 3);
+ strs[0] = "foo";
+ strs[1] = "bar";
+ strs[2] = NULL;
+ g_ptr_array_add (in_array, strs);
+
+ strs = g_new0 (char *, 4);
+ strs[0] = "baz";
+ strs[1] = "whee";
+ strs[2] = "moo";
+ strs[3] = NULL;
+ g_ptr_array_add (in_array, strs);
+
+ out_array = NULL;
+ g_print ("Calling RecArrays\n");
+ if (!dbus_g_proxy_call (proxy, "RecArrays", &error,
+ dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRV), in_array,
+ G_TYPE_INVALID,
+ dbus_g_type_get_collection ("GPtrArray",
+ dbus_g_type_get_collection ("GPtrArray",
+ G_TYPE_UINT)), &out_array,
+ G_TYPE_INVALID))
+ lose_gerror ("Failed to complete RecArrays call", error);
+ g_free (g_ptr_array_index (in_array, 0));
+ g_free (g_ptr_array_index (in_array, 1));
+
+ g_assert (out_array);
+ g_assert (out_array->len == 2);
+ uints = g_ptr_array_index (out_array, 0);
+ g_assert (uints);
+ g_assert (uints->len == 3);
+ g_assert (g_array_index (uints, guint, 0) == 10);
+ g_assert (g_array_index (uints, guint, 1) == 42);
+ g_assert (g_array_index (uints, guint, 2) == 27);
+ g_array_free (uints, TRUE);
+ uints = g_ptr_array_index (out_array, 1);
+ g_assert (uints);
+ g_assert (uints->len == 1);
+ g_assert (g_array_index (uints, guint, 0) == 30);
+ g_array_free (uints, TRUE);
+ g_ptr_array_free (out_array, TRUE);
+ }
+
+ {
guint val;
char *ret_path;
DBusGProxy *ret_proxy;
diff --git a/test/glib/test-service-glib.c b/test/glib/test-service-glib.c
index b0043e80..1c62a498 100644
--- a/test/glib/test-service-glib.c
+++ b/test/glib/test-service-glib.c
@@ -69,6 +69,8 @@ gboolean my_object_recursive2 (MyObject *obj, guint32 reqlen, GArray **array, GE
gboolean my_object_many_stringify (MyObject *obj, GHashTable *vals, GHashTable **ret, GError **error);
+gboolean my_object_rec_arrays (MyObject *obj, GPtrArray *in, GPtrArray **ret, GError **error);
+
gboolean my_object_objpath (MyObject *obj, const char *in, const char **arg1, GError **error);
gboolean my_object_get_objs (MyObject *obj, GPtrArray **objs, GError **error);
@@ -459,6 +461,105 @@ my_object_many_stringify (MyObject *obj, GHashTable /* char * -> GValue * */ *va
}
gboolean
+my_object_rec_arrays (MyObject *obj, GPtrArray *in, GPtrArray **ret, GError **error)
+{
+ guint i;
+ char **strs;
+ GArray *ints;
+ guint v_UINT;
+
+ if (in->len != 2)
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid array len");
+ return FALSE;
+ }
+
+ strs = g_ptr_array_index (in, 0);
+ if (!*strs || strcmp (*strs, "foo"))
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string 0");
+ return FALSE;
+ }
+ strs++;
+ if (!*strs || strcmp (*strs, "bar"))
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string 1");
+ return FALSE;
+ }
+ strs++;
+ if (*strs)
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string array len in pos 0");
+ return FALSE;
+ }
+ strs = g_ptr_array_index (in, 1);
+ if (!*strs || strcmp (*strs, "baz"))
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string 0");
+ return FALSE;
+ }
+ strs++;
+ if (!*strs || strcmp (*strs, "whee"))
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string 1");
+ return FALSE;
+ }
+ strs++;
+ if (!*strs || strcmp (*strs, "moo"))
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string 2");
+ return FALSE;
+ }
+ strs++;
+ if (*strs)
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string array len in pos 1");
+ return FALSE;
+ }
+
+ *ret = g_ptr_array_new ();
+
+ ints = g_array_new (TRUE, TRUE, sizeof (guint));
+ v_UINT = 10;
+ g_array_append_val (ints, v_UINT);
+ v_UINT = 42;
+ g_array_append_val (ints, v_UINT);
+ v_UINT = 27;
+ g_array_append_val (ints, v_UINT);
+ g_ptr_array_add (*ret, ints);
+
+ ints = g_array_new (TRUE, TRUE, sizeof (guint));
+ v_UINT = 30;
+ g_array_append_val (ints, v_UINT);
+ g_ptr_array_add (*ret, ints);
+ return TRUE;
+}
+
+gboolean
my_object_objpath (MyObject *obj, const char *incoming, const char **outgoing, GError **error)
{
if (strcmp (incoming, "/org/freedesktop/DBus/Tests/MyTestObject"))
diff --git a/test/glib/test-service-glib.xml b/test/glib/test-service-glib.xml
index f63beada..1fd6155c 100644
--- a/test/glib/test-service-glib.xml
+++ b/test/glib/test-service-glib.xml
@@ -90,6 +90,11 @@
<arg type="a{ss}" direction="out"/>
</method>
+ <method name="RecArrays">
+ <arg type="aas" name="val" direction="in"/>
+ <arg type="aau" direction="out"/>
+ </method>
+
<method name="Objpath">
<arg type="o" direction="in"/>
<arg type="o" direction="out">