test-session: Handle all net.connman.Error.Failed exceptions
[platform/upstream/connman.git] / test / test-session
index 21a2019..9784122 100755 (executable)
@@ -2,6 +2,7 @@
 
 import sys
 import gobject
+import string
 
 import dbus
 import dbus.service
@@ -146,7 +147,7 @@ class SessionApplication(dbus.service.Object):
                                                      "net.connman.Session")
 
                except dbus.DBusException, e:
-                       if e.get_dbus_name() in ['net.connman.Error.InvalidArguments']:
+                       if e.get_dbus_name() in ['net.connman.Error.Failed']:
                                print e.get_dbus_message()
                                return
                        traceback.print_exc()
@@ -174,8 +175,7 @@ class SessionApplication(dbus.service.Object):
                try:
                        self.session.Connect()
                except dbus.DBusException, e:
-                       if e.get_dbus_name() in ['net.connman.Error.InProgress',
-                                                'net.connman.Error.AlreadyConnected']:
+                       if e.get_dbus_name() in ['net.connman.Error.Failed']:
                                print e.get_dbus_message()
                                return
                        traceback.print_exc()
@@ -188,8 +188,7 @@ class SessionApplication(dbus.service.Object):
                try:
                        self.session.Disconnect()
                except dbus.DBusException, e:
-                       if e.get_dbus_name() in ['net.connman.Error.AlreadyDisabled',
-                                                'net.connman.Error.NotConnected']:
+                       if e.get_dbus_name() in ['net.connman.Error.Failed']:
                                print e.get_dbus_message()
                                return
                        traceback.print_exc()
@@ -203,7 +202,7 @@ class SessionApplication(dbus.service.Object):
                        val = self.type_convert(key, value)
                        self.session.Change(key, val)
                except dbus.DBusException, e:
-                       if e.get_dbus_name() in ['net.connman.Error.InvalidArguments']:
+                       if e.get_dbus_name() in ['net.connman.Error.Failed']:
                                print e.get_dbus_message()
                                return
                        traceback.print_exc()
@@ -255,8 +254,10 @@ def main():
        app_path = sys.argv[2]
        bus = dbus.SessionBus()
 
+       app_name = "com.example.SessionApplication.%s" % (string.strip(app_path, "/"))
+
        if sys.argv[1] == "run":
-               name = dbus.service.BusName("com.example.SessionApplication", bus)
+               name = dbus.service.BusName(app_name, bus)
                mainloop = gobject.MainLoop()
 
                app = SessionApplication(bus, app_path, mainloop)
@@ -264,7 +265,7 @@ def main():
                mainloop.run()
                return
 
-       app = dbus.Interface(bus.get_object("com.example.SessionApplication", app_path),
+       app = dbus.Interface(bus.get_object(app_name, app_path),
                             "com.example.TestSession")
 
        if sys.argv[1] == "create":