Merge lp:~3v1n0/unity/lockscreen-power-keys into lp:unity
- lockscreen-power-keys
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Stephen M. Webb |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3828 |
Proposed branch: | lp:~3v1n0/unity/lockscreen-power-keys |
Merge into: | lp:unity |
Prerequisite: | lp:~brandontschaefer/unity/shutdown-dialog-hi-dpi |
Diff against target: |
701 lines (+225/-66) 14 files modified
UnityCore/GnomeSessionManager.cpp (+62/-14) UnityCore/GnomeSessionManager.h (+2/-0) UnityCore/GnomeSessionManagerImpl.h (+1/-0) UnityCore/SessionManager.h (+3/-0) lockscreen/LockScreenAcceleratorController.cpp (+46/-2) lockscreen/LockScreenAcceleratorController.h (+2/-1) lockscreen/LockScreenController.cpp (+3/-3) shutdown/SessionDBusManager.cpp (+23/-9) shutdown/SessionView.cpp (+49/-30) shutdown/SessionView.h (+6/-5) shutdown/StandaloneSession.cpp (+2/-0) tests/test_mock_session_manager.h (+2/-0) tests/test_session_controller.cpp (+1/-0) tests/test_session_view.cpp (+23/-2) |
To merge this branch: | bzr merge lp:~3v1n0/unity/lockscreen-power-keys |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stephen M. Webb (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Christopher Townsend | Approve | ||
Review via email: mp+219778@code.launchpad.net |
Commit message
LockScreenAccel
We finally can suspend, shutdown, hibernate or start the screensaver when the screen is locked, using
the Suspend, Sleep, Hibernate and PowerOff hardware keys.
Also the Shutdown dialog doesn't allow now to lock the session if it is not allowed by settings.
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
Christopher Townsend (townsend) wrote : | # |
LGTM
Christopher Townsend (townsend) wrote : | # |
Oops, meant to approve
Stephen M. Webb (bregma) wrote : | # |
Merge conflicts when attempting to merge to trunk.
Text conflict in lockscreen/
Text conflict in shutdown/
2 conflicts encountered.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3818
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Stephen M. Webb (bregma) wrote : | # |
OK, merges cleanly now
Preview Diff
1 | === modified file 'UnityCore/GnomeSessionManager.cpp' | |||
2 | --- UnityCore/GnomeSessionManager.cpp 2014-04-16 22:03:41 +0000 | |||
3 | +++ UnityCore/GnomeSessionManager.cpp 2014-06-18 15:11:36 +0000 | |||
4 | @@ -91,6 +91,11 @@ | |||
5 | 91 | shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE); | 91 | shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE); |
6 | 92 | shell_object_->SetMethodsCallsHandler(sigc::mem_fun(this, &Impl::OnShellMethodCall)); | 92 | shell_object_->SetMethodsCallsHandler(sigc::mem_fun(this, &Impl::OnShellMethodCall)); |
7 | 93 | 93 | ||
8 | 94 | manager_->is_locked = false; | ||
9 | 95 | manager_->is_locked.changed.connect([this] (bool locked) { | ||
10 | 96 | locked ? manager_->locked.emit() : manager_->unlocked.emit(); | ||
11 | 97 | }); | ||
12 | 98 | |||
13 | 94 | { | 99 | { |
14 | 95 | const char* session_id = test_mode_ ? "id0" : g_getenv("XDG_SESSION_ID"); | 100 | const char* session_id = test_mode_ ? "id0" : g_getenv("XDG_SESSION_ID"); |
15 | 96 | 101 | ||
16 | @@ -421,21 +426,13 @@ | |||
17 | 421 | { | 426 | { |
18 | 422 | EnsureCancelPendingAction(); | 427 | EnsureCancelPendingAction(); |
19 | 423 | 428 | ||
20 | 429 | if (!manager_->CanLock()) | ||
21 | 430 | { | ||
22 | 431 | manager_->ScreenSaverActivate(); | ||
23 | 432 | return; | ||
24 | 433 | } | ||
25 | 434 | |||
26 | 424 | // FIXME (andy) we should ask gnome-session to emit the logind signal | 435 | // FIXME (andy) we should ask gnome-session to emit the logind signal |
27 | 425 | glib::Object<GSettings> lockdown_settings(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str())); | ||
28 | 426 | |||
29 | 427 | if (g_settings_get_boolean(lockdown_settings, DISABLE_LOCKSCREEN_KEY.c_str())) | ||
30 | 428 | { | ||
31 | 429 | manager_->ScreenSaverActivate(); | ||
32 | 430 | return; | ||
33 | 431 | } | ||
34 | 432 | else if (manager_->UserName().find("guest-") == 0) | ||
35 | 433 | { | ||
36 | 434 | LOG_INFO(logger) << "Impossible to lock a guest session"; | ||
37 | 435 | manager_->ScreenSaverActivate(); | ||
38 | 436 | return; | ||
39 | 437 | } | ||
40 | 438 | |||
41 | 439 | prompt ? manager_->prompt_lock_requested.emit() : manager_->lock_requested.emit(); | 436 | prompt ? manager_->prompt_lock_requested.emit() : manager_->lock_requested.emit(); |
42 | 440 | } | 437 | } |
43 | 441 | 438 | ||
44 | @@ -454,6 +451,39 @@ | |||
45 | 454 | }); | 451 | }); |
46 | 455 | } | 452 | } |
47 | 456 | 453 | ||
48 | 454 | bool GnomeManager::Impl::HasInhibitors() | ||
49 | 455 | { | ||
50 | 456 | glib::Error error; | ||
51 | 457 | glib::Object<GDBusConnection> bus(g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error)); | ||
52 | 458 | |||
53 | 459 | if (error) | ||
54 | 460 | { | ||
55 | 461 | LOG_ERROR(logger) << "Impossible to get the session bus, to fetch the inhibitors: " << error; | ||
56 | 462 | return false; | ||
57 | 463 | } | ||
58 | 464 | |||
59 | 465 | enum class Inhibited : unsigned | ||
60 | 466 | { | ||
61 | 467 | LOGOUT = 1, | ||
62 | 468 | USER_SWITCH = 2, | ||
63 | 469 | SUSPEND = 4, | ||
64 | 470 | IDLE_SET = 8 | ||
65 | 471 | }; | ||
66 | 472 | |||
67 | 473 | glib::Variant inhibitors(g_dbus_connection_call_sync(bus, test_mode_ ? testing::DBUS_NAME.c_str() : "org.gnome.SessionManager", | ||
68 | 474 | "/org/gnome/SessionManager", "org.gnome.SessionManager", | ||
69 | 475 | "IsInhibited", g_variant_new("(u)", Inhibited::LOGOUT), nullptr, | ||
70 | 476 | G_DBUS_CALL_FLAGS_NONE, 500, nullptr, &error)); | ||
71 | 477 | |||
72 | 478 | if (error) | ||
73 | 479 | { | ||
74 | 480 | LOG_ERROR(logger) << "Impossible to get the inhibitors: " << error; | ||
75 | 481 | return false; | ||
76 | 482 | } | ||
77 | 483 | |||
78 | 484 | return inhibitors.GetBool(); | ||
79 | 485 | } | ||
80 | 486 | |||
81 | 457 | // Public implementation | 487 | // Public implementation |
82 | 458 | 488 | ||
83 | 459 | GnomeManager::GnomeManager() | 489 | GnomeManager::GnomeManager() |
84 | @@ -617,6 +647,19 @@ | |||
85 | 617 | }); | 647 | }); |
86 | 618 | } | 648 | } |
87 | 619 | 649 | ||
88 | 650 | bool GnomeManager::CanLock() const | ||
89 | 651 | { | ||
90 | 652 | glib::Object<GSettings> lockdown_settings(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str())); | ||
91 | 653 | |||
92 | 654 | if (g_settings_get_boolean(lockdown_settings, DISABLE_LOCKSCREEN_KEY.c_str()) || | ||
93 | 655 | UserName().find("guest-") == 0 || is_locked()) | ||
94 | 656 | { | ||
95 | 657 | return false; | ||
96 | 658 | } | ||
97 | 659 | |||
98 | 660 | return true; | ||
99 | 661 | } | ||
100 | 662 | |||
101 | 620 | bool GnomeManager::CanShutdown() const | 663 | bool GnomeManager::CanShutdown() const |
102 | 621 | { | 664 | { |
103 | 622 | return impl_->can_shutdown_; | 665 | return impl_->can_shutdown_; |
104 | @@ -632,6 +675,11 @@ | |||
105 | 632 | return impl_->can_hibernate_; | 675 | return impl_->can_hibernate_; |
106 | 633 | } | 676 | } |
107 | 634 | 677 | ||
108 | 678 | bool GnomeManager::HasInhibitors() const | ||
109 | 679 | { | ||
110 | 680 | return impl_->HasInhibitors(); | ||
111 | 681 | } | ||
112 | 682 | |||
113 | 635 | void GnomeManager::CancelAction() | 683 | void GnomeManager::CancelAction() |
114 | 636 | { | 684 | { |
115 | 637 | impl_->CancelAction(); | 685 | impl_->CancelAction(); |
116 | 638 | 686 | ||
117 | === modified file 'UnityCore/GnomeSessionManager.h' | |||
118 | --- UnityCore/GnomeSessionManager.h 2014-04-10 04:47:58 +0000 | |||
119 | +++ UnityCore/GnomeSessionManager.h 2014-06-18 15:11:36 +0000 | |||
120 | @@ -47,9 +47,11 @@ | |||
121 | 47 | void Suspend(); | 47 | void Suspend(); |
122 | 48 | void Hibernate(); | 48 | void Hibernate(); |
123 | 49 | 49 | ||
124 | 50 | bool CanLock() const; | ||
125 | 50 | bool CanShutdown() const; | 51 | bool CanShutdown() const; |
126 | 51 | bool CanSuspend() const; | 52 | bool CanSuspend() const; |
127 | 52 | bool CanHibernate() const; | 53 | bool CanHibernate() const; |
128 | 54 | bool HasInhibitors() const; | ||
129 | 53 | 55 | ||
130 | 54 | void CancelAction(); | 56 | void CancelAction(); |
131 | 55 | 57 | ||
132 | 56 | 58 | ||
133 | === modified file 'UnityCore/GnomeSessionManagerImpl.h' | |||
134 | --- UnityCore/GnomeSessionManagerImpl.h 2014-04-16 21:51:45 +0000 | |||
135 | +++ UnityCore/GnomeSessionManagerImpl.h 2014-06-18 15:11:36 +0000 | |||
136 | @@ -51,6 +51,7 @@ | |||
137 | 51 | void ConfirmShutdown(); | 51 | void ConfirmShutdown(); |
138 | 52 | void CancelAction(); | 52 | void CancelAction(); |
139 | 53 | void ClosedDialog(); | 53 | void ClosedDialog(); |
140 | 54 | bool HasInhibitors(); | ||
141 | 54 | void EnsureCancelPendingAction(); | 55 | void EnsureCancelPendingAction(); |
142 | 55 | void LockScreen(bool prompt); | 56 | void LockScreen(bool prompt); |
143 | 56 | 57 | ||
144 | 57 | 58 | ||
145 | === modified file 'UnityCore/SessionManager.h' | |||
146 | --- UnityCore/SessionManager.h 2014-04-16 21:51:45 +0000 | |||
147 | +++ UnityCore/SessionManager.h 2014-06-18 15:11:36 +0000 | |||
148 | @@ -39,6 +39,7 @@ | |||
149 | 39 | virtual ~Manager() = default; | 39 | virtual ~Manager() = default; |
150 | 40 | 40 | ||
151 | 41 | nux::ROProperty<bool> have_other_open_sessions; | 41 | nux::ROProperty<bool> have_other_open_sessions; |
152 | 42 | nux::Property<bool> is_locked; | ||
153 | 42 | 43 | ||
154 | 43 | virtual std::string RealName() const = 0; | 44 | virtual std::string RealName() const = 0; |
155 | 44 | virtual std::string UserName() const = 0; | 45 | virtual std::string UserName() const = 0; |
156 | @@ -54,9 +55,11 @@ | |||
157 | 54 | virtual void Suspend() = 0; | 55 | virtual void Suspend() = 0; |
158 | 55 | virtual void Hibernate() = 0; | 56 | virtual void Hibernate() = 0; |
159 | 56 | 57 | ||
160 | 58 | virtual bool CanLock() const = 0; | ||
161 | 57 | virtual bool CanShutdown() const = 0; | 59 | virtual bool CanShutdown() const = 0; |
162 | 58 | virtual bool CanSuspend() const = 0; | 60 | virtual bool CanSuspend() const = 0; |
163 | 59 | virtual bool CanHibernate() const = 0; | 61 | virtual bool CanHibernate() const = 0; |
164 | 62 | virtual bool HasInhibitors() const = 0; | ||
165 | 60 | 63 | ||
166 | 61 | virtual void CancelAction() = 0; | 64 | virtual void CancelAction() = 0; |
167 | 62 | 65 | ||
168 | 63 | 66 | ||
169 | === modified file 'lockscreen/LockScreenAcceleratorController.cpp' | |||
170 | --- lockscreen/LockScreenAcceleratorController.cpp 2014-04-28 13:09:53 +0000 | |||
171 | +++ lockscreen/LockScreenAcceleratorController.cpp 2014-06-18 15:11:36 +0000 | |||
172 | @@ -32,6 +32,17 @@ | |||
173 | 32 | const char* const MEDIA_KEYS_KEY_VOLUME_MUTE = "volume-mute"; | 32 | const char* const MEDIA_KEYS_KEY_VOLUME_MUTE = "volume-mute"; |
174 | 33 | const char* const MEDIA_KEYS_KEY_VOLUME_DOWN = "volume-down"; | 33 | const char* const MEDIA_KEYS_KEY_VOLUME_DOWN = "volume-down"; |
175 | 34 | const char* const MEDIA_KEYS_KEY_VOLUME_UP = "volume-up"; | 34 | const char* const MEDIA_KEYS_KEY_VOLUME_UP = "volume-up"; |
176 | 35 | |||
177 | 36 | const char* const POWER_SCHEMA = "org.gnome.settings-daemon.plugins.power"; | ||
178 | 37 | const char* const SUSPEND_BUTTON_ACTION_KEY = "button-suspend"; | ||
179 | 38 | const char* const SLEEP_BUTTON_ACTION_KEY = "button-sleep"; | ||
180 | 39 | const char* const HIBERNATE_BUTTON_ACTION_KEY = "button-hibernate"; | ||
181 | 40 | const char* const POWER_BUTTON_ACTION_KEY = "button-power"; | ||
182 | 41 | const char* const POWER_KEY_SUSPEND = "XF86Suspend"; | ||
183 | 42 | const char* const POWER_KEY_SLEEP = "XF86Sleep"; | ||
184 | 43 | const char* const POWER_KEY_HIBERNATE = "XF86Hibernate"; | ||
185 | 44 | const char* const POWER_KEY_POWEROFF = "XF86PowerOff"; | ||
186 | 45 | |||
187 | 35 | const char* const INPUT_SWITCH_SCHEMA = "org.gnome.desktop.wm.keybindings"; | 46 | const char* const INPUT_SWITCH_SCHEMA = "org.gnome.desktop.wm.keybindings"; |
188 | 36 | const char* const INPUT_SWITCH_KEY_PREVIOUS_SOURCE = "switch-input-source-backward"; | 47 | const char* const INPUT_SWITCH_KEY_PREVIOUS_SOURCE = "switch-input-source-backward"; |
189 | 37 | const char* const INPUT_SWITCH_KEY_NEXT_SOURCE = "switch-input-source"; | 48 | const char* const INPUT_SWITCH_KEY_NEXT_SOURCE = "switch-input-source"; |
190 | @@ -89,15 +100,32 @@ | |||
191 | 89 | INDICATOR_KEYBOARD_ACTION_SCROLL, | 100 | INDICATOR_KEYBOARD_ACTION_SCROLL, |
192 | 90 | g_variant_new_int32(-offset)); | 101 | g_variant_new_int32(-offset)); |
193 | 91 | } | 102 | } |
194 | 103 | |||
195 | 104 | void PowerAction(session::Manager::Ptr const& session, const char *action_key) | ||
196 | 105 | { | ||
197 | 106 | glib::Object<GSettings> settings(g_settings_new(POWER_SCHEMA)); | ||
198 | 107 | auto const& action = glib::String(g_settings_get_string(settings, action_key)).Str(); | ||
199 | 108 | |||
200 | 109 | if (action == "interactive") | ||
201 | 110 | session->shutdown_requested.emit(session->HasInhibitors()); | ||
202 | 111 | else if (action == "shutdown") | ||
203 | 112 | session->reboot_requested.emit(session->HasInhibitors()); | ||
204 | 113 | else if (action == "suspend") | ||
205 | 114 | session->Suspend(); | ||
206 | 115 | else if (action == "hibernate") | ||
207 | 116 | session->Hibernate(); | ||
208 | 117 | else if (action == "blank") | ||
209 | 118 | session->ScreenSaverActivate(); | ||
210 | 119 | } | ||
211 | 92 | } // namespace | 120 | } // namespace |
212 | 93 | 121 | ||
214 | 94 | AcceleratorController::AcceleratorController() | 122 | AcceleratorController::AcceleratorController(session::Manager::Ptr const& session) |
215 | 95 | : accelerators_(new Accelerators) | 123 | : accelerators_(new Accelerators) |
216 | 96 | { | 124 | { |
217 | 97 | auto settings = glib::Object<GSettings>(g_settings_new(MEDIA_KEYS_SCHEMA)); | 125 | auto settings = glib::Object<GSettings>(g_settings_new(MEDIA_KEYS_SCHEMA)); |
218 | 98 | 126 | ||
219 | 99 | auto accelerator = std::make_shared<Accelerator>(glib::String(g_settings_get_string(settings, MEDIA_KEYS_KEY_VOLUME_MUTE))); | 127 | auto accelerator = std::make_shared<Accelerator>(glib::String(g_settings_get_string(settings, MEDIA_KEYS_KEY_VOLUME_MUTE))); |
221 | 100 | accelerator->activated.connect(std::function<void ()>(MuteIndicatorSound)); | 128 | accelerator->activated.connect(std::function<void()>(MuteIndicatorSound)); |
222 | 101 | accelerators_->Add(accelerator); | 129 | accelerators_->Add(accelerator); |
223 | 102 | 130 | ||
224 | 103 | accelerator = std::make_shared<Accelerator>(glib::String(g_settings_get_string(settings, MEDIA_KEYS_KEY_VOLUME_DOWN))); | 131 | accelerator = std::make_shared<Accelerator>(glib::String(g_settings_get_string(settings, MEDIA_KEYS_KEY_VOLUME_DOWN))); |
225 | @@ -108,6 +136,22 @@ | |||
226 | 108 | accelerator->activated.connect(std::bind(ScrollIndicatorSound, +1)); | 136 | accelerator->activated.connect(std::bind(ScrollIndicatorSound, +1)); |
227 | 109 | accelerators_->Add(accelerator); | 137 | accelerators_->Add(accelerator); |
228 | 110 | 138 | ||
229 | 139 | accelerator = std::make_shared<Accelerator>(POWER_KEY_SUSPEND); | ||
230 | 140 | accelerator->activated.connect(std::bind(PowerAction, session, SUSPEND_BUTTON_ACTION_KEY)); | ||
231 | 141 | accelerators_->Add(accelerator); | ||
232 | 142 | |||
233 | 143 | accelerator = std::make_shared<Accelerator>(POWER_KEY_SLEEP); | ||
234 | 144 | accelerator->activated.connect(std::bind(PowerAction, session, SLEEP_BUTTON_ACTION_KEY)); | ||
235 | 145 | accelerators_->Add(accelerator); | ||
236 | 146 | |||
237 | 147 | accelerator = std::make_shared<Accelerator>(POWER_KEY_HIBERNATE); | ||
238 | 148 | accelerator->activated.connect(std::bind(PowerAction, session, HIBERNATE_BUTTON_ACTION_KEY)); | ||
239 | 149 | accelerators_->Add(accelerator); | ||
240 | 150 | |||
241 | 151 | accelerator = std::make_shared<Accelerator>(POWER_KEY_POWEROFF); | ||
242 | 152 | accelerator->activated.connect(std::bind(PowerAction, session, POWER_BUTTON_ACTION_KEY)); | ||
243 | 153 | accelerators_->Add(accelerator); | ||
244 | 154 | |||
245 | 111 | settings = glib::Object<GSettings>(g_settings_new(INPUT_SWITCH_SCHEMA)); | 155 | settings = glib::Object<GSettings>(g_settings_new(INPUT_SWITCH_SCHEMA)); |
246 | 112 | 156 | ||
247 | 113 | auto variant = glib::Variant(g_settings_get_value(settings, INPUT_SWITCH_KEY_PREVIOUS_SOURCE), glib::StealRef()); | 157 | auto variant = glib::Variant(g_settings_get_value(settings, INPUT_SWITCH_KEY_PREVIOUS_SOURCE), glib::StealRef()); |
248 | 114 | 158 | ||
249 | === modified file 'lockscreen/LockScreenAcceleratorController.h' | |||
250 | --- lockscreen/LockScreenAcceleratorController.h 2014-04-28 13:09:53 +0000 | |||
251 | +++ lockscreen/LockScreenAcceleratorController.h 2014-06-18 15:11:36 +0000 | |||
252 | @@ -20,6 +20,7 @@ | |||
253 | 20 | #ifndef UNITY_LOCKSCREEN_ACCELERATOR_CONTROLLER | 20 | #ifndef UNITY_LOCKSCREEN_ACCELERATOR_CONTROLLER |
254 | 21 | #define UNITY_LOCKSCREEN_ACCELERATOR_CONTROLLER | 21 | #define UNITY_LOCKSCREEN_ACCELERATOR_CONTROLLER |
255 | 22 | 22 | ||
256 | 23 | #include <UnityCore/SessionManager.h> | ||
257 | 23 | #include "LockScreenAccelerators.h" | 24 | #include "LockScreenAccelerators.h" |
258 | 24 | 25 | ||
259 | 25 | namespace unity | 26 | namespace unity |
260 | @@ -32,7 +33,7 @@ | |||
261 | 32 | public: | 33 | public: |
262 | 33 | typedef std::shared_ptr<AcceleratorController> Ptr; | 34 | typedef std::shared_ptr<AcceleratorController> Ptr; |
263 | 34 | 35 | ||
265 | 35 | AcceleratorController(); | 36 | AcceleratorController(session::Manager::Ptr const&); |
266 | 36 | 37 | ||
267 | 37 | Accelerators::Ptr const& GetAccelerators() const; | 38 | Accelerators::Ptr const& GetAccelerators() const; |
268 | 38 | 39 | ||
269 | 39 | 40 | ||
270 | === modified file 'lockscreen/LockScreenController.cpp' | |||
271 | --- lockscreen/LockScreenController.cpp 2014-06-07 16:26:59 +0000 | |||
272 | +++ lockscreen/LockScreenController.cpp 2014-06-18 15:11:36 +0000 | |||
273 | @@ -104,7 +104,7 @@ | |||
274 | 104 | key_connection_->disconnect(); | 104 | key_connection_->disconnect(); |
275 | 105 | uscreen_connection_->block(); | 105 | uscreen_connection_->block(); |
276 | 106 | hidden_window_connection_->block(); | 106 | hidden_window_connection_->block(); |
278 | 107 | session_manager_->unlocked.emit(); | 107 | session_manager_->is_locked = false; |
279 | 108 | 108 | ||
280 | 109 | std::for_each(shields_.begin(), shields_.end(), [](nux::ObjectPtr<Shield> const& shield) { | 109 | std::for_each(shields_.begin(), shields_.end(), [](nux::ObjectPtr<Shield> const& shield) { |
281 | 110 | shield->RemoveLayout(); | 110 | shield->RemoveLayout(); |
282 | @@ -342,7 +342,7 @@ | |||
283 | 342 | HideBlankWindow(); | 342 | HideBlankWindow(); |
284 | 343 | 343 | ||
285 | 344 | LockScreen(); | 344 | LockScreen(); |
287 | 345 | session_manager_->locked.emit(); | 345 | session_manager_->is_locked = true; |
288 | 346 | 346 | ||
289 | 347 | if (prompt_activation_) | 347 | if (prompt_activation_) |
290 | 348 | { | 348 | { |
291 | @@ -403,7 +403,7 @@ | |||
292 | 403 | indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>(); | 403 | indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>(); |
293 | 404 | upstart_wrapper_->Emit("desktop-lock"); | 404 | upstart_wrapper_->Emit("desktop-lock"); |
294 | 405 | 405 | ||
296 | 406 | accelerator_controller_ = std::make_shared<AcceleratorController>(); | 406 | accelerator_controller_ = std::make_shared<AcceleratorController>(session_manager_); |
297 | 407 | auto activate_key = WindowManager::Default().activate_indicators_key(); | 407 | auto activate_key = WindowManager::Default().activate_indicators_key(); |
298 | 408 | auto accelerator = std::make_shared<Accelerator>(activate_key.second, 0, activate_key.first); | 408 | auto accelerator = std::make_shared<Accelerator>(activate_key.second, 0, activate_key.first); |
299 | 409 | accelerator->activated.connect(std::bind(std::mem_fn(&Controller::ActivatePanel), this)); | 409 | accelerator->activated.connect(std::bind(std::mem_fn(&Controller::ActivatePanel), this)); |
300 | 410 | 410 | ||
301 | === modified file 'shutdown/SessionDBusManager.cpp' | |||
302 | --- shutdown/SessionDBusManager.cpp 2014-04-10 04:47:58 +0000 | |||
303 | +++ shutdown/SessionDBusManager.cpp 2014-06-18 15:11:36 +0000 | |||
304 | @@ -53,14 +53,20 @@ | |||
305 | 53 | <method name="Suspend" /> | 53 | <method name="Suspend" /> |
306 | 54 | <method name="Hibernate" /> | 54 | <method name="Hibernate" /> |
307 | 55 | <method name="CancelAction" /> | 55 | <method name="CancelAction" /> |
308 | 56 | <method name="IsLocked"> | ||
309 | 57 | <arg type="b" direction="out" name="is_locked" /> | ||
310 | 58 | </method> | ||
311 | 59 | <method name="CanLock"> | ||
312 | 60 | <arg type="b" direction="out" name="can_lock" /> | ||
313 | 61 | </method> | ||
314 | 56 | <method name="CanShutdown"> | 62 | <method name="CanShutdown"> |
316 | 57 | <arg type="b" direction="out" name="canshutdown" /> | 63 | <arg type="b" direction="out" name="can_shutdown" /> |
317 | 58 | </method> | 64 | </method> |
318 | 59 | <method name="CanSuspend"> | 65 | <method name="CanSuspend"> |
320 | 60 | <arg type="b" direction="out" name="cansuspend" /> | 66 | <arg type="b" direction="out" name="can_suspend" /> |
321 | 61 | </method> | 67 | </method> |
322 | 62 | <method name="CanHibernate"> | 68 | <method name="CanHibernate"> |
324 | 63 | <arg type="b" direction="out" name="canhibernate" /> | 69 | <arg type="b" direction="out" name="can_hibernate" /> |
325 | 64 | </method> | 70 | </method> |
326 | 65 | 71 | ||
327 | 66 | <signal name="LockRequested" /> | 72 | <signal name="LockRequested" /> |
328 | @@ -121,7 +127,7 @@ | |||
329 | 121 | } | 127 | } |
330 | 122 | else if (method == "RequestLogout") | 128 | else if (method == "RequestLogout") |
331 | 123 | { | 129 | { |
333 | 124 | session_->logout_requested.emit(false); | 130 | session_->logout_requested.emit(session_->HasInhibitors()); |
334 | 125 | } | 131 | } |
335 | 126 | else if (method == "Reboot") | 132 | else if (method == "Reboot") |
336 | 127 | { | 133 | { |
337 | @@ -129,7 +135,7 @@ | |||
338 | 129 | } | 135 | } |
339 | 130 | else if (method == "RequestReboot") | 136 | else if (method == "RequestReboot") |
340 | 131 | { | 137 | { |
342 | 132 | session_->reboot_requested.emit(false); | 138 | session_->reboot_requested.emit(session_->HasInhibitors()); |
343 | 133 | } | 139 | } |
344 | 134 | else if (method == "Shutdown") | 140 | else if (method == "Shutdown") |
345 | 135 | { | 141 | { |
346 | @@ -137,7 +143,7 @@ | |||
347 | 137 | } | 143 | } |
348 | 138 | else if (method == "RequestShutdown") | 144 | else if (method == "RequestShutdown") |
349 | 139 | { | 145 | { |
351 | 140 | session_->shutdown_requested.emit(false); | 146 | session_->shutdown_requested.emit(session_->HasInhibitors()); |
352 | 141 | } | 147 | } |
353 | 142 | else if (method == "Suspend") | 148 | else if (method == "Suspend") |
354 | 143 | { | 149 | { |
355 | @@ -152,17 +158,25 @@ | |||
356 | 152 | session_->CancelAction(); | 158 | session_->CancelAction(); |
357 | 153 | session_->cancel_requested.emit(); | 159 | session_->cancel_requested.emit(); |
358 | 154 | } | 160 | } |
359 | 161 | else if (method == "IsLocked") | ||
360 | 162 | { | ||
361 | 163 | return g_variant_new("(b)", session_->is_locked() != false); | ||
362 | 164 | } | ||
363 | 165 | else if (method == "CanLock") | ||
364 | 166 | { | ||
365 | 167 | return g_variant_new("(b)", session_->CanLock() != false); | ||
366 | 168 | } | ||
367 | 155 | else if (method == "CanShutdown") | 169 | else if (method == "CanShutdown") |
368 | 156 | { | 170 | { |
370 | 157 | return g_variant_new("(b)", session_->CanShutdown() != FALSE); | 171 | return g_variant_new("(b)", session_->CanShutdown() != false); |
371 | 158 | } | 172 | } |
372 | 159 | else if (method == "CanSuspend") | 173 | else if (method == "CanSuspend") |
373 | 160 | { | 174 | { |
375 | 161 | return g_variant_new("(b)", session_->CanSuspend() != FALSE); | 175 | return g_variant_new("(b)", session_->CanSuspend() != false); |
376 | 162 | } | 176 | } |
377 | 163 | else if (method == "CanHibernate") | 177 | else if (method == "CanHibernate") |
378 | 164 | { | 178 | { |
380 | 165 | return g_variant_new("(b)", session_->CanHibernate() != FALSE); | 179 | return g_variant_new("(b)", session_->CanHibernate() != false); |
381 | 166 | } | 180 | } |
382 | 167 | 181 | ||
383 | 168 | return nullptr; | 182 | return nullptr; |
384 | 169 | 183 | ||
385 | === modified file 'shutdown/SessionView.cpp' | |||
386 | --- shutdown/SessionView.cpp 2014-06-07 16:26:41 +0000 | |||
387 | +++ shutdown/SessionView.cpp 2014-06-18 15:11:36 +0000 | |||
388 | @@ -91,16 +91,17 @@ | |||
389 | 91 | return false; | 91 | return false; |
390 | 92 | }); | 92 | }); |
391 | 93 | 93 | ||
397 | 94 | mode.changed.connect([this] (Mode m) { | 94 | mode.changed.connect(sigc::hide(sigc::mem_fun(this, &View::UpdateContents))); |
393 | 95 | UpdateText(); | ||
394 | 96 | Populate(); | ||
395 | 97 | }); | ||
396 | 98 | |||
398 | 99 | scale.changed.connect(sigc::hide(sigc::mem_fun(this, &View::UpdateViewSize))); | 95 | scale.changed.connect(sigc::hide(sigc::mem_fun(this, &View::UpdateViewSize))); |
399 | 96 | UpdateContents(); | ||
400 | 97 | } | ||
401 | 100 | 98 | ||
402 | 99 | void View::UpdateContents() | ||
403 | 100 | { | ||
404 | 101 | SetVisible(true); | ||
405 | 102 | PopulateButtons(); | ||
406 | 103 | UpdateText(); | ||
407 | 101 | UpdateViewSize(); | 104 | UpdateViewSize(); |
408 | 102 | UpdateText(); | ||
409 | 103 | Populate(); | ||
410 | 104 | } | 105 | } |
411 | 105 | 106 | ||
412 | 106 | void View::UpdateViewSize() | 107 | void View::UpdateViewSize() |
413 | @@ -115,11 +116,17 @@ | |||
414 | 115 | ReloadCloseButtonTexture(); | 116 | ReloadCloseButtonTexture(); |
415 | 116 | 117 | ||
416 | 117 | buttons_layout_->SetSpaceBetweenChildren(style::BUTTONS_SPACE.CP(scale())); | 118 | buttons_layout_->SetSpaceBetweenChildren(style::BUTTONS_SPACE.CP(scale())); |
419 | 118 | 119 | auto const& buttons = buttons_layout_->GetChildren(); | |
420 | 119 | for (auto* area : buttons_layout_->GetChildren()) | 120 | |
421 | 121 | for (auto* area : buttons) | ||
422 | 122 | static_cast<Button*>(area)->scale = scale(); | ||
423 | 123 | |||
424 | 124 | if (buttons.size() == 1) | ||
425 | 120 | { | 125 | { |
428 | 121 | auto* button = static_cast<Button*>(area); | 126 | auto* button = buttons.front(); |
429 | 122 | button->scale = scale(); | 127 | button->ComputeContentSize(); |
430 | 128 | int padding = button->GetWidth()/2 + style::MAIN_SPACE.CP(scale())/2; | ||
431 | 129 | buttons_layout_->SetLeftAndRightPadding(padding, padding); | ||
432 | 123 | } | 130 | } |
433 | 124 | } | 131 | } |
434 | 125 | 132 | ||
435 | @@ -201,20 +208,26 @@ | |||
436 | 201 | subtitle_->SetText(glib::String(g_strdup_printf(message.c_str(), name.c_str())).Str()); | 208 | subtitle_->SetText(glib::String(g_strdup_printf(message.c_str(), name.c_str())).Str()); |
437 | 202 | } | 209 | } |
438 | 203 | 210 | ||
440 | 204 | void View::Populate() | 211 | void View::PopulateButtons() |
441 | 205 | { | 212 | { |
442 | 206 | debug::Introspectable::RemoveAllChildren(); | 213 | debug::Introspectable::RemoveAllChildren(); |
443 | 207 | buttons_layout_->Clear(); | 214 | buttons_layout_->Clear(); |
444 | 215 | buttons_layout_->SetLeftAndRightPadding(0, 0); | ||
445 | 208 | key_focus_area_ = this; | 216 | key_focus_area_ = this; |
446 | 209 | 217 | ||
447 | 210 | if (mode() == Mode::LOGOUT) | 218 | if (mode() == Mode::LOGOUT) |
448 | 211 | { | 219 | { |
455 | 212 | auto* button = new Button(Button::Action::LOCK, NUX_TRACKER_LOCATION); | 220 | if (manager_->is_locked()) |
456 | 213 | button->scale = scale(); | 221 | return; |
457 | 214 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::LockScreen)); | 222 | |
458 | 215 | AddButton(button); | 223 | if (manager_->CanLock()) |
459 | 216 | 224 | { | |
460 | 217 | button = new Button(Button::Action::LOGOUT, NUX_TRACKER_LOCATION); | 225 | auto* button = new Button(Button::Action::LOCK, NUX_TRACKER_LOCATION); |
461 | 226 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::LockScreen)); | ||
462 | 227 | AddButton(button); | ||
463 | 228 | } | ||
464 | 229 | |||
465 | 230 | auto* button = new Button(Button::Action::LOGOUT, NUX_TRACKER_LOCATION); | ||
466 | 218 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Logout)); | 231 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Logout)); |
467 | 219 | key_focus_area_ = button; | 232 | key_focus_area_ = button; |
468 | 220 | AddButton(button); | 233 | AddButton(button); |
469 | @@ -223,23 +236,23 @@ | |||
470 | 223 | { | 236 | { |
471 | 224 | if (mode() == Mode::FULL) | 237 | if (mode() == Mode::FULL) |
472 | 225 | { | 238 | { |
477 | 226 | auto* button = new Button(Button::Action::LOCK, NUX_TRACKER_LOCATION); | 239 | if (manager_->CanLock()) |
478 | 227 | button->scale = scale(); | 240 | { |
479 | 228 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::LockScreen)); | 241 | auto* button = new Button(Button::Action::LOCK, NUX_TRACKER_LOCATION); |
480 | 229 | AddButton(button); | 242 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::LockScreen)); |
481 | 243 | AddButton(button); | ||
482 | 244 | } | ||
483 | 230 | 245 | ||
484 | 231 | if (manager_->CanSuspend()) | 246 | if (manager_->CanSuspend()) |
485 | 232 | { | 247 | { |
488 | 233 | button = new Button(Button::Action::SUSPEND, NUX_TRACKER_LOCATION); | 248 | auto* button = new Button(Button::Action::SUSPEND, NUX_TRACKER_LOCATION); |
487 | 234 | button->scale = scale(); | ||
489 | 235 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Suspend)); | 249 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Suspend)); |
490 | 236 | AddButton(button); | 250 | AddButton(button); |
491 | 237 | } | 251 | } |
492 | 238 | 252 | ||
493 | 239 | if (manager_->CanHibernate()) | 253 | if (manager_->CanHibernate()) |
494 | 240 | { | 254 | { |
497 | 241 | button = new Button(Button::Action::HIBERNATE, NUX_TRACKER_LOCATION); | 255 | auto* button = new Button(Button::Action::HIBERNATE, NUX_TRACKER_LOCATION); |
496 | 242 | button->scale = scale(); | ||
498 | 243 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Hibernate)); | 256 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Hibernate)); |
499 | 244 | AddButton(button); | 257 | AddButton(button); |
500 | 245 | } | 258 | } |
501 | @@ -248,28 +261,34 @@ | |||
502 | 248 | if (manager_->CanShutdown()) | 261 | if (manager_->CanShutdown()) |
503 | 249 | { | 262 | { |
504 | 250 | auto *button = new Button(Button::Action::REBOOT, NUX_TRACKER_LOCATION); | 263 | auto *button = new Button(Button::Action::REBOOT, NUX_TRACKER_LOCATION); |
505 | 251 | button->scale = scale(); | ||
506 | 252 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Reboot)); | 264 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Reboot)); |
507 | 253 | AddButton(button); | 265 | AddButton(button); |
508 | 254 | 266 | ||
509 | 255 | button = new Button(Button::Action::SHUTDOWN, NUX_TRACKER_LOCATION); | 267 | button = new Button(Button::Action::SHUTDOWN, NUX_TRACKER_LOCATION); |
510 | 256 | button->scale = scale(); | ||
511 | 257 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Shutdown)); | 268 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Shutdown)); |
512 | 258 | key_focus_area_ = (mode() == Mode::SHUTDOWN) ? button : key_focus_area_; | 269 | key_focus_area_ = (mode() == Mode::SHUTDOWN) ? button : key_focus_area_; |
513 | 259 | AddButton(button); | 270 | AddButton(button); |
514 | 260 | } | 271 | } |
516 | 261 | else if (mode() == Mode::FULL) | 272 | else if (mode() == Mode::FULL && !manager_->is_locked()) |
517 | 262 | { | 273 | { |
518 | 263 | auto* button = new Button(Button::Action::LOGOUT, NUX_TRACKER_LOCATION); | 274 | auto* button = new Button(Button::Action::LOGOUT, NUX_TRACKER_LOCATION); |
519 | 264 | button->scale = scale(); | ||
520 | 265 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Logout)); | 275 | button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Logout)); |
521 | 266 | AddButton(button); | 276 | AddButton(button); |
522 | 267 | } | 277 | } |
523 | 268 | } | 278 | } |
524 | 279 | |||
525 | 280 | cancel_idle_.reset(); | ||
526 | 281 | if (buttons_layout_->GetChildren().empty()) | ||
527 | 282 | { | ||
528 | 283 | // There's nothing to show here, let's cancel the action and hide | ||
529 | 284 | SetVisible(false); | ||
530 | 285 | cancel_idle_.reset(new glib::Idle([this] { request_close.emit(); return false; })); | ||
531 | 286 | } | ||
532 | 269 | } | 287 | } |
533 | 270 | 288 | ||
534 | 271 | void View::AddButton(Button* button) | 289 | void View::AddButton(Button* button) |
535 | 272 | { | 290 | { |
536 | 291 | button->scale = scale(); | ||
537 | 273 | button->activated.connect([this] {request_hide.emit();}); | 292 | button->activated.connect([this] {request_hide.emit();}); |
538 | 274 | buttons_layout_->AddView(button); | 293 | buttons_layout_->AddView(button); |
539 | 275 | debug::Introspectable::AddChild(button); | 294 | debug::Introspectable::AddChild(button); |
540 | 276 | 295 | ||
541 | === modified file 'shutdown/SessionView.h' | |||
542 | --- shutdown/SessionView.h 2014-04-25 18:12:48 +0000 | |||
543 | +++ shutdown/SessionView.h 2014-06-18 15:11:36 +0000 | |||
544 | @@ -25,10 +25,10 @@ | |||
545 | 25 | #include <Nux/VLayout.h> | 25 | #include <Nux/VLayout.h> |
546 | 26 | #include <Nux/HLayout.h> | 26 | #include <Nux/HLayout.h> |
547 | 27 | 27 | ||
549 | 28 | #include "UnityCore/SessionManager.h" | 28 | #include <UnityCore/GLibSource.h> |
550 | 29 | #include <UnityCore/SessionManager.h> | ||
551 | 29 | #include "unity-shared/EMConverter.h" | 30 | #include "unity-shared/EMConverter.h" |
552 | 30 | #include "unity-shared/UnityWindowView.h" | 31 | #include "unity-shared/UnityWindowView.h" |
553 | 31 | #include "UnityCore/SessionManager.h" | ||
554 | 32 | 32 | ||
555 | 33 | namespace unity | 33 | namespace unity |
556 | 34 | { | 34 | { |
557 | @@ -73,10 +73,10 @@ | |||
558 | 73 | private: | 73 | private: |
559 | 74 | friend class TestSessionView; | 74 | friend class TestSessionView; |
560 | 75 | 75 | ||
561 | 76 | void PopulateButtons(); | ||
562 | 77 | void UpdateText(); | ||
563 | 78 | void UpdateContents(); | ||
564 | 76 | void UpdateViewSize(); | 79 | void UpdateViewSize(); |
565 | 77 | |||
566 | 78 | void UpdateText(); | ||
567 | 79 | void Populate(); | ||
568 | 80 | void AddButton(Button*); | 80 | void AddButton(Button*); |
569 | 81 | 81 | ||
570 | 82 | Manager::Ptr manager_; | 82 | Manager::Ptr manager_; |
571 | @@ -85,6 +85,7 @@ | |||
572 | 85 | nux::VLayout* main_layout_; | 85 | nux::VLayout* main_layout_; |
573 | 86 | nux::HLayout* buttons_layout_; | 86 | nux::HLayout* buttons_layout_; |
574 | 87 | nux::InputArea* key_focus_area_; | 87 | nux::InputArea* key_focus_area_; |
575 | 88 | glib::Source::UniquePtr cancel_idle_; | ||
576 | 88 | }; | 89 | }; |
577 | 89 | 90 | ||
578 | 90 | } // namespace session | 91 | } // namespace session |
579 | 91 | 92 | ||
580 | === modified file 'shutdown/StandaloneSession.cpp' | |||
581 | --- shutdown/StandaloneSession.cpp 2014-04-10 04:47:58 +0000 | |||
582 | +++ shutdown/StandaloneSession.cpp 2014-06-18 15:11:36 +0000 | |||
583 | @@ -52,9 +52,11 @@ | |||
584 | 52 | 52 | ||
585 | 53 | void CancelAction() { std::cout << "CancelAction" << std::endl; } | 53 | void CancelAction() { std::cout << "CancelAction" << std::endl; } |
586 | 54 | 54 | ||
587 | 55 | bool CanLock() const {return true;} | ||
588 | 55 | bool CanShutdown() const {return true;} | 56 | bool CanShutdown() const {return true;} |
589 | 56 | bool CanSuspend() const {return true;} | 57 | bool CanSuspend() const {return true;} |
590 | 57 | bool CanHibernate() const {return true;} | 58 | bool CanHibernate() const {return true;} |
591 | 59 | bool HasInhibitors() const {return false;} | ||
592 | 58 | }; | 60 | }; |
593 | 59 | 61 | ||
594 | 60 | struct SessionWindow | 62 | struct SessionWindow |
595 | 61 | 63 | ||
596 | === modified file 'tests/test_mock_session_manager.h' | |||
597 | --- tests/test_mock_session_manager.h 2014-04-10 04:47:58 +0000 | |||
598 | +++ tests/test_mock_session_manager.h 2014-06-18 15:11:36 +0000 | |||
599 | @@ -44,9 +44,11 @@ | |||
600 | 44 | MOCK_METHOD0(Hibernate, void()); | 44 | MOCK_METHOD0(Hibernate, void()); |
601 | 45 | MOCK_METHOD0(CancelAction, void()); | 45 | MOCK_METHOD0(CancelAction, void()); |
602 | 46 | 46 | ||
603 | 47 | MOCK_CONST_METHOD0(CanLock, bool()); | ||
604 | 47 | MOCK_CONST_METHOD0(CanShutdown, bool()); | 48 | MOCK_CONST_METHOD0(CanShutdown, bool()); |
605 | 48 | MOCK_CONST_METHOD0(CanSuspend, bool()); | 49 | MOCK_CONST_METHOD0(CanSuspend, bool()); |
606 | 49 | MOCK_CONST_METHOD0(CanHibernate, bool()); | 50 | MOCK_CONST_METHOD0(CanHibernate, bool()); |
607 | 51 | MOCK_CONST_METHOD0(HasInhibitors, bool()); | ||
608 | 50 | }; | 52 | }; |
609 | 51 | 53 | ||
610 | 52 | } // session | 54 | } // session |
611 | 53 | 55 | ||
612 | === modified file 'tests/test_session_controller.cpp' | |||
613 | --- tests/test_session_controller.cpp 2014-04-30 15:33:43 +0000 | |||
614 | +++ tests/test_session_controller.cpp 2014-06-18 15:11:36 +0000 | |||
615 | @@ -41,6 +41,7 @@ | |||
616 | 41 | , manager(std::make_shared<testing::NiceMock<MockManager>>()) | 41 | , manager(std::make_shared<testing::NiceMock<MockManager>>()) |
617 | 42 | , controller(manager) | 42 | , controller(manager) |
618 | 43 | { | 43 | { |
619 | 44 | ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(true)); | ||
620 | 44 | ON_CALL(*manager, CanShutdown()).WillByDefault(testing::Return(true)); | 45 | ON_CALL(*manager, CanShutdown()).WillByDefault(testing::Return(true)); |
621 | 45 | } | 46 | } |
622 | 46 | 47 | ||
623 | 47 | 48 | ||
624 | === modified file 'tests/test_session_view.cpp' | |||
625 | --- tests/test_session_view.cpp 2014-03-21 04:40:12 +0000 | |||
626 | +++ tests/test_session_view.cpp 2014-06-18 15:11:36 +0000 | |||
627 | @@ -137,6 +137,7 @@ | |||
628 | 137 | 137 | ||
629 | 138 | TEST_F(TestSessionView, FullModeButtons) | 138 | TEST_F(TestSessionView, FullModeButtons) |
630 | 139 | { | 139 | { |
631 | 140 | ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(true)); | ||
632 | 140 | ON_CALL(*manager, CanShutdown()).WillByDefault(testing::Return(true)); | 141 | ON_CALL(*manager, CanShutdown()).WillByDefault(testing::Return(true)); |
633 | 141 | ON_CALL(*manager, CanSuspend()).WillByDefault(testing::Return(true)); | 142 | ON_CALL(*manager, CanSuspend()).WillByDefault(testing::Return(true)); |
634 | 142 | ON_CALL(*manager, CanHibernate()).WillByDefault(testing::Return(true)); | 143 | ON_CALL(*manager, CanHibernate()).WillByDefault(testing::Return(true)); |
635 | @@ -166,6 +167,11 @@ | |||
636 | 166 | view.mode.changed.emit(View::Mode::FULL); | 167 | view.mode.changed.emit(View::Mode::FULL); |
637 | 167 | 168 | ||
638 | 168 | EXPECT_EQ(view.GetButtonByAction(Button::Action::HIBERNATE), nullptr); | 169 | EXPECT_EQ(view.GetButtonByAction(Button::Action::HIBERNATE), nullptr); |
639 | 170 | |||
640 | 171 | ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(false)); | ||
641 | 172 | view.mode.changed.emit(View::Mode::FULL); | ||
642 | 173 | |||
643 | 174 | EXPECT_EQ(view.GetButtonByAction(Button::Action::LOCK), nullptr); | ||
644 | 169 | } | 175 | } |
645 | 170 | 176 | ||
646 | 171 | TEST_F(TestSessionView, ShutdownModeButtons) | 177 | TEST_F(TestSessionView, ShutdownModeButtons) |
647 | @@ -181,6 +187,7 @@ | |||
648 | 181 | 187 | ||
649 | 182 | TEST_F(TestSessionView, LogoutModeButtons) | 188 | TEST_F(TestSessionView, LogoutModeButtons) |
650 | 183 | { | 189 | { |
651 | 190 | ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(true)); | ||
652 | 184 | view.mode = View::Mode::LOGOUT; | 191 | view.mode = View::Mode::LOGOUT; |
653 | 185 | 192 | ||
654 | 186 | EXPECT_EQ(view.GetButtons().size(), 2); | 193 | EXPECT_EQ(view.GetButtons().size(), 2); |
655 | @@ -189,6 +196,16 @@ | |||
656 | 189 | EXPECT_EQ(view.key_focus_area(), view.GetButtonByAction(Button::Action::LOGOUT)); | 196 | EXPECT_EQ(view.key_focus_area(), view.GetButtonByAction(Button::Action::LOGOUT)); |
657 | 190 | } | 197 | } |
658 | 191 | 198 | ||
659 | 199 | TEST_F(TestSessionView, LogoutLightModeButtons) | ||
660 | 200 | { | ||
661 | 201 | ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(false)); | ||
662 | 202 | view.mode = View::Mode::LOGOUT; | ||
663 | 203 | |||
664 | 204 | EXPECT_EQ(view.GetButtons().size(), 1); | ||
665 | 205 | EXPECT_EQ(view.GetButtonPosition(Button::Action::LOGOUT), 0); | ||
666 | 206 | EXPECT_EQ(view.key_focus_area(), view.GetButtonByAction(Button::Action::LOGOUT)); | ||
667 | 207 | } | ||
668 | 208 | |||
669 | 192 | TEST_F(TestSessionView, FullModeTitle) | 209 | TEST_F(TestSessionView, FullModeTitle) |
670 | 193 | { | 210 | { |
671 | 194 | EXPECT_TRUE(view.GetTitle().empty()); | 211 | EXPECT_TRUE(view.GetTitle().empty()); |
672 | @@ -213,8 +230,9 @@ | |||
673 | 213 | { | 230 | { |
674 | 214 | bool request_hide = false; | 231 | bool request_hide = false; |
675 | 215 | view.request_hide.connect([&request_hide] { request_hide = true; }); | 232 | view.request_hide.connect([&request_hide] { request_hide = true; }); |
676 | 233 | view.mode = View::Mode::LOGOUT; | ||
677 | 216 | 234 | ||
679 | 217 | auto button = view.GetButtonByAction(Button::Action::LOCK); | 235 | auto button = view.GetButtonByAction(Button::Action::LOGOUT); |
680 | 218 | ASSERT_NE(button, nullptr); | 236 | ASSERT_NE(button, nullptr); |
681 | 219 | button->activated.emit(); | 237 | button->activated.emit(); |
682 | 220 | 238 | ||
683 | @@ -223,7 +241,8 @@ | |||
684 | 223 | 241 | ||
685 | 224 | TEST_F(TestSessionView, ButtonsActivateDeselectButton) | 242 | TEST_F(TestSessionView, ButtonsActivateDeselectButton) |
686 | 225 | { | 243 | { |
688 | 226 | auto button = view.GetButtonByAction(Button::Action::LOCK); | 244 | view.mode = View::Mode::LOGOUT; |
689 | 245 | auto button = view.GetButtonByAction(Button::Action::LOGOUT); | ||
690 | 227 | ASSERT_NE(button, nullptr); | 246 | ASSERT_NE(button, nullptr); |
691 | 228 | button->highlighted = true; | 247 | button->highlighted = true; |
692 | 229 | button->activated.emit(); | 248 | button->activated.emit(); |
693 | @@ -233,6 +252,8 @@ | |||
694 | 233 | 252 | ||
695 | 234 | TEST_F(TestSessionView, LockButtonActivateLocks) | 253 | TEST_F(TestSessionView, LockButtonActivateLocks) |
696 | 235 | { | 254 | { |
697 | 255 | ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(true)); | ||
698 | 256 | view.mode = View::Mode::LOGOUT; | ||
699 | 236 | EXPECT_CALL(*manager, LockScreen()); | 257 | EXPECT_CALL(*manager, LockScreen()); |
700 | 237 | auto button = view.GetButtonByAction(Button::Action::LOCK); | 258 | auto button = view.GetButtonByAction(Button::Action::LOCK); |
701 | 238 | ASSERT_NE(button, nullptr); | 259 | ASSERT_NE(button, nullptr); |
PASSED: Continuous integration, rev:3817 jenkins. qa.ubuntu. com/job/ unity-ci/ 926/ jenkins. qa.ubuntu. com/job/ unity-utopic- amd64-ci/ 13 jenkins. qa.ubuntu. com/job/ unity-utopic- armhf-ci/ 13 jenkins. qa.ubuntu. com/job/ unity-utopic- i386-ci/ 13
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- ci/926/ rebuild
http://