From 384f7e11a78e77bc2bd141810c955f3e39179aba Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 25 Sep 2012 15:11:48 +0300 Subject: [PATCH] test: Add test-profile test script --- Makefile.tools | 4 ++-- test/test-profile | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100755 test/test-profile diff --git a/Makefile.tools b/Makefile.tools index d3b6f575f..15fe4e2e5 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -209,7 +209,7 @@ EXTRA_DIST += test/sap_client.py test/hsplay test/hsmicro \ test/test-network test/simple-agent test/simple-service \ test/simple-endpoint test/test-audio test/test-input \ test/test-sap-server test/test-oob test/test-attrib \ - test/test-proximity test/test-thermometer test/test-health \ - test/test-health-sink test/service-record.dtd \ + test/test-proximity test/test-thermometer test/test-profile \ + test/test-health test/test-health-sink test/service-record.dtd \ test/service-did.xml test/service-spp.xml test/service-opp.xml \ test/service-ftp.xml test/simple-player test/test-nap diff --git a/test/test-profile b/test/test-profile new file mode 100755 index 000000000..455ef09f4 --- /dev/null +++ b/test/test-profile @@ -0,0 +1,51 @@ +#!/usr/bin/python + +from __future__ import absolute_import, print_function, unicode_literals + +from gi.repository import GObject + +import sys +import dbus +import dbus.service +import dbus.mainloop.glib +from optparse import OptionParser, make_option + +class Profile(dbus.service.Object): + @dbus.service.method("org.bluez.Profile", + in_signature="", out_signature="") + def Release(self): + print("Release") + mainloop.quit() + +if __name__ == '__main__': + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + bus = dbus.SystemBus() + + manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager") + + option_list = [ + make_option("-u", "--uuid", action="store", + type="string", dest="uuid"), + make_option("-p", "--path", action="store", + type="string", dest="path"), + ] + parser = OptionParser(option_list=option_list) + + (options, args) = parser.parse_args() + + if not options.uuid: + options.uuid = "spp" + + if not options.path: + options.path = "/foo/bar/profile" + + profile = Profile(bus, options.path) + + mainloop = GObject.MainLoop() + + opts = { "Role" : "client" } + + manager.RegisterProfile(options.path, options.uuid, opts) + + mainloop.run() -- 2.47.3