Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(602)

Side by Side Diff: chrome/browser/profiles/profile_manager_unittest.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Fix Win GN build. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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_id(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 =
235 user_manager->LoginUser(kTestUserName); 236 user_manager->AddUser(test_account_id);
236 user_manager->SwitchActiveUser(kTestUserName); 237 user_manager->LoginUser(test_account_id);
238 user_manager->SwitchActiveUser(test_account_id);
237 239
238 profile_manager->Observe( 240 profile_manager->Observe(
239 chrome::NOTIFICATION_LOGIN_USER_CHANGED, 241 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
240 content::NotificationService::AllSources(), 242 content::NotificationService::AllSources(),
241 content::Details<const user_manager::User>(active_user)); 243 content::Details<const user_manager::User>(active_user));
242 base::FilePath expected_logged_in( 244 base::FilePath expected_logged_in(
243 chromeos::ProfileHelper::GetUserProfileDir(active_user->username_hash())); 245 chromeos::ProfileHelper::GetUserProfileDir(active_user->username_hash()));
244 EXPECT_EQ(expected_logged_in.value(), 246 EXPECT_EQ(expected_logged_in.value(),
245 profile_manager->GetInitialProfileDir().value()); 247 profile_manager->GetInitialProfileDir().value());
246 VLOG(1) << temp_dir_.path().Append( 248 VLOG(1) << temp_dir_.path().Append(
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 dest_path2.BaseName().MaybeAsASCII()); 1340 dest_path2.BaseName().MaybeAsASCII());
1339 profile_manager->ScheduleProfileForDeletion(dest_path2, 1341 profile_manager->ScheduleProfileForDeletion(dest_path2,
1340 ProfileManager::CreateCallback()); 1342 ProfileManager::CreateCallback());
1341 // Spin the message loop so that all the callbacks can finish running. 1343 // Spin the message loop so that all the callbacks can finish running.
1342 base::RunLoop().RunUntilIdle(); 1344 base::RunLoop().RunUntilIdle();
1343 1345
1344 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); 1346 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath());
1345 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); 1347 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed));
1346 } 1348 }
1347 #endif // !defined(OS_MACOSX) 1349 #endif // !defined(OS_MACOSX)
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.cc ('k') | chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698