From 8c4df6215a986695edc6c6530f6d6388ea9640d5 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Mon, 13 Feb 2023 22:02:46 +0100 Subject: UnitySession -> LomiriSession: Re-rename related changes that we erroneously hid away as Ayatana DesktopSession. This brings full Lomiri integration finally. Until now, the session indicator somehow seemed to work, but in some odd ways. On the phone, the session indicator would fallback to direct systemd interaction while on Lomiri in Debian, it would fallback to Zenity dialogs (most of all because Zenity got installed by some other package as a dependency). With this massive renaming change, ayatana-indicator-session should now smoothly interact with the com.lomiri.Shell.Session DBus interface and also with the mimicked GNOME SessionManager End-Session-Dialog interface. As a downside, this change nearly fully removes Unity7 support which would need to be brought back +/- as a full duplicate of what we do for Lomiri. But as noone has dared integrating Ayatana Indicator Session with Unity7, so far, we should be able to live with that for now. Fixes https://github.com/AyatanaIndicators/ayatana-indicator-session/issues/82 --- debian/copyright | 6 +- debian/copyright.in | 2 +- src/backend-dbus/CMakeLists.txt | 7 +- src/backend-dbus/actions.c | 86 ++++++++++++------------ src/backend-dbus/com.lomiri.Shell.Session.xml | 12 ++++ src/backend-dbus/org.ayatana.Desktop.Session.xml | 12 ---- tests/backend-dbus/CMakeLists.txt | 4 +- tests/backend-dbus/gtest-mock-dbus-fixture.h | 2 +- tests/backend-dbus/mock-end-session-dialog.cc | 2 +- tests/backend-dbus/mock-lomiri-session.cc | 83 +++++++++++++++++++++++ tests/backend-dbus/mock-lomiri-session.h | 57 ++++++++++++++++ tests/backend-dbus/mock-unity-session.cc | 83 ----------------------- tests/backend-dbus/mock-unity-session.h | 57 ---------------- tests/backend-dbus/test-actions.cc | 36 +++++----- 14 files changed, 225 insertions(+), 224 deletions(-) create mode 100644 src/backend-dbus/com.lomiri.Shell.Session.xml delete mode 100644 src/backend-dbus/org.ayatana.Desktop.Session.xml create mode 100644 tests/backend-dbus/mock-lomiri-session.cc create mode 100644 tests/backend-dbus/mock-lomiri-session.h delete mode 100644 tests/backend-dbus/mock-unity-session.cc delete mode 100644 tests/backend-dbus/mock-unity-session.h diff --git a/debian/copyright b/debian/copyright index 5b4b331..5214e9c 100644 --- a/debian/copyright +++ b/debian/copyright @@ -42,8 +42,8 @@ Files: src/actions.c tests/backend-dbus/mock-screen-saver.h tests/backend-dbus/mock-session-manager.cc tests/backend-dbus/mock-session-manager.h - tests/backend-dbus/mock-unity-session.cc - tests/backend-dbus/mock-unity-session.h + tests/backend-dbus/mock-lomiri-session.cc + tests/backend-dbus/mock-lomiri-session.h tests/backend-dbus/mock-user.cc tests/backend-dbus/mock-user.h tests/backend-dbus/mock-webcredentials.cc @@ -88,7 +88,7 @@ Files: CMakeLists.txt po/POTFILES.in src/CMakeLists.txt src/backend-dbus/CMakeLists.txt - src/backend-dbus/org.ayatana.Desktop.Session.xml + src/backend-dbus/com.lomiri.Shell.Session.xml src/backend-dbus/org.ayatana.indicators.webcredentials.xml src/backend-dbus/org.freedesktop.Accounts.User.xml src/backend-dbus/org.freedesktop.Accounts.xml diff --git a/debian/copyright.in b/debian/copyright.in index c2b8f39..a635592 100644 --- a/debian/copyright.in +++ b/debian/copyright.in @@ -100,7 +100,7 @@ Files: CMakeLists.txt debian/watch po/CMakeLists.txt src/CMakeLists.txt - src/backend-dbus/org.ayatana.Desktop.Session.xml + src/backend-dbus/com.lomiri.Shell.Session.xml src/backend-dbus/org.ayatana.indicators.webcredentials.xml src/backend-dbus/org.freedesktop.Accounts.User.xml src/backend-dbus/org.freedesktop.Accounts.xml diff --git a/src/backend-dbus/CMakeLists.txt b/src/backend-dbus/CMakeLists.txt index 5c99e9f..bd87e27 100644 --- a/src/backend-dbus/CMakeLists.txt +++ b/src/backend-dbus/CMakeLists.txt @@ -43,9 +43,10 @@ add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-end-session-dialog org.gnome.SessionManager ${CMAKE_CURRENT_SOURCE_DIR}/org.gnome.SessionManager.EndSessionDialog.xml) -add_gdbus_codegen (BACKEND_GENERATED_SOURCES desktop-session - org.ayatana - ${CMAKE_CURRENT_SOURCE_DIR}/org.ayatana.Desktop.Session.xml) +add_gdbus_codegen_with_namespace (BACKEND_GENERATED_SOURCES lomiri-session + com.lomiri + Lomiri + ${CMAKE_CURRENT_SOURCE_DIR}/com.lomiri.Shell.Session.xml) set (SOURCES actions.c guest.c users.c backend-dbus.c utils.c) diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c index 9450865..d735f00 100644 --- a/src/backend-dbus/actions.c +++ b/src/backend-dbus/actions.c @@ -27,7 +27,7 @@ #include "dbus-webcredentials.h" #include "gnome-screen-saver.h" #include "gnome-session-manager.h" -#include "desktop-session.h" +#include "lomiri-session.h" #include "actions.h" @@ -48,7 +48,7 @@ struct _IndicatorSessionActionsDbusPrivate GSettings * indicator_settings; GnomeScreenSaver * screen_saver; GnomeSessionManager * session_manager; - DesktopSession * desktop_session; + LomiriShellSession * lomiri_session; Login1Manager * login1_manager; GCancellable * login1_manager_cancellable; Login1Seat * login1_seat; @@ -92,7 +92,7 @@ typedef enum { PROMPT_NONE, PROMPT_WITH_ZENITY, - PROMPT_WITH_AYATANA, + PROMPT_WITH_LOMIRI, PROMPT_WITH_MATE, PROMPT_WITH_BUDGIE, PROMPT_WITH_XFCE, @@ -121,13 +121,13 @@ get_prompt_status (IndicatorSessionActionsDbus * self) if ((prompt == PROMPT_NONE) && ayatana_common_utils_have_xfce_program ("xfce4-session-logout")) prompt = PROMPT_WITH_XFCE; - /* can we use the Unity/Ayatana prompt? */ + /* can we use Lomiri prompt? */ if ((prompt == PROMPT_NONE) && p && p->end_session_dialog) { GDBusProxy * proxy = G_DBUS_PROXY (p->end_session_dialog); char * name = g_dbus_proxy_get_name_owner (proxy); if (name != NULL) - prompt = PROMPT_WITH_AYATANA; + prompt = PROMPT_WITH_LOMIRI; g_free (name); } @@ -219,16 +219,16 @@ on_screensaver_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpoin } static void -on_desktop_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer gself) +on_lomiri_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer gself) { GError * err; - DesktopSession * us; + LomiriShellSession * us; err = NULL; - us = desktop_session_proxy_new_for_bus_finish (res, &err); + us = lomiri_shell_session_proxy_new_for_bus_finish (res, &err); if (err == NULL) { - INDICATOR_SESSION_ACTIONS_DBUS(gself)->priv->desktop_session = us; + INDICATOR_SESSION_ACTIONS_DBUS(gself)->priv->lomiri_session = us; } log_and_clear_error (&err, G_STRLOC, G_STRFUNC); @@ -420,7 +420,7 @@ my_can_reboot (IndicatorSessionActions * actions) /* Shutdown and Restart are the same dialog prompt in Unity, so disable the redundant 'Restart' menuitem in that mode */ if (!g_settings_get_boolean (p->indicator_settings, "suppress-shutdown-menuitem")) - if (ayatana_common_utils_is_unity()) + if (ayatana_common_utils_is_unity() || ayatana_common_utils_is_lomiri()) return FALSE; return TRUE; @@ -547,14 +547,14 @@ logout_now_gnome_session_manager (IndicatorSessionActionsDbus * self) } static void -on_desktop_logout_response (GObject * o, - GAsyncResult * res, - gpointer gself) +on_lomiri_logout_response (GObject * o, + GAsyncResult * res, + gpointer gself) { GError * error; error = NULL; - desktop_session_call_request_logout_finish (DESKTOP_SESSION(o), res, &error); + lomiri_shell_session_call_request_logout_finish (LOMIRI_SHELL_SESSION(o), res, &error); if (error != NULL) { @@ -574,15 +574,15 @@ logout_now_desktop (IndicatorSessionActionsDbus * self) priv_t * p = self->priv; gboolean called = FALSE; - if (is_owned_proxy (p->desktop_session)) + if (is_owned_proxy (p->lomiri_session)) { called = TRUE; - g_debug ("calling desktop_session_call_request_logout()"); - desktop_session_call_request_logout (p->desktop_session, - p->cancellable, - on_desktop_logout_response, - self); - } + g_debug ("calling lomiri_shell_session_call_request_logout()"); + lomiri_shell_session_call_request_logout (p->lomiri_session, + p->cancellable, + on_lomiri_logout_response, + self); + } return called; } @@ -675,7 +675,7 @@ on_open_end_session_dialog_ready (GObject * o, } static void -show_desktop_end_session_dialog (IndicatorSessionActionsDbus * self, int type) +show_lomiri_end_session_dialog (IndicatorSessionActionsDbus * self, int type) { priv_t * p = INDICATOR_SESSION_ACTIONS_DBUS(self)->priv; gpointer o = p->end_session_dialog; @@ -761,8 +761,8 @@ my_logout (IndicatorSessionActions * actions) switch (get_prompt_status (self)) { - case PROMPT_WITH_AYATANA: - show_desktop_end_session_dialog (self, END_SESSION_TYPE_LOGOUT); + case PROMPT_WITH_LOMIRI: + show_lomiri_end_session_dialog (self, END_SESSION_TYPE_LOGOUT); break; case PROMPT_WITH_MATE: @@ -809,8 +809,8 @@ my_reboot (IndicatorSessionActions * actions) switch (get_prompt_status (self)) { - case PROMPT_WITH_AYATANA: - show_desktop_end_session_dialog (self, END_SESSION_TYPE_REBOOT); + case PROMPT_WITH_LOMIRI: + show_lomiri_end_session_dialog (self, END_SESSION_TYPE_REBOOT); break; case PROMPT_WITH_MATE: @@ -847,13 +847,13 @@ my_power_off (IndicatorSessionActions * actions) switch (get_prompt_status (self)) { - case PROMPT_WITH_AYATANA: + case PROMPT_WITH_LOMIRI: /* NB: TYPE_REBOOT instead of TYPE_SHUTDOWN because - the latter adds lock & logout options in Unity... */ - if (ayatana_common_utils_is_unity()) - show_desktop_end_session_dialog (self, END_SESSION_TYPE_REBOOT); + the latter adds lock & logout options in Unity and Lomiri... */ + if (ayatana_common_utils_is_unity() || ayatana_common_utils_is_lomiri()) + show_lomiri_end_session_dialog (self, END_SESSION_TYPE_REBOOT); else - show_desktop_end_session_dialog (self, END_SESSION_TYPE_SHUTDOWN); + show_lomiri_end_session_dialog (self, END_SESSION_TYPE_SHUTDOWN); break; case PROMPT_WITH_MATE: @@ -983,15 +983,15 @@ lock_current_session (IndicatorSessionActions * self, gboolean immediate) { priv_t * p = INDICATOR_SESSION_ACTIONS_DBUS(self)->priv; - if (is_owned_proxy (p->desktop_session)) + if (is_owned_proxy (p->lomiri_session)) { if (immediate) { - desktop_session_call_prompt_lock (p->desktop_session, p->cancellable, NULL, NULL); + lomiri_shell_session_call_prompt_lock (p->lomiri_session, p->cancellable, NULL, NULL); } else { - desktop_session_call_lock (p->desktop_session, p->cancellable, NULL, NULL); + lomiri_shell_session_call_lock (p->lomiri_session, p->cancellable, NULL, NULL); } } else if (ayatana_common_utils_have_mate_program ("mate-screensaver-command")) @@ -1100,7 +1100,7 @@ my_dispose (GObject * o) g_clear_object (&p->screen_saver); g_clear_object (&p->session_manager); - g_clear_object (&p->desktop_session); + g_clear_object (&p->lomiri_session); set_dm_seat (self, NULL); set_login1_manager (self, NULL); set_login1_seat (self, NULL); @@ -1203,13 +1203,13 @@ indicator_session_actions_dbus_init (IndicatorSessionActionsDbus * self) on_screensaver_proxy_ready, self); - desktop_session_proxy_new_for_bus (G_BUS_TYPE_SESSION, - G_DBUS_PROXY_FLAGS_NONE, - "org.ayatana.Desktop", - "/org/ayatana/Desktop/Session", - p->cancellable, - on_desktop_proxy_ready, - self); + lomiri_shell_session_proxy_new_for_bus (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + "com.lomiri.Shell", + "/com/lomiri/Shell/Session", + p->cancellable, + on_lomiri_proxy_ready, + self); gnome_session_manager_proxy_new_for_bus (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, @@ -1229,7 +1229,7 @@ indicator_session_actions_dbus_init (IndicatorSessionActionsDbus * self) end_session_dialog_proxy_new_for_bus (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, - "org.ayatana.Desktop", + "com.lomiri.Shell", "/org/gnome/SessionManager/EndSessionDialog", p->cancellable, on_end_session_dialog_proxy_ready, diff --git a/src/backend-dbus/com.lomiri.Shell.Session.xml b/src/backend-dbus/com.lomiri.Shell.Session.xml new file mode 100644 index 0000000..0e1e903 --- /dev/null +++ b/src/backend-dbus/com.lomiri.Shell.Session.xml @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/src/backend-dbus/org.ayatana.Desktop.Session.xml b/src/backend-dbus/org.ayatana.Desktop.Session.xml deleted file mode 100644 index 9257b91..0000000 --- a/src/backend-dbus/org.ayatana.Desktop.Session.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/tests/backend-dbus/CMakeLists.txt b/tests/backend-dbus/CMakeLists.txt index 92d5a02..393fc13 100644 --- a/tests/backend-dbus/CMakeLists.txt +++ b/tests/backend-dbus/CMakeLists.txt @@ -14,8 +14,8 @@ add_library (desktopmock STATIC mock-object.h mock-screen-saver.cc mock-screen-saver.h - mock-unity-session.cc - mock-unity-session.h + mock-lomiri-session.cc + mock-lomiri-session.h mock-session-manager.cc mock-session-manager.h mock-user.cc diff --git a/tests/backend-dbus/gtest-mock-dbus-fixture.h b/tests/backend-dbus/gtest-mock-dbus-fixture.h index 16b4648..df5bc82 100644 --- a/tests/backend-dbus/gtest-mock-dbus-fixture.h +++ b/tests/backend-dbus/gtest-mock-dbus-fixture.h @@ -25,7 +25,7 @@ #include "mock-display-manager-seat.h" #include "mock-end-session-dialog.h" #include "mock-screen-saver.h" -#include "mock-unity-session.h" +#include "mock-lomiri-session.h" #include "mock-session-manager.h" #include "mock-user.h" #include "mock-webcredentials.h" diff --git a/tests/backend-dbus/mock-end-session-dialog.cc b/tests/backend-dbus/mock-end-session-dialog.cc index 5e8797f..3134dd5 100644 --- a/tests/backend-dbus/mock-end-session-dialog.cc +++ b/tests/backend-dbus/mock-end-session-dialog.cc @@ -39,7 +39,7 @@ MockEndSessionDialog :: handle_open (EndSessionDialog * object, namespace { - const char * const MY_NAME = "org.ayatana.Desktop"; + const char * const MY_NAME = "com.lomiri.Shell"; const char * const MY_PATH = "/org/gnome/SessionManager/EndSessionDialog"; } diff --git a/tests/backend-dbus/mock-lomiri-session.cc b/tests/backend-dbus/mock-lomiri-session.cc new file mode 100644 index 0000000..dd3fec5 --- /dev/null +++ b/tests/backend-dbus/mock-lomiri-session.cc @@ -0,0 +1,83 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * Authors: + * Marco Trevisan + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "mock-lomiri-session.h" + + +gboolean +MockLomiriSession :: handle_lock (LomiriShellSession * us, + GDBusMethodInvocation * inv, + gpointer gself) +{ + static_cast(gself)->my_last_action = Lock; + lomiri_shell_session_complete_lock (us, inv); + return true; +} + +gboolean +MockLomiriSession :: handle_prompt_lock (LomiriShellSession * us, + GDBusMethodInvocation * inv, + gpointer gself) +{ + static_cast(gself)->my_last_action = PromptLock; + lomiri_shell_session_complete_prompt_lock (us, inv); + return true; +} + +gboolean +MockLomiriSession :: handle_request_logout (LomiriShellSession * us, + GDBusMethodInvocation * inv, + gpointer gself) +{ + static_cast(gself)->my_last_action = RequestLogout; + lomiri_shell_session_complete_request_logout (us, inv); + return true; +} + +/*** +**** +***/ + +namespace +{ + const char * const LOMIRI_SESSION_NAME = "com.lomiri.Shell"; + const char * const LOMIRI_SESSION_PATH = "/com/lomiri/Shell/Session"; + +} + +MockLomiriSession :: MockLomiriSession (GMainLoop * loop, + GDBusConnection * bus_connection): + MockObject (loop, bus_connection, LOMIRI_SESSION_NAME, LOMIRI_SESSION_PATH), + my_skeleton (lomiri_shell_session_skeleton_new ()), + my_last_action (None) +{ + g_signal_connect (my_skeleton, "handle-lock", + G_CALLBACK(handle_lock), this); + g_signal_connect (my_skeleton, "handle-prompt-lock", + G_CALLBACK(handle_prompt_lock), this); + g_signal_connect (my_skeleton, "handle-request-logout", + G_CALLBACK(handle_request_logout), this); + + set_skeleton (G_DBUS_INTERFACE_SKELETON(my_skeleton)); +} + +MockLomiriSession :: ~MockLomiriSession () +{ + g_clear_object (&my_skeleton); +} diff --git a/tests/backend-dbus/mock-lomiri-session.h b/tests/backend-dbus/mock-lomiri-session.h new file mode 100644 index 0000000..1f42f49 --- /dev/null +++ b/tests/backend-dbus/mock-lomiri-session.h @@ -0,0 +1,57 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * Authors: + * Marco Trevisan + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef MOCK_LOMIRI_SESSION_H +#define MOCK_LOMIRI_SESSION_H + +#include "mock-object.h" // parent class +#include "backend-dbus/lomiri-session.h" // Lomiri Session + +class MockLomiriSession: public MockObject +{ + public: + + MockLomiriSession (GMainLoop * loop, + GDBusConnection * bus_connection); + virtual ~MockLomiriSession (); + + public: + + enum Action { None, Lock, PromptLock, RequestLogout, RequestShutdown, RequestReboot }; + Action last_action () { return my_last_action; } + void clear_last_action () { my_last_action = None; } + + private: + + LomiriShellSession * my_skeleton; + Action my_last_action; + + static gboolean handle_lock (LomiriShellSession *, + GDBusMethodInvocation *, + gpointer); + static gboolean handle_prompt_lock (LomiriShellSession *, + GDBusMethodInvocation *, + gpointer); + static gboolean handle_request_logout (LomiriShellSession *, + GDBusMethodInvocation *, + gpointer); + +}; + +#endif diff --git a/tests/backend-dbus/mock-unity-session.cc b/tests/backend-dbus/mock-unity-session.cc deleted file mode 100644 index 8bc06a3..0000000 --- a/tests/backend-dbus/mock-unity-session.cc +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2014 Canonical Ltd. - * - * Authors: - * Marco Trevisan - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "mock-unity-session.h" - - -gboolean -MockUnitySession :: handle_lock (DesktopSession * us, - GDBusMethodInvocation * inv, - gpointer gself) -{ - static_cast(gself)->my_last_action = Lock; - desktop_session_complete_lock (us, inv); - return true; -} - -gboolean -MockUnitySession :: handle_prompt_lock (DesktopSession * us, - GDBusMethodInvocation * inv, - gpointer gself) -{ - static_cast(gself)->my_last_action = PromptLock; - desktop_session_complete_prompt_lock (us, inv); - return true; -} - -gboolean -MockUnitySession :: handle_request_logout (DesktopSession * us, - GDBusMethodInvocation * inv, - gpointer gself) -{ - static_cast(gself)->my_last_action = RequestLogout; - desktop_session_complete_request_logout (us, inv); - return true; -} - -/*** -**** -***/ - -namespace -{ - const char * const UNITY_SESSION_NAME = "org.ayatana.Desktop"; - const char * const UNITY_SESSION_PATH = "/org/ayatana/Desktop/Session"; - -} - -MockUnitySession :: MockUnitySession (GMainLoop * loop, - GDBusConnection * bus_connection): - MockObject (loop, bus_connection, UNITY_SESSION_NAME, UNITY_SESSION_PATH), - my_skeleton (desktop_session_skeleton_new ()), - my_last_action (None) -{ - g_signal_connect (my_skeleton, "handle-lock", - G_CALLBACK(handle_lock), this); - g_signal_connect (my_skeleton, "handle-prompt-lock", - G_CALLBACK(handle_prompt_lock), this); - g_signal_connect (my_skeleton, "handle-request-logout", - G_CALLBACK(handle_request_logout), this); - - set_skeleton (G_DBUS_INTERFACE_SKELETON(my_skeleton)); -} - -MockUnitySession :: ~MockUnitySession () -{ - g_clear_object (&my_skeleton); -} diff --git a/tests/backend-dbus/mock-unity-session.h b/tests/backend-dbus/mock-unity-session.h deleted file mode 100644 index 890f2ac..0000000 --- a/tests/backend-dbus/mock-unity-session.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2014 Canonical Ltd. - * - * Authors: - * Marco Trevisan - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef MOCK_UNITY_SESSION_H -#define MOCK_UNITY_SESSION_H - -#include "mock-object.h" // parent class -#include "backend-dbus/desktop-session.h" // Desktop Session - -class MockUnitySession: public MockObject -{ - public: - - MockUnitySession (GMainLoop * loop, - GDBusConnection * bus_connection); - virtual ~MockUnitySession (); - - public: - - enum Action { None, Lock, PromptLock, RequestLogout, RequestShutdown, RequestReboot }; - Action last_action () { return my_last_action; } - void clear_last_action () { my_last_action = None; } - - private: - - DesktopSession * my_skeleton; - Action my_last_action; - - static gboolean handle_lock (DesktopSession *, - GDBusMethodInvocation *, - gpointer); - static gboolean handle_prompt_lock (DesktopSession *, - GDBusMethodInvocation *, - gpointer); - static gboolean handle_request_logout (DesktopSession *, - GDBusMethodInvocation *, - gpointer); - -}; - -#endif diff --git a/tests/backend-dbus/test-actions.cc b/tests/backend-dbus/test-actions.cc index 709273a..bced3e9 100644 --- a/tests/backend-dbus/test-actions.cc +++ b/tests/backend-dbus/test-actions.cc @@ -263,10 +263,10 @@ TEST_F (Actions, PowerOff) g_settings_reset (indicator_settings, SUPPRESS_KEY); } -TEST_F (Actions, LogoutUnity) +TEST_F (Actions, LogoutLomiri) { - MockUnitySession desktop_session(loop, conn); - ASSERT_EQ (MockUnitySession::None, desktop_session.last_action()); + MockLomiriSession lomiri_session(loop, conn); + ASSERT_EQ (MockLomiriSession::None, lomiri_session.last_action()); wait_msec(); // confirm that user is prompted @@ -276,7 +276,7 @@ TEST_F (Actions, LogoutUnity) ASSERT_TRUE (end_session_dialog->is_open()); end_session_dialog->cancel(); wait_msec (50); - ASSERT_EQ (MockUnitySession::None, desktop_session.last_action()); + ASSERT_EQ (MockLomiriSession::None, lomiri_session.last_action()); // confirm that user is prompted // and that logout is called when user confirms the logout dialog @@ -285,19 +285,19 @@ TEST_F (Actions, LogoutUnity) ASSERT_TRUE (end_session_dialog->is_open ()); end_session_dialog->confirm_logout (); wait_msec (100); - ASSERT_EQ (MockUnitySession::RequestLogout, desktop_session.last_action()); + ASSERT_EQ (MockLomiriSession::RequestLogout, lomiri_session.last_action()); // confirm that we try to call SessionManager::LogoutQuet // when prompts are disabled login1_manager->clear_last_action (); - desktop_session.clear_last_action (); + lomiri_session.clear_last_action (); ASSERT_EQ ("", login1_manager->last_action()); - ASSERT_EQ (MockUnitySession::None, desktop_session.last_action ()); + ASSERT_EQ (MockLomiriSession::None, lomiri_session.last_action ()); g_settings_set_boolean (indicator_settings, SUPPRESS_KEY, TRUE); wait_msec (50); indicator_session_actions_logout (actions); wait_msec (50); - ASSERT_EQ (MockUnitySession::RequestLogout, desktop_session.last_action ()); + ASSERT_EQ (MockLomiriSession::RequestLogout, lomiri_session.last_action ()); g_settings_reset (indicator_settings, SUPPRESS_KEY); } @@ -356,29 +356,29 @@ TEST_F (Actions, Hibernate) TEST_F (Actions, SwitchToScreensaver) { - MockUnitySession desktop_session(loop, conn); + MockLomiriSession lomiri_session(loop, conn); - ASSERT_EQ (MockUnitySession::None, desktop_session.last_action()); + ASSERT_EQ (MockLomiriSession::None, lomiri_session.last_action()); indicator_session_actions_switch_to_screensaver (actions); wait_msec (50); - ASSERT_EQ (MockUnitySession::Lock, desktop_session.last_action()); + ASSERT_EQ (MockLomiriSession::Lock, lomiri_session.last_action()); } TEST_F (Actions, SwitchToGreeter) { - MockUnitySession desktop_session(loop, conn); + MockLomiriSession lomiri_session(loop, conn); ASSERT_NE (MockDisplayManagerSeat::GREETER, dm_seat->last_action()); - ASSERT_EQ (MockUnitySession::None, desktop_session.last_action()); + ASSERT_EQ (MockLomiriSession::None, lomiri_session.last_action()); indicator_session_actions_switch_to_greeter (actions); wait_msec (50); - ASSERT_EQ (MockUnitySession::PromptLock, desktop_session.last_action()); + ASSERT_EQ (MockLomiriSession::PromptLock, lomiri_session.last_action()); ASSERT_EQ (MockDisplayManagerSeat::GREETER, dm_seat->last_action()); } TEST_F (Actions, SwitchToGuest) { - MockUnitySession desktop_session(loop, conn); + MockLomiriSession lomiri_session(loop, conn); // allow guests dm_seat->set_guest_allowed (true); @@ -394,12 +394,12 @@ TEST_F (Actions, SwitchToGuest) wait_for_signal (login1_seat->skeleton(), "notify::active-session"); ASSERT_EQ (guest_session_tag, login1_seat->active_session()); wait_msec (50); - ASSERT_EQ (MockUnitySession::PromptLock, desktop_session.last_action()); + ASSERT_EQ (MockLomiriSession::PromptLock, lomiri_session.last_action()); } TEST_F (Actions, SwitchToUsername) { - MockUnitySession desktop_session(loop, conn); + MockLomiriSession lomiri_session(loop, conn); const char * const dr1_username = "whartnell"; const char * const dr2_username = "ptroughton"; MockUser * dr1_user; @@ -417,7 +417,7 @@ TEST_F (Actions, SwitchToUsername) wait_for_signal (login1_seat->skeleton(), "notify::active-session"); ASSERT_EQ (dr1_session, login1_seat->active_session()); wait_msec (50); - ASSERT_EQ (MockUnitySession::PromptLock, desktop_session.last_action()); + ASSERT_EQ (MockLomiriSession::PromptLock, lomiri_session.last_action()); indicator_session_actions_switch_to_username (actions, dr2_username); wait_for_signal (login1_seat->skeleton(), "notify::active-session"); -- cgit v1.2.3