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(); |
| 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 EXPECT_EQ(normal_profile, last_opened_profiles[0]); | 845 EXPECT_EQ(normal_profile, last_opened_profiles[0]); |
829 } | 846 } |
830 | 847 |
831 TEST_F(ProfileManagerTest, ActiveProfileDeleted) { | 848 TEST_F(ProfileManagerTest, ActiveProfileDeleted) { |
832 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 849 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
833 ASSERT_TRUE(profile_manager); | 850 ASSERT_TRUE(profile_manager); |
834 | 851 |
835 // Create and load two profiles. | 852 // Create and load two profiles. |
836 const std::string profile_name1 = "New Profile 1"; | 853 const std::string profile_name1 = "New Profile 1"; |
837 const std::string profile_name2 = "New Profile 2"; | 854 const std::string profile_name2 = "New Profile 2"; |
838 base::FilePath dest_path1 = | 855 base::FilePath dest_path1 = temp_dir_.path().AppendASCII(profile_name1); |
839 temp_dir_.path().AppendASCII(profile_name1); | 856 base::FilePath dest_path2 = temp_dir_.path().AppendASCII(profile_name2); |
840 base::FilePath dest_path2 = | |
841 temp_dir_.path().AppendASCII(profile_name2); | |
842 | 857 |
843 MockObserver mock_observer; | 858 MockObserver mock_observer; |
844 EXPECT_CALL(mock_observer, OnProfileCreated( | 859 EXPECT_CALL(mock_observer, OnProfileCreated( |
845 testing::NotNull(), NotFail())).Times(testing::AtLeast(3)); | 860 testing::NotNull(), NotFail())).Times(testing::AtLeast(3)); |
846 | 861 |
847 CreateProfileAsync(profile_manager, profile_name1, false, &mock_observer); | 862 CreateProfileAsync(profile_manager, profile_name1, false, &mock_observer); |
848 CreateProfileAsync(profile_manager, profile_name2, false, &mock_observer); | 863 CreateProfileAsync(profile_manager, profile_name2, false, &mock_observer); |
849 base::RunLoop().RunUntilIdle(); | 864 base::RunLoop().RunUntilIdle(); |
850 | 865 |
851 EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size()); | 866 EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size()); |
852 EXPECT_EQ(2u, profile_manager->GetProfileInfoCache().GetNumberOfProfiles()); | 867 EXPECT_EQ(2u, profile_manager->GetProfileInfoCache().GetNumberOfProfiles()); |
853 | 868 |
854 // Set the active profile. | 869 // Set the active profile. |
855 PrefService* local_state = g_browser_process->local_state(); | 870 PrefService* local_state = g_browser_process->local_state(); |
856 local_state->SetString(prefs::kProfileLastUsed, profile_name1); | 871 local_state->SetString(prefs::kProfileLastUsed, profile_name1); |
857 | 872 |
858 // Delete the active profile. | 873 // Delete the active profile. |
859 profile_manager->ScheduleProfileForDeletion(dest_path1, | 874 profile_manager->ScheduleProfileForDeletion(dest_path1, |
860 ProfileManager::CreateCallback()); | 875 ProfileManager::CreateCallback()); |
861 // Spin the message loop so that all the callbacks can finish running. | 876 // Spin the message loop so that all the callbacks can finish running. |
862 base::RunLoop().RunUntilIdle(); | 877 base::RunLoop().RunUntilIdle(); |
863 | 878 |
864 EXPECT_EQ(dest_path2, profile_manager->GetLastUsedProfile()->GetPath()); | 879 EXPECT_EQ(dest_path2, profile_manager->GetLastUsedProfile()->GetPath()); |
865 EXPECT_EQ(profile_name2, local_state->GetString(prefs::kProfileLastUsed)); | 880 EXPECT_EQ(profile_name2, local_state->GetString(prefs::kProfileLastUsed)); |
866 } | 881 } |
| 882 |
| 883 TEST_F(ProfileManagerTest, ProfileDisplayNameResetsDefaultName) { |
| 884 if (!profiles::IsMultipleProfilesEnabled()) |
| 885 return; |
| 886 |
| 887 // The command line is reset at the end of every test by the test suite. |
| 888 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 889 switches::kNewProfileManagement); |
| 890 |
| 891 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 892 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 893 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); |
| 894 |
| 895 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. |
| 896 const base::string16 default_profile_name = |
| 897 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); |
| 898 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); |
| 899 Profile* profile1 = AddProfileToCache(profile_manager, |
| 900 "path_1", profile_name1); |
| 901 EXPECT_EQ(default_profile_name, profiles::GetAvatarNameForProfile(profile1)); |
| 902 |
| 903 // Multiple profiles means displaying the actual profile names. |
| 904 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); |
| 905 Profile* profile2 = AddProfileToCache(profile_manager, |
| 906 "path_2", profile_name2); |
| 907 EXPECT_EQ(profile_name1, profiles::GetAvatarNameForProfile(profile1)); |
| 908 EXPECT_EQ(profile_name2, profiles::GetAvatarNameForProfile(profile2)); |
| 909 |
| 910 // Deleting a profile means returning to the default name. |
| 911 profile_manager->ScheduleProfileForDeletion(profile2->GetPath(), |
| 912 ProfileManager::CreateCallback()); |
| 913 // Spin the message loop so that all the callbacks can finish running. |
| 914 base::RunLoop().RunUntilIdle(); |
| 915 EXPECT_EQ(default_profile_name, profiles::GetAvatarNameForProfile(profile1)); |
| 916 } |
| 917 |
| 918 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesCustomName) { |
| 919 if (!profiles::IsMultipleProfilesEnabled()) |
| 920 return; |
| 921 |
| 922 // The command line is reset at the end of every test by the test suite. |
| 923 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 924 switches::kNewProfileManagement); |
| 925 |
| 926 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 927 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 928 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); |
| 929 |
| 930 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. |
| 931 const base::string16 default_profile_name = |
| 932 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); |
| 933 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); |
| 934 Profile* profile1 = AddProfileToCache(profile_manager, |
| 935 "path_1", profile_name1); |
| 936 EXPECT_EQ(default_profile_name, profiles::GetAvatarNameForProfile(profile1)); |
| 937 |
| 938 // We should display custom names for local profiles. |
| 939 const base::string16 custom_profile_name = ASCIIToUTF16("Batman"); |
| 940 cache.SetNameOfProfileAtIndex(0, custom_profile_name); |
| 941 EXPECT_EQ(custom_profile_name, cache.GetNameOfProfileAtIndex(0)); |
| 942 EXPECT_EQ(custom_profile_name, profiles::GetAvatarNameForProfile(profile1)); |
| 943 |
| 944 // Multiple profiles means displaying the actual profile names. |
| 945 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); |
| 946 Profile* profile2 = AddProfileToCache(profile_manager, |
| 947 "path_2", profile_name2); |
| 948 EXPECT_EQ(custom_profile_name, profiles::GetAvatarNameForProfile(profile1)); |
| 949 EXPECT_EQ(profile_name2, profiles::GetAvatarNameForProfile(profile2)); |
| 950 |
| 951 // Deleting a profile means returning to the original, custom name. |
| 952 profile_manager->ScheduleProfileForDeletion(profile2->GetPath(), |
| 953 ProfileManager::CreateCallback()); |
| 954 // Spin the message loop so that all the callbacks can finish running. |
| 955 base::RunLoop().RunUntilIdle(); |
| 956 EXPECT_EQ(custom_profile_name, profiles::GetAvatarNameForProfile(profile1)); |
| 957 } |
| 958 |
| 959 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesSignedInName) { |
| 960 if (!profiles::IsMultipleProfilesEnabled()) |
| 961 return; |
| 962 |
| 963 // The command line is reset at the end of every test by the test suite. |
| 964 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 965 switches::kNewProfileManagement); |
| 966 |
| 967 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 968 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 969 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); |
| 970 |
| 971 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. |
| 972 const base::string16 default_profile_name = |
| 973 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); |
| 974 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); |
| 975 Profile* profile1 = AddProfileToCache(profile_manager, |
| 976 "path_1", profile_name1); |
| 977 EXPECT_EQ(default_profile_name, profiles::GetAvatarNameForProfile(profile1)); |
| 978 |
| 979 // We should display the actual profile name for signed in profiles. |
| 980 cache.SetUserNameOfProfileAtIndex(0, ASCIIToUTF16("user@gmail.com")); |
| 981 EXPECT_EQ(profile_name1, cache.GetNameOfProfileAtIndex(0)); |
| 982 EXPECT_EQ(profile_name1, profiles::GetAvatarNameForProfile(profile1)); |
| 983 |
| 984 // Multiple profiles means displaying the actual profile names. |
| 985 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); |
| 986 Profile* profile2 = AddProfileToCache(profile_manager, |
| 987 "path_2", profile_name2); |
| 988 EXPECT_EQ(profile_name1, profiles::GetAvatarNameForProfile(profile1)); |
| 989 EXPECT_EQ(profile_name2, profiles::GetAvatarNameForProfile(profile2)); |
| 990 |
| 991 // Deleting a profile means returning to the original, actual profile name. |
| 992 profile_manager->ScheduleProfileForDeletion(profile2->GetPath(), |
| 993 ProfileManager::CreateCallback()); |
| 994 // Spin the message loop so that all the callbacks can finish running. |
| 995 base::RunLoop().RunUntilIdle(); |
| 996 EXPECT_EQ(profile_name1, profiles::GetAvatarNameForProfile(profile1)); |
| 997 } |
867 #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 998 #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
868 | 999 |
869 #if defined(OS_MACOSX) | 1000 #if defined(OS_MACOSX) |
870 // These tests are for a Mac-only code path that assumes the browser | 1001 // These tests are for a Mac-only code path that assumes the browser |
871 // process isn't killed when all browser windows are closed. | 1002 // process isn't killed when all browser windows are closed. |
872 TEST_F(ProfileManagerTest, ActiveProfileDeletedNeedsToLoadNextProfile) { | 1003 TEST_F(ProfileManagerTest, ActiveProfileDeletedNeedsToLoadNextProfile) { |
873 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1004 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
874 ASSERT_TRUE(profile_manager); | 1005 ASSERT_TRUE(profile_manager); |
875 | 1006 |
876 // Create and load one profile, and just create a second profile. | 1007 // Create and load one profile, and just create a second profile. |
877 const std::string profile_name1 = "New Profile 1"; | 1008 const std::string profile_name1 = "New Profile 1"; |
878 const std::string profile_name2 = "New Profile 2"; | 1009 const std::string profile_name2 = "New Profile 2"; |
879 base::FilePath dest_path1 = | 1010 base::FilePath dest_path1 = temp_dir_.path().AppendASCII(profile_name1); |
880 temp_dir_.path().AppendASCII(profile_name1); | 1011 base::FilePath dest_path2 = temp_dir_.path().AppendASCII(profile_name2); |
881 base::FilePath dest_path2 = | |
882 temp_dir_.path().AppendASCII(profile_name2); | |
883 | 1012 |
884 MockObserver mock_observer; | 1013 MockObserver mock_observer; |
885 EXPECT_CALL(mock_observer, OnProfileCreated( | 1014 EXPECT_CALL(mock_observer, OnProfileCreated( |
886 testing::NotNull(), NotFail())).Times(testing::AtLeast(2)); | 1015 testing::NotNull(), NotFail())).Times(testing::AtLeast(2)); |
887 CreateProfileAsync(profile_manager, profile_name1, false, &mock_observer); | 1016 CreateProfileAsync(profile_manager, profile_name1, false, &mock_observer); |
888 base::RunLoop().RunUntilIdle(); | 1017 base::RunLoop().RunUntilIdle(); |
889 | 1018 |
890 // Track the profile, but don't load it. | 1019 // Track the profile, but don't load it. |
891 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1020 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
892 cache.AddProfileToCache(dest_path2, ASCIIToUTF16(profile_name2), | 1021 cache.AddProfileToCache(dest_path2, ASCIIToUTF16(profile_name2), |
(...skipping 25 matching lines...) Expand all Loading... |
918 // the next active profile has also been marked for deletion, so the | 1047 // the next active profile has also been marked for deletion, so the |
919 // ProfileManager needs to recursively select a different next profile. | 1048 // ProfileManager needs to recursively select a different next profile. |
920 TEST_F(ProfileManagerTest, ActiveProfileDeletedNextProfileDeletedToo) { | 1049 TEST_F(ProfileManagerTest, ActiveProfileDeletedNextProfileDeletedToo) { |
921 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1050 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
922 ASSERT_TRUE(profile_manager); | 1051 ASSERT_TRUE(profile_manager); |
923 | 1052 |
924 // Create and load one profile, and create two more profiles. | 1053 // Create and load one profile, and create two more profiles. |
925 const std::string profile_name1 = "New Profile 1"; | 1054 const std::string profile_name1 = "New Profile 1"; |
926 const std::string profile_name2 = "New Profile 2"; | 1055 const std::string profile_name2 = "New Profile 2"; |
927 const std::string profile_name3 = "New Profile 3"; | 1056 const std::string profile_name3 = "New Profile 3"; |
928 base::FilePath dest_path1 = | 1057 base::FilePath dest_path1 = temp_dir_.path().AppendASCII(profile_name1); |
929 temp_dir_.path().AppendASCII(profile_name1); | 1058 base::FilePath dest_path2 = temp_dir_.path().AppendASCII(profile_name2); |
930 base::FilePath dest_path2 = | 1059 base::FilePath dest_path3 = temp_dir_.path().AppendASCII(profile_name3); |
931 temp_dir_.path().AppendASCII(profile_name2); | |
932 base::FilePath dest_path3 = | |
933 temp_dir_.path().AppendASCII(profile_name3); | |
934 | 1060 |
935 MockObserver mock_observer; | 1061 MockObserver mock_observer; |
936 EXPECT_CALL(mock_observer, OnProfileCreated( | 1062 EXPECT_CALL(mock_observer, OnProfileCreated( |
937 testing::NotNull(), NotFail())).Times(testing::AtLeast(2)); | 1063 testing::NotNull(), NotFail())).Times(testing::AtLeast(2)); |
938 CreateProfileAsync(profile_manager, profile_name1, false, &mock_observer); | 1064 CreateProfileAsync(profile_manager, profile_name1, false, &mock_observer); |
939 base::RunLoop().RunUntilIdle(); | 1065 base::RunLoop().RunUntilIdle(); |
940 | 1066 |
941 // Create the other profiles, but don't load them. Assign a fake avatar icon | 1067 // Create the other profiles, but don't load them. Assign a fake avatar icon |
942 // to ensure that profiles in the info cache are sorted by the profile name, | 1068 // to ensure that profiles in the info cache are sorted by the profile name, |
943 // and not randomly by the avatar name. | 1069 // and not randomly by the avatar name. |
(...skipping 26 matching lines...) Expand all Loading... |
970 dest_path2.BaseName().MaybeAsASCII()); | 1096 dest_path2.BaseName().MaybeAsASCII()); |
971 profile_manager->ScheduleProfileForDeletion(dest_path2, | 1097 profile_manager->ScheduleProfileForDeletion(dest_path2, |
972 ProfileManager::CreateCallback()); | 1098 ProfileManager::CreateCallback()); |
973 // Spin the message loop so that all the callbacks can finish running. | 1099 // Spin the message loop so that all the callbacks can finish running. |
974 base::RunLoop().RunUntilIdle(); | 1100 base::RunLoop().RunUntilIdle(); |
975 | 1101 |
976 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 1102 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
977 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 1103 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
978 } | 1104 } |
979 #endif // !defined(OS_MACOSX) | 1105 #endif // !defined(OS_MACOSX) |
OLD | NEW |