| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 154 } |
| 155 | 155 |
| 156 #if defined(OS_CHROMEOS) | 156 #if defined(OS_CHROMEOS) |
| 157 // Helper function to register an user with id |user_id| and create profile | 157 // Helper function to register an user with id |user_id| and create profile |
| 158 // with a correct path. | 158 // with a correct path. |
| 159 void RegisterUser(const std::string& user_id) { | 159 void RegisterUser(const std::string& user_id) { |
| 160 chromeos::ProfileHelper* profile_helper = chromeos::ProfileHelper::Get(); | 160 chromeos::ProfileHelper* profile_helper = chromeos::ProfileHelper::Get(); |
| 161 const std::string user_id_hash = | 161 const std::string user_id_hash = |
| 162 profile_helper->GetUserIdHashByUserIdForTesting(user_id); | 162 profile_helper->GetUserIdHashByUserIdForTesting(user_id); |
| 163 user_manager::UserManager::Get()->UserLoggedIn( | 163 user_manager::UserManager::Get()->UserLoggedIn( |
| 164 user_id, user_id_hash, false); | 164 AccountId::FromUserEmail(user_id), user_id_hash, false); |
| 165 g_browser_process->profile_manager()->GetProfile( | 165 g_browser_process->profile_manager()->GetProfile( |
| 166 profile_helper->GetProfilePathByUserIdHash(user_id_hash)); | 166 profile_helper->GetProfilePathByUserIdHash(user_id_hash)); |
| 167 } | 167 } |
| 168 | 168 |
| 169 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 169 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 170 chromeos::ScopedTestCrosSettings test_cros_settings_; | 170 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 171 #endif | 171 #endif |
| 172 | 172 |
| 173 // The path to temporary directory used to contain the test operations. | 173 // The path to temporary directory used to contain the test operations. |
| 174 base::ScopedTempDir temp_dir_; | 174 base::ScopedTempDir temp_dir_; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 // This functionality only exists on Chrome OS. | 221 // This functionality only exists on Chrome OS. |
| 222 TEST_F(ProfileManagerTest, LoggedInProfileDir) { | 222 TEST_F(ProfileManagerTest, LoggedInProfileDir) { |
| 223 base::FilePath expected_default = | 223 base::FilePath expected_default = |
| 224 base::FilePath().AppendASCII(chrome::kInitialProfile); | 224 base::FilePath().AppendASCII(chrome::kInitialProfile); |
| 225 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 225 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 226 EXPECT_EQ(expected_default.value(), | 226 EXPECT_EQ(expected_default.value(), |
| 227 profile_manager->GetInitialProfileDir().value()); | 227 profile_manager->GetInitialProfileDir().value()); |
| 228 | 228 |
| 229 const char kTestUserName[] = "test-user@example.com"; | 229 const char kTestUserName[] = "test-user@example.com"; |
| 230 const AccountId test_account(AccountId::FromUserEmail(kTestUserName)); |
| 230 chromeos::FakeChromeUserManager* user_manager = | 231 chromeos::FakeChromeUserManager* user_manager = |
| 231 new chromeos::FakeChromeUserManager(); | 232 new chromeos::FakeChromeUserManager(); |
| 232 chromeos::ScopedUserManagerEnabler enabler(user_manager); | 233 chromeos::ScopedUserManagerEnabler enabler(user_manager); |
| 233 | 234 |
| 234 const user_manager::User* active_user = user_manager->AddUser(kTestUserName); | 235 const user_manager::User* active_user = user_manager->AddUser(test_account); |
| 235 user_manager->LoginUser(kTestUserName); | 236 user_manager->LoginUser(test_account); |
| 236 user_manager->SwitchActiveUser(kTestUserName); | 237 user_manager->SwitchActiveUser(test_account); |
| 237 | 238 |
| 238 profile_manager->Observe( | 239 profile_manager->Observe( |
| 239 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 240 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 240 content::NotificationService::AllSources(), | 241 content::NotificationService::AllSources(), |
| 241 content::Details<const user_manager::User>(active_user)); | 242 content::Details<const user_manager::User>(active_user)); |
| 242 base::FilePath expected_logged_in( | 243 base::FilePath expected_logged_in( |
| 243 chromeos::ProfileHelper::GetUserProfileDir(active_user->username_hash())); | 244 chromeos::ProfileHelper::GetUserProfileDir(active_user->username_hash())); |
| 244 EXPECT_EQ(expected_logged_in.value(), | 245 EXPECT_EQ(expected_logged_in.value(), |
| 245 profile_manager->GetInitialProfileDir().value()); | 246 profile_manager->GetInitialProfileDir().value()); |
| 246 VLOG(1) << temp_dir_.path().Append( | 247 VLOG(1) << temp_dir_.path().Append( |
| (...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 dest_path2.BaseName().MaybeAsASCII()); | 1339 dest_path2.BaseName().MaybeAsASCII()); |
| 1339 profile_manager->ScheduleProfileForDeletion(dest_path2, | 1340 profile_manager->ScheduleProfileForDeletion(dest_path2, |
| 1340 ProfileManager::CreateCallback()); | 1341 ProfileManager::CreateCallback()); |
| 1341 // Spin the message loop so that all the callbacks can finish running. | 1342 // Spin the message loop so that all the callbacks can finish running. |
| 1342 base::RunLoop().RunUntilIdle(); | 1343 base::RunLoop().RunUntilIdle(); |
| 1343 | 1344 |
| 1344 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 1345 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
| 1345 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 1346 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
| 1346 } | 1347 } |
| 1347 #endif // !defined(OS_MACOSX) | 1348 #endif // !defined(OS_MACOSX) |
| OLD | NEW |