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