OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/chromeos/power/power_prefs.h" | 5 #include "chrome/browser/chromeos/power/power_prefs.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
25 #include "chrome/test/base/testing_browser_process.h" | 25 #include "chrome/test/base/testing_browser_process.h" |
26 #include "chrome/test/base/testing_profile.h" | 26 #include "chrome/test/base/testing_profile.h" |
27 #include "chrome/test/base/testing_profile_manager.h" | 27 #include "chrome/test/base/testing_profile_manager.h" |
28 #include "chromeos/dbus/fake_power_manager_client.h" | 28 #include "chromeos/dbus/fake_power_manager_client.h" |
29 #include "chromeos/dbus/power_manager/policy.pb.h" | 29 #include "chromeos/dbus/power_manager/policy.pb.h" |
30 #include "chromeos/dbus/power_policy_controller.h" | 30 #include "chromeos/dbus/power_policy_controller.h" |
31 #include "components/pref_registry/pref_registry_syncable.h" | 31 #include "components/pref_registry/pref_registry_syncable.h" |
32 #include "components/prefs/pref_service.h" | 32 #include "components/prefs/pref_service.h" |
33 #include "components/signin/core/account_id/account_id.h" | 33 #include "components/signin/core/account_id/account_id.h" |
34 #include "components/syncable_prefs/pref_service_syncable.h" | 34 #include "components/sync_preferences/pref_service_syncable.h" |
35 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 35 #include "components/sync_preferences/testing_pref_service_syncable.h" |
36 #include "content/public/browser/notification_details.h" | 36 #include "content/public/browser/notification_details.h" |
37 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
38 #include "content/public/browser/notification_source.h" | 38 #include "content/public/browser/notification_source.h" |
39 #include "content/public/test/test_browser_thread_bundle.h" | 39 #include "content/public/test/test_browser_thread_bundle.h" |
40 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
41 | 41 |
42 namespace chromeos { | 42 namespace chromeos { |
43 | 43 |
44 class PowerPrefsTest : public testing::Test { | 44 class PowerPrefsTest : public testing::Test { |
45 protected: | 45 protected: |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return power_policy_controller_->honor_screen_wake_locks_; | 169 return power_policy_controller_->honor_screen_wake_locks_; |
170 } | 170 } |
171 | 171 |
172 bool PowerPrefsTest::GetExpectedAllowScreenWakeLocksForProfile( | 172 bool PowerPrefsTest::GetExpectedAllowScreenWakeLocksForProfile( |
173 Profile* profile) const { | 173 Profile* profile) const { |
174 return profile->GetPrefs()->GetBoolean(prefs::kPowerAllowScreenWakeLocks); | 174 return profile->GetPrefs()->GetBoolean(prefs::kPowerAllowScreenWakeLocks); |
175 } | 175 } |
176 | 176 |
177 TEST_F(PowerPrefsTest, LoginScreen) { | 177 TEST_F(PowerPrefsTest, LoginScreen) { |
178 // Set up login profile. | 178 // Set up login profile. |
179 std::unique_ptr<syncable_prefs::TestingPrefServiceSyncable> | 179 std::unique_ptr<sync_preferences::TestingPrefServiceSyncable> |
180 login_profile_prefs(new syncable_prefs::TestingPrefServiceSyncable); | 180 login_profile_prefs(new sync_preferences::TestingPrefServiceSyncable); |
181 chrome::RegisterLoginProfilePrefs(login_profile_prefs->registry()); | 181 chrome::RegisterLoginProfilePrefs(login_profile_prefs->registry()); |
182 TestingProfile::Builder builder; | 182 TestingProfile::Builder builder; |
183 builder.SetPath( | 183 builder.SetPath( |
184 profile_manager_.profiles_dir().AppendASCII(chrome::kInitialProfile)); | 184 profile_manager_.profiles_dir().AppendASCII(chrome::kInitialProfile)); |
185 builder.SetPrefService(std::move(login_profile_prefs)); | 185 builder.SetPrefService(std::move(login_profile_prefs)); |
186 TestingProfile* login_profile = builder.BuildIncognito( | 186 TestingProfile* login_profile = builder.BuildIncognito( |
187 profile_manager_.CreateTestingProfile(chrome::kInitialProfile)); | 187 profile_manager_.CreateTestingProfile(chrome::kInitialProfile)); |
188 | 188 |
189 // Inform power_prefs_ that the login screen is being shown. | 189 // Inform power_prefs_ that the login screen is being shown. |
190 power_prefs_->Observe(chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 190 power_prefs_->Observe(chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 | 366 |
367 // The automatic screen locking is enabled and the lock screen is disabled, so | 367 // The automatic screen locking is enabled and the lock screen is disabled, so |
368 // the power policy actions are set now to stop the user session. | 368 // the power policy actions are set now to stop the user session. |
369 user_profile_->GetPrefs()->SetBoolean(prefs::kEnableAutoScreenLock, true); | 369 user_profile_->GetPrefs()->SetBoolean(prefs::kEnableAutoScreenLock, true); |
370 EXPECT_EQ(std::vector<power_manager::PowerManagementPolicy_Action>( | 370 EXPECT_EQ(std::vector<power_manager::PowerManagementPolicy_Action>( |
371 3, power_manager::PowerManagementPolicy_Action_STOP_SESSION), | 371 3, power_manager::PowerManagementPolicy_Action_STOP_SESSION), |
372 GetCurrentPowerPolicyActions()); | 372 GetCurrentPowerPolicyActions()); |
373 } | 373 } |
374 | 374 |
375 } // namespace chromeos | 375 } // namespace chromeos |
OLD | NEW |