summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-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
-rwxr-xr-xtest/python/test-client.py61
4 files changed, 127 insertions, 11 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>
diff --git a/test/python/test-client.py b/test/python/test-client.py
index 13cee958..08c547fd 100755
--- a/test/python/test-client.py
+++ b/test/python/test-client.py
@@ -20,13 +20,7 @@ if not dbus.__file__.startswith(pydir):
if not dbus_bindings.__file__.startswith(pydir):
raise Exception("DBus modules are not being picked up from the package")
-class TestDBusBindings(unittest.TestCase):
- def setUp(self):
- self.bus = dbus.SessionBus()
- self.remote_object = self.bus.get_object("org.freedesktop.DBus.TestSuitePythonService", "/org/freedesktop/DBus/TestSuitePythonObject")
- self.iface = dbus.Interface(self.remote_object, "org.freedesktop.DBus.TestSuiteInterface")
-
- self.test_types_vals = [1, 12323231, 3.14159265, 99999999.99,
+test_types_vals = [1, 12323231, 3.14159265, 99999999.99,
"dude", "123", "What is all the fuss about?", "gob@gob.com",
[1,2,3], ["how", "are", "you"], [1.23,2.3], [1], ["Hello"],
(1,2,3), (1,), (1,"2",3), ("2", "what"), ("you", 1.2),
@@ -35,6 +29,13 @@ class TestDBusBindings(unittest.TestCase):
([1,2,3],"c", 1.2, ["a","b","c"], {"a": (1,"v"), "b": (2,"d")})
]
+
+class TestDBusBindings(unittest.TestCase):
+ def setUp(self):
+ self.bus = dbus.SessionBus()
+ self.remote_object = self.bus.get_object("org.freedesktop.DBus.TestSuitePythonService", "/org/freedesktop/DBus/TestSuitePythonObject")
+ self.iface = dbus.Interface(self.remote_object, "org.freedesktop.DBus.TestSuiteInterface")
+
def testInterfaceKeyword(self):
#test dbus_interface parameter
print self.remote_object.Echo("dbus_interface on Proxy test Passed", dbus_interface = "org.freedesktop.DBus.TestSuiteInterface")
@@ -52,7 +53,7 @@ class TestDBusBindings(unittest.TestCase):
#test sending python types and getting them back
print "\n********* Testing Python Types ***********"
- for send_val in self.test_types_vals:
+ for send_val in test_types_vals:
print "Testing %s"% str(send_val)
recv_val = self.iface.Echo(send_val)
self.assertEquals(send_val, recv_val)
@@ -82,8 +83,8 @@ class TestDBusBindings(unittest.TestCase):
self.test_controler.assert_(val, False)
- last_type = self.test_types_vals[-1]
- for send_val in self.test_types_vals:
+ last_type = test_types_vals[-1]
+ for send_val in test_types_vals:
print "Testing %s"% str(send_val)
check = async_check(self, send_val, last_type == send_val)
recv_val = self.iface.Echo(send_val,
@@ -91,7 +92,45 @@ class TestDBusBindings(unittest.TestCase):
error_handler = check.error_handler)
main_loop.run()
-
+
+class TestDBusPythonToGLibBindings(unittest.TestCase):
+ def setUp(self):
+ self.bus = dbus.SessionBus()
+ self.remote_object = self.bus.get_object("org.freedesktop.DBus.TestSuiteGLibService", "/org/freedesktop/DBus/Tests/MyTestObject")
+ self.iface = dbus.Interface(self.remote_object, "org.freedesktop.DBus.Tests.MyObject")
+
+ def testIntrospection(self):
+ #test introspection
+ print "\n********* Introspection Test ************"
+ print self.remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable")
+ print "Introspection test passed"
+ self.assert_(True)
+
+ def testCalls(self):
+ print "\n********* Call Test ************"
+ result = self.iface.ManyArgs(1000, 'Hello GLib', 2)
+ print result
+ self.assert_(result == [2002.0, 'HELLO GLIB'])
+
+ arg0 = {"Dude": 1, "john": "palmieri", "python": 2.4}
+ result = self.iface.ManyStringify(arg0)
+ print result
+
+ print "Call test passed"
+ self.assert_(True)
+
+ #this crashes glib so disable it for now
+ #until glib is fixed
+ """
+ def testPythonTypes(self):
+ print "\n********* Testing Python Types ***********"
+
+ for send_val in test_types_vals:
+ print "Testing %s"% str(send_val)
+ recv_val = self.iface.EchoVariant(send_val)
+ self.assertEquals(send_val, recv_val)
+ """
+
if __name__ == '__main__':
gobject.threads_init()
dbus.glib.init_threads()