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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 EXPECT_EQ(GetExpectedPowerPolicyForProfile(login_profile, UNLOCKED), | 234 EXPECT_EQ(GetExpectedPowerPolicyForProfile(login_profile, UNLOCKED), |
235 GetCurrentPowerPolicy()); | 235 GetCurrentPowerPolicy()); |
236 } | 236 } |
237 | 237 |
238 TEST_F(PowerPrefsTest, UserSession) { | 238 TEST_F(PowerPrefsTest, UserSession) { |
239 FakeChromeUserManager* user_manager = new FakeChromeUserManager(); | 239 FakeChromeUserManager* user_manager = new FakeChromeUserManager(); |
240 ScopedUserManagerEnabler user_manager_enabler(user_manager); | 240 ScopedUserManagerEnabler user_manager_enabler(user_manager); |
241 | 241 |
242 // Set up user profile. | 242 // Set up user profile. |
243 const char test_user1[] = "test-user1@example.com"; | 243 const char test_user1[] = "test-user1@example.com"; |
244 user_manager->AddUser(test_user1); | 244 const AccountId test_account_id1(AccountId::FromUserEmail(test_user1)); |
245 user_manager->LoginUser(test_user1); | 245 user_manager->AddUser(test_account_id1); |
| 246 user_manager->LoginUser(test_account_id1); |
246 TestingProfile* user_profile = | 247 TestingProfile* user_profile = |
247 profile_manager_.CreateTestingProfile(test_user1); | 248 profile_manager_.CreateTestingProfile(test_account_id1.GetUserEmail()); |
248 | 249 |
249 profile_manager_.SetLoggedIn(true); | 250 profile_manager_.SetLoggedIn(true); |
250 | 251 |
251 // Inform power_prefs_ that a session has started. | 252 // Inform power_prefs_ that a session has started. |
252 power_prefs_->Observe(chrome::NOTIFICATION_SESSION_STARTED, | 253 power_prefs_->Observe(chrome::NOTIFICATION_SESSION_STARTED, |
253 content::Source<PowerPrefsTest>(this), | 254 content::Source<PowerPrefsTest>(this), |
254 content::NotificationService::NoDetails()); | 255 content::NotificationService::NoDetails()); |
255 | 256 |
256 EXPECT_EQ(user_profile, GetProfile()); | 257 EXPECT_EQ(user_profile, GetProfile()); |
257 EXPECT_EQ(GetExpectedPowerPolicyForProfile(user_profile, UNLOCKED), | 258 EXPECT_EQ(GetExpectedPowerPolicyForProfile(user_profile, UNLOCKED), |
258 GetCurrentPowerPolicy()); | 259 GetCurrentPowerPolicy()); |
259 EXPECT_EQ(GetExpectedAllowScreenWakeLocksForProfile(user_profile), | 260 EXPECT_EQ(GetExpectedAllowScreenWakeLocksForProfile(user_profile), |
260 GetCurrentAllowScreenWakeLocks()); | 261 GetCurrentAllowScreenWakeLocks()); |
261 | 262 |
262 const char test_user2[] = "test-user2@example.com"; | 263 const char test_user2[] = "test-user2@example.com"; |
263 user_manager->AddUser(test_user2); | 264 const AccountId test_account_id2(AccountId::FromUserEmail(test_user2)); |
264 user_manager->LoginUser(test_user2); | 265 user_manager->AddUser(test_account_id2); |
| 266 user_manager->LoginUser(test_account_id2); |
265 TestingProfile* other_profile = | 267 TestingProfile* other_profile = |
266 profile_manager_.CreateTestingProfile(test_user2); | 268 profile_manager_.CreateTestingProfile(test_account_id2.GetUserEmail()); |
267 | 269 |
268 // Inform power_prefs_ that an unrelated profile has been destroyed. | 270 // Inform power_prefs_ that an unrelated profile has been destroyed. |
269 power_prefs_->Observe(chrome::NOTIFICATION_PROFILE_DESTROYED, | 271 power_prefs_->Observe(chrome::NOTIFICATION_PROFILE_DESTROYED, |
270 content::Source<Profile>(other_profile), | 272 content::Source<Profile>(other_profile), |
271 content::NotificationService::NoDetails()); | 273 content::NotificationService::NoDetails()); |
272 | 274 |
273 // Verify that the user profile's power prefs are still being used. | 275 // Verify that the user profile's power prefs are still being used. |
274 EXPECT_EQ(user_profile, GetProfile()); | 276 EXPECT_EQ(user_profile, GetProfile()); |
275 EXPECT_EQ(GetExpectedPowerPolicyForProfile(user_profile, UNLOCKED), | 277 EXPECT_EQ(GetExpectedPowerPolicyForProfile(user_profile, UNLOCKED), |
276 GetCurrentPowerPolicy()); | 278 GetCurrentPowerPolicy()); |
(...skipping 18 matching lines...) Expand all Loading... |
295 content::Source<Profile>(user_profile), | 297 content::Source<Profile>(user_profile), |
296 content::NotificationService::NoDetails()); | 298 content::NotificationService::NoDetails()); |
297 | 299 |
298 // The user profile's prefs should still be used. | 300 // The user profile's prefs should still be used. |
299 EXPECT_FALSE(GetProfile()); | 301 EXPECT_FALSE(GetProfile()); |
300 EXPECT_EQ(GetExpectedPowerPolicyForProfile(user_profile, UNLOCKED), | 302 EXPECT_EQ(GetExpectedPowerPolicyForProfile(user_profile, UNLOCKED), |
301 GetCurrentPowerPolicy()); | 303 GetCurrentPowerPolicy()); |
302 } | 304 } |
303 | 305 |
304 } // namespace chromeos | 306 } // namespace chromeos |
OLD | NEW |