Chromium Code Reviews| 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/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" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/chromeos/settings/cros_settings.h" | 18 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 19 #include "chrome/browser/history/history_service.h" | 19 #include "chrome/browser/history/history_service.h" |
| 20 #include "chrome/browser/history/history_service_factory.h" | 20 #include "chrome/browser/history/history_service_factory.h" |
| 21 #include "chrome/browser/io_thread.h" | 21 #include "chrome/browser/io_thread.h" |
| 22 #include "chrome/browser/prefs/browser_prefs.h" | 22 #include "chrome/browser/prefs/browser_prefs.h" |
| 23 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 23 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/profiles/profile_info_cache.h" | 25 #include "chrome/browser/profiles/profile_info_cache.h" |
| 26 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
| 27 #include "chrome/browser/profiles/profiles_state.h" | |
| 27 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 28 #include "chrome/common/chrome_constants.h" | 29 #include "chrome/common/chrome_constants.h" |
| 29 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 30 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 32 #include "chrome/test/base/scoped_testing_local_state.h" | 33 #include "chrome/test/base/scoped_testing_local_state.h" |
| 33 #include "chrome/test/base/test_browser_window.h" | 34 #include "chrome/test/base/test_browser_window.h" |
| 34 #include "chrome/test/base/testing_browser_process.h" | 35 #include "chrome/test/base/testing_browser_process.h" |
| 35 #include "chrome/test/base/testing_profile.h" | 36 #include "chrome/test/base/testing_profile.h" |
| 36 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
| 37 #include "content/public/test/test_browser_thread_bundle.h" | 38 #include "content/public/test/test_browser_thread_bundle.h" |
| 39 #include "grit/generated_resources.h" | |
| 38 #include "testing/gmock/include/gmock/gmock.h" | 40 #include "testing/gmock/include/gmock/gmock.h" |
| 39 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | |
| 40 | 43 |
| 41 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
| 42 #include "chrome/browser/chromeos/login/mock_user_manager.h" | 45 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
| 43 #include "chrome/browser/chromeos/login/user_manager.h" | 46 #include "chrome/browser/chromeos/login/user_manager.h" |
| 44 #include "chrome/browser/chromeos/settings/cros_settings.h" | 47 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 45 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 48 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 46 #include "chromeos/chromeos_switches.h" | 49 #include "chromeos/chromeos_switches.h" |
| 47 #endif | 50 #endif |
| 48 | 51 |
| 49 using base::ASCIIToUTF16; | 52 using base::ASCIIToUTF16; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 MockObserver* mock_observer) { | 122 MockObserver* mock_observer) { |
| 120 manager->CreateProfileAsync( | 123 manager->CreateProfileAsync( |
| 121 temp_dir_.path().AppendASCII(name), | 124 temp_dir_.path().AppendASCII(name), |
| 122 base::Bind(&MockObserver::OnProfileCreated, | 125 base::Bind(&MockObserver::OnProfileCreated, |
| 123 base::Unretained(mock_observer)), | 126 base::Unretained(mock_observer)), |
| 124 base::UTF8ToUTF16(name), | 127 base::UTF8ToUTF16(name), |
| 125 base::UTF8ToUTF16(ProfileInfoCache::GetDefaultAvatarIconUrl(0)), | 128 base::UTF8ToUTF16(ProfileInfoCache::GetDefaultAvatarIconUrl(0)), |
| 126 is_managed ? "Dummy ID" : std::string()); | 129 is_managed ? "Dummy ID" : std::string()); |
| 127 } | 130 } |
| 128 | 131 |
| 132 // Helper function to add a profile with |profile_name| to | |
| 133 // |profile_manager|'s ProfileInfoCache, and return the profile created. | |
| 134 Profile* AddProfileToCache(ProfileManager* profile_manager, | |
| 135 const std::string& path_suffix, | |
| 136 const base::string16& profile_name) { | |
| 137 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | |
|
groby-ooo-7-16
2014/02/20 20:17:27
Indent seems off
noms (inactive)
2014/02/24 22:35:06
Done.
| |
| 138 size_t num_profiles = cache.GetNumberOfProfiles(); | |
| 139 base::FilePath path = temp_dir_.path().AppendASCII(path_suffix); | |
| 140 cache.AddProfileToCache(path, profile_name, | |
| 141 base::string16(), 0, std::string()); | |
| 142 EXPECT_EQ(num_profiles + 1, cache.GetNumberOfProfiles()); | |
| 143 return profile_manager->GetProfile(path); | |
| 144 } | |
| 145 | |
| 129 #if defined(OS_CHROMEOS) | 146 #if defined(OS_CHROMEOS) |
| 130 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 147 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 131 chromeos::ScopedTestCrosSettings test_cros_settings_; | 148 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 132 #endif | 149 #endif |
| 133 | 150 |
| 134 // The path to temporary directory used to contain the test operations. | 151 // The path to temporary directory used to contain the test operations. |
| 135 base::ScopedTempDir temp_dir_; | 152 base::ScopedTempDir temp_dir_; |
| 136 ScopedTestingLocalState local_state_; | 153 ScopedTestingLocalState local_state_; |
| 137 | 154 |
| 138 content::TestBrowserThreadBundle thread_bundle_; | 155 content::TestBrowserThreadBundle thread_bundle_; |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 819 EXPECT_EQ(normal_profile, last_opened_profiles[0]); | 836 EXPECT_EQ(normal_profile, last_opened_profiles[0]); |
| 820 } | 837 } |
| 821 | 838 |
| 822 TEST_F(ProfileManagerTest, ActiveProfileDeleted) { | 839 TEST_F(ProfileManagerTest, ActiveProfileDeleted) { |
| 823 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 840 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 824 ASSERT_TRUE(profile_manager); | 841 ASSERT_TRUE(profile_manager); |
| 825 | 842 |
| 826 // Create and load two profiles. | 843 // Create and load two profiles. |
| 827 const std::string profile_name1 = "New Profile 1"; | 844 const std::string profile_name1 = "New Profile 1"; |
| 828 const std::string profile_name2 = "New Profile 2"; | 845 const std::string profile_name2 = "New Profile 2"; |
| 829 base::FilePath dest_path1 = | 846 base::FilePath dest_path1 = temp_dir_.path().AppendASCII(profile_name1); |
| 830 temp_dir_.path().AppendASCII(profile_name1); | 847 base::FilePath dest_path2 = temp_dir_.path().AppendASCII(profile_name2); |
| 831 base::FilePath dest_path2 = | |
| 832 temp_dir_.path().AppendASCII(profile_name2); | |
| 833 | 848 |
| 834 MockObserver mock_observer; | 849 MockObserver mock_observer; |
| 835 EXPECT_CALL(mock_observer, OnProfileCreated( | 850 EXPECT_CALL(mock_observer, OnProfileCreated( |
| 836 testing::NotNull(), NotFail())).Times(testing::AtLeast(3)); | 851 testing::NotNull(), NotFail())).Times(testing::AtLeast(3)); |
| 837 | 852 |
| 838 CreateProfileAsync(profile_manager, profile_name1, false, &mock_observer); | 853 CreateProfileAsync(profile_manager, profile_name1, false, &mock_observer); |
| 839 CreateProfileAsync(profile_manager, profile_name2, false, &mock_observer); | 854 CreateProfileAsync(profile_manager, profile_name2, false, &mock_observer); |
| 840 base::RunLoop().RunUntilIdle(); | 855 base::RunLoop().RunUntilIdle(); |
| 841 | 856 |
| 842 EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size()); | 857 EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size()); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 860 #if defined(OS_MACOSX) | 875 #if defined(OS_MACOSX) |
| 861 // These tests are for a Mac-only code path that assumes the browser | 876 // These tests are for a Mac-only code path that assumes the browser |
| 862 // process isn't killed when all browser windows are closed. | 877 // process isn't killed when all browser windows are closed. |
| 863 TEST_F(ProfileManagerTest, ActiveProfileDeletedNeedsToLoadNextProfile) { | 878 TEST_F(ProfileManagerTest, ActiveProfileDeletedNeedsToLoadNextProfile) { |
| 864 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 879 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 865 ASSERT_TRUE(profile_manager); | 880 ASSERT_TRUE(profile_manager); |
| 866 | 881 |
| 867 // Create and load one profile, and just create a second profile. | 882 // Create and load one profile, and just create a second profile. |
| 868 const std::string profile_name1 = "New Profile 1"; | 883 const std::string profile_name1 = "New Profile 1"; |
| 869 const std::string profile_name2 = "New Profile 2"; | 884 const std::string profile_name2 = "New Profile 2"; |
| 870 base::FilePath dest_path1 = | 885 base::FilePath dest_path1 = temp_dir_.path().AppendASCII(profile_name1); |
| 871 temp_dir_.path().AppendASCII(profile_name1); | 886 base::FilePath dest_path2 = temp_dir_.path().AppendASCII(profile_name2); |
| 872 base::FilePath dest_path2 = | |
| 873 temp_dir_.path().AppendASCII(profile_name2); | |
| 874 | 887 |
| 875 MockObserver mock_observer; | 888 MockObserver mock_observer; |
| 876 EXPECT_CALL(mock_observer, OnProfileCreated( | 889 EXPECT_CALL(mock_observer, OnProfileCreated( |
| 877 testing::NotNull(), NotFail())).Times(testing::AtLeast(2)); | 890 testing::NotNull(), NotFail())).Times(testing::AtLeast(2)); |
| 878 CreateProfileAsync(profile_manager, profile_name1, false, &mock_observer); | 891 CreateProfileAsync(profile_manager, profile_name1, false, &mock_observer); |
| 879 base::RunLoop().RunUntilIdle(); | 892 base::RunLoop().RunUntilIdle(); |
| 880 | 893 |
| 881 // Track the profile, but don't load it. | 894 // Track the profile, but don't load it. |
| 882 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 895 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 883 cache.AddProfileToCache(dest_path2, ASCIIToUTF16(profile_name2), | 896 cache.AddProfileToCache(dest_path2, ASCIIToUTF16(profile_name2), |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 909 // the next active profile has also been marked for deletion, so the | 922 // the next active profile has also been marked for deletion, so the |
| 910 // ProfileManager needs to recursively select a different next profile. | 923 // ProfileManager needs to recursively select a different next profile. |
| 911 TEST_F(ProfileManagerTest, ActiveProfileDeletedNextProfileDeletedToo) { | 924 TEST_F(ProfileManagerTest, ActiveProfileDeletedNextProfileDeletedToo) { |
| 912 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 925 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 913 ASSERT_TRUE(profile_manager); | 926 ASSERT_TRUE(profile_manager); |
| 914 | 927 |
| 915 // Create and load one profile, and create two more profiles. | 928 // Create and load one profile, and create two more profiles. |
| 916 const std::string profile_name1 = "New Profile 1"; | 929 const std::string profile_name1 = "New Profile 1"; |
| 917 const std::string profile_name2 = "New Profile 2"; | 930 const std::string profile_name2 = "New Profile 2"; |
| 918 const std::string profile_name3 = "New Profile 3"; | 931 const std::string profile_name3 = "New Profile 3"; |
| 919 base::FilePath dest_path1 = | 932 base::FilePath dest_path1 = temp_dir_.path().AppendASCII(profile_name1); |
| 920 temp_dir_.path().AppendASCII(profile_name1); | 933 base::FilePath dest_path2 = temp_dir_.path().AppendASCII(profile_name2); |
| 921 base::FilePath dest_path2 = | 934 base::FilePath dest_path3 = temp_dir_.path().AppendASCII(profile_name3); |
| 922 temp_dir_.path().AppendASCII(profile_name2); | |
| 923 base::FilePath dest_path3 = | |
| 924 temp_dir_.path().AppendASCII(profile_name3); | |
| 925 | 935 |
| 926 MockObserver mock_observer; | 936 MockObserver mock_observer; |
| 927 EXPECT_CALL(mock_observer, OnProfileCreated( | 937 EXPECT_CALL(mock_observer, OnProfileCreated( |
| 928 testing::NotNull(), NotFail())).Times(testing::AtLeast(2)); | 938 testing::NotNull(), NotFail())).Times(testing::AtLeast(2)); |
| 929 CreateProfileAsync(profile_manager, profile_name1, false, &mock_observer); | 939 CreateProfileAsync(profile_manager, profile_name1, false, &mock_observer); |
| 930 base::RunLoop().RunUntilIdle(); | 940 base::RunLoop().RunUntilIdle(); |
| 931 | 941 |
| 932 // Create the other profiles, but don't load them. Assign a fake avatar icon | 942 // Create the other profiles, but don't load them. Assign a fake avatar icon |
| 933 // to ensure that profiles in the info cache are sorted by the profile name, | 943 // to ensure that profiles in the info cache are sorted by the profile name, |
| 934 // and not randomly by the avatar name. | 944 // and not randomly by the avatar name. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 961 dest_path2.BaseName().MaybeAsASCII()); | 971 dest_path2.BaseName().MaybeAsASCII()); |
| 962 profile_manager->ScheduleProfileForDeletion(dest_path2, | 972 profile_manager->ScheduleProfileForDeletion(dest_path2, |
| 963 ProfileManager::CreateCallback()); | 973 ProfileManager::CreateCallback()); |
| 964 // Spin the message loop so that all the callbacks can finish running. | 974 // Spin the message loop so that all the callbacks can finish running. |
| 965 base::RunLoop().RunUntilIdle(); | 975 base::RunLoop().RunUntilIdle(); |
| 966 | 976 |
| 967 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 977 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
| 968 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 978 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
| 969 } | 979 } |
| 970 #endif // !defined(OS_MACOSX) | 980 #endif // !defined(OS_MACOSX) |
| 981 | |
| 982 TEST_F(ProfileManagerTest, ProfileDisplayNameResetsDefaultName) { | |
| 983 // The command line is reset at the end of every test by the test suite. | |
| 984 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 985 switches::kNewProfileManagement); | |
| 986 | |
| 987 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 988 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | |
| 989 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); | |
| 990 | |
| 991 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. | |
| 992 const base::string16 default_profile_name = | |
| 993 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); | |
| 994 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); | |
| 995 Profile* profile1 = AddProfileToCache(profile_manager, | |
| 996 "path_1", profile_name1); | |
| 997 EXPECT_EQ(default_profile_name, | |
| 998 profiles::GetAvatarButtonDisplayNameForProfile(profile1)); | |
| 999 | |
| 1000 // Multiple profiles means displaying the actual profile names. | |
| 1001 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); | |
| 1002 Profile* profile2 = AddProfileToCache(profile_manager, | |
| 1003 "path_2", profile_name2); | |
| 1004 EXPECT_EQ(profile_name1, | |
| 1005 profiles::GetAvatarButtonDisplayNameForProfile(profile1)); | |
| 1006 EXPECT_EQ(profile_name2, | |
| 1007 profiles::GetAvatarButtonDisplayNameForProfile(profile2)); | |
| 1008 | |
| 1009 // Deleting a profile means returning to the default name. | |
| 1010 profile_manager->ScheduleProfileForDeletion(profile2->GetPath(), | |
| 1011 ProfileManager::CreateCallback()); | |
| 1012 // Spin the message loop so that all the callbacks can finish running. | |
| 1013 base::RunLoop().RunUntilIdle(); | |
| 1014 EXPECT_EQ(default_profile_name, | |
| 1015 profiles::GetAvatarButtonDisplayNameForProfile(profile1)); | |
| 1016 } | |
| 1017 | |
| 1018 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesCustomName) { | |
| 1019 // The command line is reset at the end of every test by the test suite. | |
| 1020 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 1021 switches::kNewProfileManagement); | |
| 1022 | |
| 1023 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 1024 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | |
| 1025 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); | |
| 1026 | |
| 1027 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. | |
| 1028 const base::string16 default_profile_name = | |
| 1029 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); | |
| 1030 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); | |
| 1031 Profile* profile1 = AddProfileToCache(profile_manager, | |
| 1032 "path_1", profile_name1); | |
| 1033 EXPECT_EQ(default_profile_name, | |
| 1034 profiles::GetAvatarButtonDisplayNameForProfile(profile1)); | |
| 1035 | |
| 1036 // We should display custom names for local profiles. | |
|
rpetterson
2014/02/20 21:41:32
How does the profile info cache know that it was a
noms (inactive)
2014/02/24 22:35:06
The ProfileInfoCache doesn't. The profiles::GetAva
| |
| 1037 const base::string16 custom_profile_name = ASCIIToUTF16("Batman"); | |
| 1038 cache.SetNameOfProfileAtIndex(0, custom_profile_name); | |
| 1039 EXPECT_EQ(custom_profile_name, cache.GetNameOfProfileAtIndex(0)); | |
| 1040 EXPECT_EQ(custom_profile_name, | |
| 1041 profiles::GetAvatarButtonDisplayNameForProfile(profile1)); | |
| 1042 | |
| 1043 // Multiple profiles means displaying the actual profile names. | |
| 1044 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); | |
| 1045 Profile* profile2 = AddProfileToCache(profile_manager, | |
| 1046 "path_2", profile_name2); | |
| 1047 EXPECT_EQ(custom_profile_name, | |
| 1048 profiles::GetAvatarButtonDisplayNameForProfile(profile1)); | |
| 1049 EXPECT_EQ(profile_name2, | |
| 1050 profiles::GetAvatarButtonDisplayNameForProfile(profile2)); | |
| 1051 | |
| 1052 // Deleting a profile means returning to the original, custom name. | |
| 1053 profile_manager->ScheduleProfileForDeletion(profile2->GetPath(), | |
| 1054 ProfileManager::CreateCallback()); | |
| 1055 // Spin the message loop so that all the callbacks can finish running. | |
| 1056 base::RunLoop().RunUntilIdle(); | |
| 1057 EXPECT_EQ(custom_profile_name, | |
| 1058 profiles::GetAvatarButtonDisplayNameForProfile(profile1)); | |
| 1059 } | |
| 1060 | |
| 1061 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesSignedInName) { | |
| 1062 // The command line is reset at the end of every test by the test suite. | |
| 1063 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 1064 switches::kNewProfileManagement); | |
| 1065 | |
| 1066 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 1067 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | |
| 1068 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); | |
| 1069 | |
| 1070 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. | |
| 1071 const base::string16 default_profile_name = | |
| 1072 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); | |
| 1073 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); | |
| 1074 Profile* profile1 = AddProfileToCache(profile_manager, | |
| 1075 "path_1", profile_name1); | |
| 1076 EXPECT_EQ(default_profile_name, | |
| 1077 profiles::GetAvatarButtonDisplayNameForProfile(profile1)); | |
| 1078 | |
| 1079 // We should display the actual profile name for signed in profiles. | |
| 1080 cache.SetUserNameOfProfileAtIndex(0, ASCIIToUTF16("user@gmail.com")); | |
|
rpetterson
2014/02/20 21:41:32
Does username take precedence over name?
noms (inactive)
2014/02/24 22:35:06
Username just means that the user is signed in, an
| |
| 1081 EXPECT_EQ(profile_name1, cache.GetNameOfProfileAtIndex(0)); | |
| 1082 EXPECT_EQ(profile_name1, | |
| 1083 profiles::GetAvatarButtonDisplayNameForProfile(profile1)); | |
| 1084 | |
| 1085 // Multiple profiles means displaying the actual profile names. | |
| 1086 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); | |
| 1087 Profile* profile2 = AddProfileToCache(profile_manager, | |
| 1088 "path_2", profile_name2); | |
| 1089 EXPECT_EQ(profile_name1, | |
| 1090 profiles::GetAvatarButtonDisplayNameForProfile(profile1)); | |
| 1091 EXPECT_EQ(profile_name2, | |
| 1092 profiles::GetAvatarButtonDisplayNameForProfile(profile2)); | |
| 1093 | |
| 1094 // Deleting a profile means returning to the original, actual profile name. | |
| 1095 profile_manager->ScheduleProfileForDeletion(profile2->GetPath(), | |
| 1096 ProfileManager::CreateCallback()); | |
| 1097 // Spin the message loop so that all the callbacks can finish running. | |
| 1098 base::RunLoop().RunUntilIdle(); | |
| 1099 EXPECT_EQ(profile_name1, | |
| 1100 profiles::GetAvatarButtonDisplayNameForProfile(profile1)); | |
| 1101 } | |
| OLD | NEW |