| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/profiles/profile_info_cache.h" | 8 #include "chrome/browser/profiles/profile_info_cache.h" |
| 9 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 9 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 89 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 90 ProfileRemovalObserver observer; | 90 ProfileRemovalObserver observer; |
| 91 | 91 |
| 92 // We should start out with 1 profile. | 92 // We should start out with 1 profile. |
| 93 ASSERT_EQ(cache.GetNumberOfProfiles(), 1U); | 93 ASSERT_EQ(cache.GetNumberOfProfiles(), 1U); |
| 94 | 94 |
| 95 // Delete singleton profile. | 95 // Delete singleton profile. |
| 96 base::FilePath singleton_profile_path = cache.GetPathOfProfileAtIndex(0); | 96 base::FilePath singleton_profile_path = cache.GetPathOfProfileAtIndex(0); |
| 97 EXPECT_FALSE(singleton_profile_path.empty()); | 97 EXPECT_FALSE(singleton_profile_path.empty()); |
| 98 profile_manager->ScheduleProfileForDeletion(singleton_profile_path, | 98 profile_manager->ScheduleProfileForDeletion(singleton_profile_path, |
| 99 chrome::HOST_DESKTOP_TYPE_NATIVE); | 99 ProfileManager::CreateCallback()); |
| 100 | 100 |
| 101 // Spin things till profile is actually deleted. | 101 // Spin things till profile is actually deleted. |
| 102 content::RunAllPendingInMessageLoop(); | 102 content::RunAllPendingInMessageLoop(); |
| 103 | 103 |
| 104 // Make sure a new profile was created automatically. | 104 // Make sure a new profile was created automatically. |
| 105 EXPECT_EQ(cache.GetNumberOfProfiles(), 1U); | 105 EXPECT_EQ(cache.GetNumberOfProfiles(), 1U); |
| 106 base::FilePath new_profile_path = cache.GetPathOfProfileAtIndex(0); | 106 base::FilePath new_profile_path = cache.GetPathOfProfileAtIndex(0); |
| 107 EXPECT_NE(new_profile_path, singleton_profile_path); | 107 EXPECT_NE(new_profile_path, singleton_profile_path); |
| 108 | 108 |
| 109 // Make sure that last used profile preference is set correctly. | 109 // Make sure that last used profile preference is set correctly. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 135 content::RunMessageLoop(); | 135 content::RunMessageLoop(); |
| 136 | 136 |
| 137 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U); | 137 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U); |
| 138 | 138 |
| 139 // Delete all profiles. | 139 // Delete all profiles. |
| 140 base::FilePath profile_path1 = cache.GetPathOfProfileAtIndex(0); | 140 base::FilePath profile_path1 = cache.GetPathOfProfileAtIndex(0); |
| 141 base::FilePath profile_path2 = cache.GetPathOfProfileAtIndex(1); | 141 base::FilePath profile_path2 = cache.GetPathOfProfileAtIndex(1); |
| 142 EXPECT_FALSE(profile_path1.empty()); | 142 EXPECT_FALSE(profile_path1.empty()); |
| 143 EXPECT_FALSE(profile_path2.empty()); | 143 EXPECT_FALSE(profile_path2.empty()); |
| 144 profile_manager->ScheduleProfileForDeletion(profile_path1, | 144 profile_manager->ScheduleProfileForDeletion(profile_path1, |
| 145 chrome::HOST_DESKTOP_TYPE_NATIVE); | 145 ProfileManager::CreateCallback()); |
| 146 profile_manager->ScheduleProfileForDeletion(profile_path2, | 146 profile_manager->ScheduleProfileForDeletion(profile_path2, |
| 147 chrome::HOST_DESKTOP_TYPE_NATIVE); | 147 ProfileManager::CreateCallback()); |
| 148 | 148 |
| 149 // Spin things so deletion can take place. | 149 // Spin things so deletion can take place. |
| 150 content::RunAllPendingInMessageLoop(); | 150 content::RunAllPendingInMessageLoop(); |
| 151 | 151 |
| 152 // Make sure a new profile was created automatically. | 152 // Make sure a new profile was created automatically. |
| 153 EXPECT_EQ(cache.GetNumberOfProfiles(), 1U); | 153 EXPECT_EQ(cache.GetNumberOfProfiles(), 1U); |
| 154 base::FilePath new_profile_path = cache.GetPathOfProfileAtIndex(0); | 154 base::FilePath new_profile_path = cache.GetPathOfProfileAtIndex(0); |
| 155 EXPECT_NE(new_profile_path, profile_path1); | 155 EXPECT_NE(new_profile_path, profile_path1); |
| 156 EXPECT_NE(new_profile_path, profile_path2); | 156 EXPECT_NE(new_profile_path, profile_path2); |
| 157 | 157 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 168 | 168 |
| 169 ASSERT_EQ(profile_manager->GetNumberOfProfiles(), 1U); | 169 ASSERT_EQ(profile_manager->GetNumberOfProfiles(), 1U); |
| 170 EXPECT_EQ(chrome::GetTotalBrowserCount(), 1U); | 170 EXPECT_EQ(chrome::GetTotalBrowserCount(), 1U); |
| 171 | 171 |
| 172 // Create a profile, make sure callback is invoked before any callbacks are | 172 // Create a profile, make sure callback is invoked before any callbacks are |
| 173 // invoked (so they can do things like sign in the profile, etc). | 173 // invoked (so they can do things like sign in the profile, etc). |
| 174 ProfileManager::CreateMultiProfileAsync( | 174 ProfileManager::CreateMultiProfileAsync( |
| 175 string16(), // name | 175 string16(), // name |
| 176 string16(), // icon url | 176 string16(), // icon url |
| 177 base::Bind(ProfileCreationComplete), | 177 base::Bind(ProfileCreationComplete), |
| 178 chrome::GetActiveDesktop(), | |
| 179 false); | 178 false); |
| 180 // Wait for profile to finish loading. | 179 // Wait for profile to finish loading. |
| 181 content::RunMessageLoop(); | 180 content::RunMessageLoop(); |
| 182 EXPECT_EQ(profile_manager->GetNumberOfProfiles(), 2U); | 181 EXPECT_EQ(profile_manager->GetNumberOfProfiles(), 2U); |
| 183 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U); | 182 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U); |
| 184 | 183 |
| 185 // Now close all browser windows. | 184 // Now close all browser windows. |
| 186 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); | 185 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); |
| 187 for (std::vector<Profile*>::const_iterator it = profiles.begin(); | 186 for (std::vector<Profile*>::const_iterator it = profiles.begin(); |
| 188 it != profiles.end(); ++it) { | 187 it != profiles.end(); ++it) { |
| 189 BrowserList::CloseAllBrowsersWithProfile(*it); | 188 BrowserList::CloseAllBrowsersWithProfile(*it); |
| 190 } | 189 } |
| 191 } | 190 } |
| OLD | NEW |