# -*- perl -*- use Test::More tests => 6; use strict; use warnings; BEGIN { use_ok('Net::DBus::Binding::Introspector'); }; TEST_ONE: { my $other_object = Net::DBus::Binding::Introspector->new( object_path => "org.example.Object.OtherObject", interfaces => { "org.example.SomeInterface" => { methods => { "hello" => { params => ["int32", "int32", ["struct", "int32","byte"]], returns => ["int32"], paramnames => ["wibble", "eek"], returnnames => ["frob"], }, "goodbye" => { params => [["array", ["struct", "int32", "string"]]], returns => ["string", "string"], paramnames => ["ooh"], returnnames => ["ahh", "eek"], }, }, signals => { "meltdown" => { params => ["int32", "byte"], } }, props => { "name" => { type => "string", access => "readwrite"}, "email" => { type => "string", access => "read"}, "age" => { type => "int32", access => "read"}, "parents" => { type => ["array", "string"], access => "readwrite" }, }, } }); isa_ok($other_object, "Net::DBus::Binding::Introspector"); my $other_xml_got = $other_object->format(); my $other_xml_expect = < EOF is($other_xml_got, $other_xml_expect, "xml data matches"); my $object = Net::DBus::Binding::Introspector->new( object_path => "org.example.Object", interfaces => { "org.example.SomeInterface" => { methods => { "hello" => { params => ["int32", "int32", ["struct", "int32","byte"]], returns => ["uint32"], paramnames => [], returnnames => [], }, "goodbye" => { params => [["array", ["dict", "int32", "string"]]], returns => ["string", ["array", "string"]], paramnames => [], returnnames => [], }, }, signals => { "meltdown" => { params => ["int32", "byte"], paramnames => [], } }, }, "org.example.OtherInterface" => { methods => { "hitme" => { params => ["int32", "uint32"], return => [], paramnames => [], returnnames => [], } }, props => { "title" => { type => "string", access => "readwrite"}, "salary" => { type => "int32", access => "read"}, }, }, }, children => [ "org.example.Object.SubObject", $other_object, ]); isa_ok($object, "Net::DBus::Binding::Introspector"); my $object_xml_got = $object->format(); my $object_xml_expect = < EOF is($object_xml_got, $object_xml_expect, "xml data matches"); my $recon_other = Net::DBus::Binding::Introspector->new(xml => $object_xml_got); my $object_xml_got_again = $recon_other->format(); is($object_xml_got_again, $object_xml_expect, "reconstructed xml matches"); }