| 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 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 bool PowerPrefsTest::GetExpectedAllowScreenWakeLocksForProfile( | 145 bool PowerPrefsTest::GetExpectedAllowScreenWakeLocksForProfile( |
| 146 Profile* profile) const { | 146 Profile* profile) const { |
| 147 return profile->GetPrefs()->GetBoolean(prefs::kPowerAllowScreenWakeLocks); | 147 return profile->GetPrefs()->GetBoolean(prefs::kPowerAllowScreenWakeLocks); |
| 148 } | 148 } |
| 149 | 149 |
| 150 TEST_F(PowerPrefsTest, LoginScreen) { | 150 TEST_F(PowerPrefsTest, LoginScreen) { |
| 151 // Set up login profile. | 151 // Set up login profile. |
| 152 scoped_ptr<TestingPrefServiceSyncable> login_profile_prefs( | 152 scoped_ptr<TestingPrefServiceSyncable> login_profile_prefs( |
| 153 new TestingPrefServiceSyncable); | 153 new TestingPrefServiceSyncable); |
| 154 chrome::RegisterLoginProfilePrefs(login_profile_prefs->registry()); | 154 chrome::RegisterLoginProfilePrefs(login_profile_prefs->registry()); |
| 155 scoped_ptr<TestingProfile> login_profile_owner(new TestingProfile( | 155 TestingProfile::Builder builder; |
| 156 profile_manager_.profiles_dir().AppendASCII(chrome::kInitialProfile), | 156 builder.SetPath( |
| 157 NULL, | 157 profile_manager_.profiles_dir().AppendASCII(chrome::kInitialProfile)); |
| 158 scoped_refptr<ExtensionSpecialStoragePolicy>(), | 158 builder.SetPrefService(login_profile_prefs.PassAs<PrefServiceSyncable>()); |
| 159 scoped_ptr<PrefServiceSyncable>(login_profile_prefs.release()))); | 159 builder.SetIncognito(); |
| 160 scoped_ptr<TestingProfile> login_profile_owner(builder.Build()); |
| 161 |
| 160 TestingProfile* login_profile = login_profile_owner.get(); | 162 TestingProfile* login_profile = login_profile_owner.get(); |
| 161 TestingProfile* login_profile_parent = profile_manager_.CreateTestingProfile( | 163 TestingProfile* login_profile_parent = profile_manager_.CreateTestingProfile( |
| 162 chrome::kInitialProfile); | 164 chrome::kInitialProfile); |
| 163 login_profile_parent->SetOffTheRecordProfile(login_profile_owner.release()); | 165 login_profile_parent->SetOffTheRecordProfile( |
| 166 login_profile_owner.PassAs<Profile>()); |
| 164 login_profile->SetOriginalProfile(login_profile_parent); | 167 login_profile->SetOriginalProfile(login_profile_parent); |
| 165 login_profile->set_incognito(true); | |
| 166 | 168 |
| 167 // Inform power_prefs_ that the login screen is being shown. | 169 // Inform power_prefs_ that the login screen is being shown. |
| 168 power_prefs_->Observe(chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 170 power_prefs_->Observe(chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 169 content::Source<PowerPrefsTest>(this), | 171 content::Source<PowerPrefsTest>(this), |
| 170 content::NotificationService::NoDetails()); | 172 content::NotificationService::NoDetails()); |
| 171 | 173 |
| 172 EXPECT_EQ(login_profile, GetProfile()); | 174 EXPECT_EQ(login_profile, GetProfile()); |
| 173 EXPECT_EQ(GetExpectedPowerPolicyForProfile(login_profile), | 175 EXPECT_EQ(GetExpectedPowerPolicyForProfile(login_profile), |
| 174 GetCurrentPowerPolicy()); | 176 GetCurrentPowerPolicy()); |
| 175 EXPECT_EQ(GetExpectedAllowScreenWakeLocksForProfile(login_profile), | 177 EXPECT_EQ(GetExpectedAllowScreenWakeLocksForProfile(login_profile), |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 content::Source<Profile>(user_profile), | 255 content::Source<Profile>(user_profile), |
| 254 content::NotificationService::NoDetails()); | 256 content::NotificationService::NoDetails()); |
| 255 | 257 |
| 256 EXPECT_FALSE(GetProfile()); | 258 EXPECT_FALSE(GetProfile()); |
| 257 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString( | 259 EXPECT_EQ(PowerPolicyController::GetPolicyDebugString( |
| 258 power_manager::PowerManagementPolicy()), | 260 power_manager::PowerManagementPolicy()), |
| 259 GetCurrentPowerPolicy()); | 261 GetCurrentPowerPolicy()); |
| 260 } | 262 } |
| 261 | 263 |
| 262 } // namespace chromeos | 264 } // namespace chromeos |
| OLD | NEW |