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

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

Issue 504453002: Use 'You' as profile name for a single signed profile whose gaia name is not available yet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix broken tests Created 6 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/profiles/profiles_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1078
1079 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. 1079 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME.
1080 const base::string16 default_profile_name = 1080 const base::string16 default_profile_name =
1081 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); 1081 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME);
1082 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); 1082 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0);
1083 Profile* profile1 = AddProfileToCache(profile_manager, 1083 Profile* profile1 = AddProfileToCache(profile_manager,
1084 "path_1", profile_name1); 1084 "path_1", profile_name1);
1085 EXPECT_EQ(default_profile_name, 1085 EXPECT_EQ(default_profile_name,
1086 profiles::GetAvatarNameForProfile(profile1->GetPath())); 1086 profiles::GetAvatarNameForProfile(profile1->GetPath()));
1087 1087
1088 // We should display the actual profile name for signed in profiles. 1088 // For a signed in profile with a default name we still display
1089 // IDS_SINGLE_PROFILE_DISPLAY_NAME.
1089 cache.SetUserNameOfProfileAtIndex(0, ASCIIToUTF16("user@gmail.com")); 1090 cache.SetUserNameOfProfileAtIndex(0, ASCIIToUTF16("user@gmail.com"));
1090 EXPECT_EQ(profile_name1, cache.GetNameOfProfileAtIndex(0)); 1091 EXPECT_EQ(profile_name1, cache.GetNameOfProfileAtIndex(0));
1091 EXPECT_EQ(profile_name1, 1092 EXPECT_EQ(default_profile_name,
1092 profiles::GetAvatarNameForProfile(profile1->GetPath())); 1093 profiles::GetAvatarNameForProfile(profile1->GetPath()));
1093 1094
1095 // For a signed in profile with a non-default Gaia given name we display the
1096 // Gaia given name.
1097 cache.SetUserNameOfProfileAtIndex(0, ASCIIToUTF16("user@gmail.com"));
1098 const base::string16 gaia_given_name(ASCIIToUTF16("given name"));
1099 cache.SetGAIAGivenNameOfProfileAtIndex(0, gaia_given_name);
1100 EXPECT_EQ(gaia_given_name, cache.GetNameOfProfileAtIndex(0));
1101 EXPECT_EQ(gaia_given_name,
1102 profiles::GetAvatarNameForProfile(profile1->GetPath()));
1103
1094 // Multiple profiles means displaying the actual profile names. 1104 // Multiple profiles means displaying the actual profile names.
1095 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); 1105 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1);
1096 Profile* profile2 = AddProfileToCache(profile_manager, 1106 Profile* profile2 = AddProfileToCache(profile_manager,
1097 "path_2", profile_name2); 1107 "path_2", profile_name2);
1098 EXPECT_EQ(profile_name1, 1108 EXPECT_EQ(gaia_given_name,
1099 profiles::GetAvatarNameForProfile(profile1->GetPath())); 1109 profiles::GetAvatarNameForProfile(profile1->GetPath()));
1100 EXPECT_EQ(profile_name2, 1110 EXPECT_EQ(profile_name2,
1101 profiles::GetAvatarNameForProfile(profile2->GetPath())); 1111 profiles::GetAvatarNameForProfile(profile2->GetPath()));
1102 1112
1103 // Deleting a profile means returning to the original, actual profile name. 1113 // Deleting a profile means returning to the original, actual profile name.
1104 profile_manager->ScheduleProfileForDeletion(profile2->GetPath(), 1114 profile_manager->ScheduleProfileForDeletion(profile2->GetPath(),
1105 ProfileManager::CreateCallback()); 1115 ProfileManager::CreateCallback());
1106 // Spin the message loop so that all the callbacks can finish running. 1116 // Spin the message loop so that all the callbacks can finish running.
1107 base::RunLoop().RunUntilIdle(); 1117 base::RunLoop().RunUntilIdle();
1108 EXPECT_EQ(profile_name1, 1118 EXPECT_EQ(gaia_given_name,
1109 profiles::GetAvatarNameForProfile(profile1->GetPath())); 1119 profiles::GetAvatarNameForProfile(profile1->GetPath()));
1110 } 1120 }
1111 #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) 1121 #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
1112 1122
1113 #if defined(OS_MACOSX) 1123 #if defined(OS_MACOSX)
1114 // These tests are for a Mac-only code path that assumes the browser 1124 // These tests are for a Mac-only code path that assumes the browser
1115 // process isn't killed when all browser windows are closed. 1125 // process isn't killed when all browser windows are closed.
1116 TEST_F(ProfileManagerTest, ActiveProfileDeletedNeedsToLoadNextProfile) { 1126 TEST_F(ProfileManagerTest, ActiveProfileDeletedNeedsToLoadNextProfile) {
1117 ProfileManager* profile_manager = g_browser_process->profile_manager(); 1127 ProfileManager* profile_manager = g_browser_process->profile_manager();
1118 ASSERT_TRUE(profile_manager); 1128 ASSERT_TRUE(profile_manager);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 dest_path2.BaseName().MaybeAsASCII()); 1219 dest_path2.BaseName().MaybeAsASCII());
1210 profile_manager->ScheduleProfileForDeletion(dest_path2, 1220 profile_manager->ScheduleProfileForDeletion(dest_path2,
1211 ProfileManager::CreateCallback()); 1221 ProfileManager::CreateCallback());
1212 // Spin the message loop so that all the callbacks can finish running. 1222 // Spin the message loop so that all the callbacks can finish running.
1213 base::RunLoop().RunUntilIdle(); 1223 base::RunLoop().RunUntilIdle();
1214 1224
1215 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); 1225 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath());
1216 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); 1226 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed));
1217 } 1227 }
1218 #endif // !defined(OS_MACOSX) 1228 #endif // !defined(OS_MACOSX)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profiles_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698