From 26b40c39ef74eec4f0e9cc7834cfd033a4decbb3 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Tue, 31 Oct 2006 22:40:34 -0500 Subject: Add a script to test FUS related functionality. Fix a problem where error was reported twice. --- src/ck-seat.c | 5 ++++- src/test-fus | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/test-session | 13 ++++-------- 3 files changed, 71 insertions(+), 10 deletions(-) create mode 100755 src/test-fus diff --git a/src/ck-seat.c b/src/ck-seat.c index fa73c40..53daad4 100644 --- a/src/ck-seat.c +++ b/src/ck-seat.c @@ -369,7 +369,10 @@ session_activate (CkSession *session, DBusGMethodInvocation *context, CkSeat *seat) { - return _seat_activate_session (seat, session, context); + _seat_activate_session (seat, session, context); + + /* always return TRUE to indicate that the signal was handled */ + return TRUE; } gboolean diff --git a/src/test-fus b/src/test-fus new file mode 100755 index 0000000..3ac7921 --- /dev/null +++ b/src/test-fus @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# +# Test fast-user-switch functionality +# + +import os +import sys +import gobject +import dbus +import dbus.glib + +def activate_reply (res): + print "session activated" + +def activate_error (e): + print str (e) + +def session_added_cb (ssid): + print "Session added: %s" % ssid + +def session_removed_cb (ssid): + print "Session removed: %s" % ssid + +def active_session_changed_cb (ssid): + print "Active session changed: %s" % ssid + +bus = dbus.SystemBus () + +manager_obj = bus.get_object ('org.freedesktop.ConsoleKit', '/org/freedesktop/ConsoleKit/Manager') + +manager = dbus.Interface (manager_obj, 'org.freedesktop.ConsoleKit.Manager') + +current_ssid = manager.GetCurrentSession () +current_session_obj = bus.get_object ('org.freedesktop.ConsoleKit', current_ssid) +current_session = dbus.Interface (current_session_obj, 'org.freedesktop.ConsoleKit.Session') + +sid = current_session.GetSeatId () +if not sid: + print "Current session is not attached to a seat, no switching possible" + sys.exit () + +seat_obj = bus.get_object ('org.freedesktop.ConsoleKit', sid) +seat = dbus.Interface (seat_obj, 'org.freedesktop.ConsoleKit.Seat') +seat.connect_to_signal ('SessionAdded', session_added_cb) +seat.connect_to_signal ('SessionRemoved', session_removed_cb) +seat.connect_to_signal ('ActiveSessionChanged', active_session_changed_cb) + +# Show a list of sessions on the current seat +sessions = seat.GetSessions () +for ssid in sessions: + session_obj = bus.get_object ('org.freedesktop.ConsoleKit', ssid) + session = dbus.Interface (session_obj, 'org.freedesktop.ConsoleKit.Session') + uid = session.GetUser () + print "Session %s user=%u" % (ssid, uid) + +# then pretend a session-ID is selected: +ssid = current_ssid +session_obj = bus.get_object ('org.freedesktop.ConsoleKit', ssid) +session = dbus.Interface (session_obj, 'org.freedesktop.ConsoleKit.Session') +session.Activate (reply_handler = activate_reply, error_handler = activate_error) + +mainloop = gobject.MainLoop () +mainloop.run() diff --git a/src/test-session b/src/test-session index d77c5f1..3b26057 100755 --- a/src/test-session +++ b/src/test-session @@ -1,15 +1,12 @@ #!/usr/bin/env python +# +# Test opening a new session +# import os import gobject import dbus - -def activate_reply (res): - print "session activated" - -def activate_error (e): - print str (e) - +import dbus.glib bus = dbus.SystemBus () @@ -42,8 +39,6 @@ print "Current session: %s" % current_session session_obj = bus.get_object ('org.freedesktop.ConsoleKit', ssid) session = dbus.Interface (session_obj, 'org.freedesktop.ConsoleKit.Session') -session.Activate (reply_handler = activate_reply, error_handler = activate_error) - mainloop = gobject.MainLoop () gobject.timeout_add (30000, mainloop.quit) -- cgit