From 8c61eab564bc10ad76e207914c806bd68542e1e0 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Mon, 31 May 2010 15:23:11 +0200 Subject: [tests] add complex tests Signed-off-by: Michael Olbrich --- tests/Makefile.am | 9 ++++++++- tests/complex_array_test.sh | 10 ++++++++++ tests/complex_dict_test.sh | 7 +++++++ tests/complex_variant_test.sh | 14 ++++++++++++++ tests/dbus-test-service.py | 25 +++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100755 tests/complex_array_test.sh create mode 100755 tests/complex_dict_test.sh create mode 100755 tests/complex_variant_test.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index c6561da..6574478 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,16 +17,23 @@ basic_TESTS = \ basic_string_test.sh \ basic_signature_test.sh +complex_TESTS = \ + complex_array_test.sh \ + complex_variant_test.sh \ + complex_dict_test.sh + TESTS = \ test_init.sh \ $(basic_TESTS) \ + $(complex_TESTS) \ test_finish.sh EXTRA_DIST = \ dbus-test-service.py \ libtest.sh \ test_setup.sh \ - $(basic_TESTS) + $(basic_TESTS) \ + $(complex_TESTS) CLEANFILES = \ dbus-test-service.pid \ diff --git a/tests/complex_array_test.sh b/tests/complex_array_test.sh new file mode 100755 index 0000000..240674f --- /dev/null +++ b/tests/complex_array_test.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +. `dirname $0`/test_setup.sh "com.pengutronix.jdb.Test.Complex" || return + +jdb_test_echo EchoArray ai "[ 1, 2, 3, 42, 99, -42 ]" && +jdb_test_echo EchoArray ai "[ 1, 2, 3, 42, 99, \"foo\" ]" null "integer value expected." && + +jdb_test_echo CountArray ai "[ 1, 2, 3, 42, 99, -42 ]" 6 && +jdb_test_echo CountArray ai "[]" 0 + diff --git a/tests/complex_dict_test.sh b/tests/complex_dict_test.sh new file mode 100755 index 0000000..f5af108 --- /dev/null +++ b/tests/complex_dict_test.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +. `dirname $0`/test_setup.sh "com.pengutronix.jdb.Test.Complex" || return + +jdb_test_echo EchoDict 'a{si}' '{ "a": 1, "b": 2, "ff": 3, "y": 42, "x": 99, "foo": -42 }' && +jdb_test_echo EchoDict 'a{si}' '{ "a": 1, "b": "2" }' null "integer value expected." + diff --git a/tests/complex_variant_test.sh b/tests/complex_variant_test.sh new file mode 100755 index 0000000..8e0c81b --- /dev/null +++ b/tests/complex_variant_test.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +. `dirname $0`/test_setup.sh "com.pengutronix.jdb.Test.Complex" || return + +jdb_test_echo EchoVariant v '[ "i", 42 ]' 42 && +jdb_test_echo EchoVariant v '[ "s", "foo" ]' '"foo"' && +jdb_test_echo EchoVariant v '[ "s", "42" ]' '"42"' && + +jdb_test_echo EchoVariant v '[ "s", "foo", 33 ]' null "Unexpected extra parameter found." && +jdb_test_echo EchoVariant v '[ "si", "foo", 33 ]' null "invalid variant signature." && + +jdb_test_echo EchoVariant v '[ "as", [ "42", "foobar"] ]' '[ "42", "foobar" ]' && +jdb_test_echo EchoVariantArray av '[ [ "i", 42 ], ["s", "foobar"] ]' '[ 42, "foobar" ]' + diff --git a/tests/dbus-test-service.py b/tests/dbus-test-service.py index 841ff38..650a1c4 100755 --- a/tests/dbus-test-service.py +++ b/tests/dbus-test-service.py @@ -84,6 +84,31 @@ class Service(dbus.service.Object): def SumINT32(self, val1, val2): return val1 + val2; + @dbus.service.method("com.pengutronix.jdb.Test.Complex", + in_signature='v', out_signature='v') + def EchoVariant(self, val): + return val; + + @dbus.service.method("com.pengutronix.jdb.Test.Complex", + in_signature='av', out_signature='av') + def EchoVariantArray(self, val): + return val; + + @dbus.service.method("com.pengutronix.jdb.Test.Complex", + in_signature='ai', out_signature='ai') + def EchoArray(self, val): + return val; + + @dbus.service.method("com.pengutronix.jdb.Test.Complex", + in_signature='ai', out_signature='i') + def CountArray(self, val): + return len(val); + + @dbus.service.method("com.pengutronix.jdb.Test.Complex", + in_signature='a{si}', out_signature='a{si}') + def EchoDict(self, val): + return val; + if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) -- cgit v1.2.3