summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/Makefile.am3
-rwxr-xr-xtests/complex_struct_test.sh18
-rwxr-xr-xtests/dbus-test-service.py22
3 files changed, 42 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6574478..cc36461 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -20,7 +20,8 @@ basic_TESTS = \
complex_TESTS = \
complex_array_test.sh \
complex_variant_test.sh \
- complex_dict_test.sh
+ complex_dict_test.sh \
+ complex_struct_test.sh
TESTS = \
test_init.sh \
diff --git a/tests/complex_struct_test.sh b/tests/complex_struct_test.sh
new file mode 100755
index 0000000..5d939b2
--- /dev/null
+++ b/tests/complex_struct_test.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+#
+# json dbus bridge
+#
+# Copyright (c) 2010 by Rolf Offermanns <roffermanns@sysgo.com>
+#
+# To the extent possible under law, SYSGO AG has waived all copyright
+# and related or neighboring rights to JSON-DBus-Bridge Demo Code.
+#
+
+. `dirname $0`/test_setup.sh "com.pengutronix.jdb.Test.Complex" || exit
+
+jdb_test_echo EchoStruct "(aiuaiu)" "[ [ 1, 2, 3, 42, 99, -42 ], 4711, [ -42, 99, 42, 3, 2, 1 ], 1701 ]" &&
+jdb_test_echo EchoStructArray "a(aiu)" "[ [ [ 1, 2, 3, 42, 99, -42 ], 4711 ], [ [ -42, 99, 42, 3, 2, 1 ], 1701 ] ]" &&
+jdb_test_echo CountStructIntegerValues "a(aiu)" "[ [ [ 1, 2, 3, 42, 99, -42 ], 4711 ], [ [ -42, 99, 42, 3, 2, 1 ], 1701 ] ]" 6622 &&
+jdb_test_echo EchoStruct "(aiuaiu)" "[ [ 1, 2, null, 42, 99, -42 ], 4711, [ -42, 99, 42, 3, 2, 1 ], 1701 ]" null "unexpected 'null' element in json array." &&
+jdb_test_echo EchoStruct "(aiuaiu)" "[ [ 1, 2, 3, 42, 99, -42 ], 4711, [ -42, 99, 42, 3, 2, 1 ] ]" null "Aditional parameter expexted." &&
+jdb_test_echo EchoStruct "(aiuaiu)" "[ [ 1, 2, 3, 42, 99, -42 ], 4711, [ -42, 99, 42, 3, 2, 1 ], 1701, 12 ]" null "Unexpected extra parameter found."
diff --git a/tests/dbus-test-service.py b/tests/dbus-test-service.py
index 5dcadb0..2944e08 100755
--- a/tests/dbus-test-service.py
+++ b/tests/dbus-test-service.py
@@ -115,6 +115,28 @@ class Service(dbus.service.Object):
keys = val.keys()
keys.sort()
return keys
+
+ @dbus.service.method("com.pengutronix.jdb.Test.Complex",
+ in_signature='(aiuaiu)', out_signature='(aiuaiu)')
+ def EchoStruct(self, val):
+ return val;
+
+ @dbus.service.method("com.pengutronix.jdb.Test.Complex",
+ in_signature='a(aiu)', out_signature='a(aiu)')
+ def EchoStructArray(self, val):
+ return val;
+
+ @dbus.service.method("com.pengutronix.jdb.Test.Complex",
+ in_signature='a(aiu)', out_signature='i')
+ def CountStructIntegerValues(self, val):
+ sum = 0
+ for struct in val:
+ ai = struct[0]
+ u = struct[1]
+ for i in ai:
+ sum += i
+ sum += u
+ return sum;
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)