Merge lp:~afrantzis/unity-system-compositor/fix-1473979-power-key-inactivity-timers into lp:unity-system-compositor

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Andreas Pokorny
Approved revision: 224
Merged at revision: 225
Proposed branch: lp:~afrantzis/unity-system-compositor/fix-1473979-power-key-inactivity-timers
Merge into: lp:unity-system-compositor
Diff against target: 74 lines (+28/-6)
2 files modified
src/screen_event_handler.cpp (+11/-4)
tests/unit-tests/test_screen_event_handler.cpp (+17/-2)
To merge this branch: bzr merge lp:~afrantzis/unity-system-compositor/fix-1473979-power-key-inactivity-timers
Reviewer Review Type Date Requested Status
Alberto Aguirre (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+264541@code.launchpad.net

Commit message

Ensure inactivity timers are enabled when turning the screen on using the power button

Description of the change

Ensure inactivity timers are enabled when turning the screen on using the power button

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/screen_event_handler.cpp'
2--- src/screen_event_handler.cpp 2015-04-29 14:39:19 +0000
3+++ src/screen_event_handler.cpp 2015-07-13 12:38:29 +0000
4@@ -80,7 +80,7 @@
5 std::lock_guard<std::mutex> lock{guard};
6
7 mode_at_press_start = screen->get_screen_power_mode();
8- if (mode_at_press_start == MirPowerMode::mir_power_mode_off)
9+ if (mode_at_press_start != MirPowerMode::mir_power_mode_on)
10 {
11 screen->set_screen_power_mode(
12 MirPowerMode::mir_power_mode_on, PowerStateChangeReason::power_key);
13@@ -98,10 +98,17 @@
14 shutdown_alarm->cancel();
15 long_press_alarm->cancel();
16
17- if (mode_at_press_start == MirPowerMode::mir_power_mode_on && !long_press_detected)
18+ if (!long_press_detected)
19 {
20- screen->set_screen_power_mode(
21- MirPowerMode::mir_power_mode_off, PowerStateChangeReason::power_key);
22+ if (mode_at_press_start == MirPowerMode::mir_power_mode_on)
23+ {
24+ screen->set_screen_power_mode(
25+ MirPowerMode::mir_power_mode_off, PowerStateChangeReason::power_key);
26+ }
27+ else
28+ {
29+ screen->enable_inactivity_timers(true);
30+ }
31 }
32 }
33
34
35=== modified file 'tests/unit-tests/test_screen_event_handler.cpp'
36--- tests/unit-tests/test_screen_event_handler.cpp 2015-06-03 17:17:37 +0000
37+++ tests/unit-tests/test_screen_event_handler.cpp 2015-07-13 12:38:29 +0000
38@@ -98,6 +98,7 @@
39 AdvanceableTimer timer;
40 std::chrono::milliseconds const power_key_ignore_timeout{5000};
41 std::chrono::milliseconds const shutdown_timeout{10000};
42+ std::chrono::milliseconds const normal_press_duration{100};
43 testing::NiceMock<MockScreen> mock_screen;
44 std::atomic<bool> shutdown_called{false};
45 usc::ScreenEventHandler screen_event_handler{
46@@ -168,8 +169,6 @@
47
48 TEST_F(AScreenEventHandler, sets_screen_mode_off_normal_press_release)
49 {
50- std::chrono::milliseconds const normal_press_duration{100};
51-
52 EXPECT_CALL(mock_screen,
53 set_screen_power_mode(MirPowerMode::mir_power_mode_off,
54 PowerStateChangeReason::power_key));
55@@ -208,3 +207,19 @@
56 EXPECT_FALSE(screen_event_handler.handle(*touch_event));
57 EXPECT_FALSE(screen_event_handler.handle(*pointer_event));
58 }
59+
60+TEST_F(AScreenEventHandler, disables_inactivity_timers_on_power_key_down)
61+{
62+ EXPECT_CALL(mock_screen, enable_inactivity_timers(false));
63+
64+ press_power_key();
65+}
66+
67+TEST_F(AScreenEventHandler, enables_inactivity_timers_on_power_key_up_when_turning_screen_on)
68+{
69+ press_power_key();
70+ timer.advance_by(normal_press_duration);
71+
72+ EXPECT_CALL(mock_screen, enable_inactivity_timers(true));
73+ release_power_key();
74+}

Subscribers

People subscribed via source and target branches