Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: chromeos/dbus/power_policy_controller_unittest.cc

Issue 15734010: chromeos: Add delay between screen off and lock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: switch to simpler approach using a constant Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/dbus/power_policy_controller.h" 5 #include "chromeos/dbus/power_policy_controller.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chromeos/dbus/dbus_thread_manager.h" 8 #include "chromeos/dbus/dbus_thread_manager.h"
9 #include "chromeos/dbus/fake_power_manager_client.h" 9 #include "chromeos/dbus/fake_power_manager_client.h"
10 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" 10 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 policy_controller_->ApplyPrefs(prefs); 88 policy_controller_->ApplyPrefs(prefs);
89 expected_policy.mutable_ac_delays()->set_idle_warning_ms(700000); 89 expected_policy.mutable_ac_delays()->set_idle_warning_ms(700000);
90 expected_policy.mutable_battery_delays()->set_idle_warning_ms(400000); 90 expected_policy.mutable_battery_delays()->set_idle_warning_ms(400000);
91 expected_policy.set_lid_closed_action( 91 expected_policy.set_lid_closed_action(
92 power_manager::PowerManagementPolicy_Action_SUSPEND); 92 power_manager::PowerManagementPolicy_Action_SUSPEND);
93 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy), 93 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
94 PowerPolicyController::GetPolicyDebugString( 94 PowerPolicyController::GetPolicyDebugString(
95 fake_power_client_.get_policy())); 95 fake_power_client_.get_policy()));
96 96
97 // The enable-screen-lock pref should force the screen-lock delays to 97 // The enable-screen-lock pref should force the screen-lock delays to
98 // match the screen-off delays. 98 // match the screen-off delays plus a constant value.
99 prefs.enable_screen_lock = true; 99 prefs.enable_screen_lock = true;
100 policy_controller_->ApplyPrefs(prefs); 100 policy_controller_->ApplyPrefs(prefs);
101 expected_policy.mutable_ac_delays()->set_screen_lock_ms(660000); 101 expected_policy.mutable_ac_delays()->set_screen_lock_ms(
102 expected_policy.mutable_battery_delays()->set_screen_lock_ms(360000); 102 660000 + PowerPolicyController::kScreenLockAfterOffDelayMs);
103 expected_policy.mutable_battery_delays()->set_screen_lock_ms(
104 360000 + PowerPolicyController::kScreenLockAfterOffDelayMs);
103 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy), 105 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
104 PowerPolicyController::GetPolicyDebugString( 106 PowerPolicyController::GetPolicyDebugString(
105 fake_power_client_.get_policy())); 107 fake_power_client_.get_policy()));
106 108
107 // If the screen-lock-delay prefs are set to lower values than the 109 // If the screen-lock-delay prefs are set to lower values than the
108 // screen-off delays, the lock prefs should take precedence. 110 // screen-off delays plus the constant, the lock prefs should take
111 // precedence.
109 prefs.ac_screen_lock_delay_ms = 70000; 112 prefs.ac_screen_lock_delay_ms = 70000;
110 prefs.battery_screen_lock_delay_ms = 60000; 113 prefs.battery_screen_lock_delay_ms = 60000;
111 policy_controller_->ApplyPrefs(prefs); 114 policy_controller_->ApplyPrefs(prefs);
112 expected_policy.mutable_ac_delays()->set_screen_lock_ms(70000); 115 expected_policy.mutable_ac_delays()->set_screen_lock_ms(70000);
113 expected_policy.mutable_battery_delays()->set_screen_lock_ms(60000); 116 expected_policy.mutable_battery_delays()->set_screen_lock_ms(60000);
114 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy), 117 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
115 PowerPolicyController::GetPolicyDebugString( 118 PowerPolicyController::GetPolicyDebugString(
116 fake_power_client_.get_policy())); 119 fake_power_client_.get_policy()));
117 120
121 // If the artificial screen-lock delays would exceed the idle delay, they
122 // shouldn't be set -- the power manager would ignore them since the
123 // idle action should lock the screen in this case.
bartfab (slow) 2013/05/31 17:39:07 Is this also true if the idle action is "do nothin
Daniel Erat 2013/06/01 03:19:43 Yes, this is also true for "do nothing": http://gi
124 prefs.ac_screen_off_delay_ms = prefs.ac_idle_delay_ms - 1;
125 prefs.battery_screen_off_delay_ms = prefs.battery_idle_delay_ms - 1;
126 prefs.ac_screen_lock_delay_ms = -1;
127 prefs.battery_screen_lock_delay_ms = -1;
128 policy_controller_->ApplyPrefs(prefs);
129 expected_policy.mutable_ac_delays()->set_screen_off_ms(
130 prefs.ac_screen_off_delay_ms);
131 expected_policy.mutable_battery_delays()->set_screen_off_ms(
132 prefs.battery_screen_off_delay_ms);
133 expected_policy.mutable_ac_delays()->set_screen_lock_ms(-1);
134 expected_policy.mutable_battery_delays()->set_screen_lock_ms(-1);
135 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
136 PowerPolicyController::GetPolicyDebugString(
137 fake_power_client_.get_policy()));
138
118 // Set the "allow screen wake locks" pref to false. The system should be 139 // Set the "allow screen wake locks" pref to false. The system should be
119 // prevented from suspending due to user inactivity but the pref-supplied 140 // prevented from suspending due to user inactivity but the pref-supplied
120 // screen-related delays should be left untouched. 141 // screen-related delays should be left untouched.
121 prefs.allow_screen_wake_locks = false; 142 prefs.allow_screen_wake_locks = false;
122 policy_controller_->ApplyPrefs(prefs); 143 policy_controller_->ApplyPrefs(prefs);
123 policy_controller_->AddScreenWakeLock("Screen"); 144 policy_controller_->AddScreenWakeLock("Screen");
124 expected_policy.set_idle_action( 145 expected_policy.set_idle_action(
125 power_manager::PowerManagementPolicy_Action_DO_NOTHING); 146 power_manager::PowerManagementPolicy_Action_DO_NOTHING);
126 expected_policy.set_reason("Prefs, Screen"); 147 expected_policy.set_reason("Prefs, Screen");
127 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy), 148 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 fake_power_client_.get_policy())); 182 fake_power_client_.get_policy()));
162 183
163 policy_controller_->RemoveWakeLock(screen_id); 184 policy_controller_->RemoveWakeLock(screen_id);
164 expected_policy.Clear(); 185 expected_policy.Clear();
165 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy), 186 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
166 PowerPolicyController::GetPolicyDebugString( 187 PowerPolicyController::GetPolicyDebugString(
167 fake_power_client_.get_policy())); 188 fake_power_client_.get_policy()));
168 } 189 }
169 190
170 } // namespace chromeos 191 } // namespace chromeos
OLDNEW
« chromeos/dbus/power_policy_controller.cc ('K') | « chromeos/dbus/power_policy_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698