| 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" |
| 11 #include "chrome/browser/ui/browser_finder.h" | 11 #include "chrome/browser/ui/browser_finder.h" |
| 12 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
| 13 #include "chrome/browser/ui/host_desktop.h" | 13 #include "chrome/browser/ui/host_desktop.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "chrome/test/base/testing_browser_process.h" | 16 #include "chrome/test/base/testing_browser_process.h" |
| 17 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // An observer that returns back to test code after a new profile is | 21 // An observer that returns back to test code after a new profile is |
| 22 // initialized. | 22 // initialized. |
| 23 void OnUnblockOnProfileCreation(Profile* profile, | 23 void OnUnblockOnProfileCreation(Profile* profile, |
| 24 Profile::CreateStatus status) { | 24 Profile::CreateStatus status) { |
| 25 if (status == Profile::CREATE_STATUS_INITIALIZED) | 25 if (status == Profile::CREATE_STATUS_INITIALIZED) |
| 26 MessageLoop::current()->Quit(); | 26 base::MessageLoop::current()->Quit(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void ProfileCreationComplete(Profile* profile, Profile::CreateStatus status) { | 29 void ProfileCreationComplete(Profile* profile, Profile::CreateStatus status) { |
| 30 ASSERT_NE(status, Profile::CREATE_STATUS_FAIL); | 30 ASSERT_NE(status, Profile::CREATE_STATUS_FAIL); |
| 31 // No browser should have been created for this profile yet. | 31 // No browser should have been created for this profile yet. |
| 32 EXPECT_EQ(chrome::GetTotalBrowserCountForProfile(profile), 0U); | 32 EXPECT_EQ(chrome::GetTotalBrowserCountForProfile(profile), 0U); |
| 33 EXPECT_EQ(chrome::GetTotalBrowserCount(), 1U); | 33 EXPECT_EQ(chrome::GetTotalBrowserCount(), 1U); |
| 34 if (status == Profile::CREATE_STATUS_INITIALIZED) | 34 if (status == Profile::CREATE_STATUS_INITIALIZED) |
| 35 MessageLoop::current()->Quit(); | 35 base::MessageLoop::current()->Quit(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 class ProfileRemovalObserver : public ProfileInfoCacheObserver { | 38 class ProfileRemovalObserver : public ProfileInfoCacheObserver { |
| 39 public: | 39 public: |
| 40 ProfileRemovalObserver() { | 40 ProfileRemovalObserver() { |
| 41 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver( | 41 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver( |
| 42 this); | 42 this); |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual ~ProfileRemovalObserver() { | 45 virtual ~ProfileRemovalObserver() { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 EXPECT_EQ(profile_manager->GetNumberOfProfiles(), 2U); | 182 EXPECT_EQ(profile_manager->GetNumberOfProfiles(), 2U); |
| 183 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U); | 183 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U); |
| 184 | 184 |
| 185 // Now close all browser windows. | 185 // Now close all browser windows. |
| 186 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); | 186 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); |
| 187 for (std::vector<Profile*>::const_iterator it = profiles.begin(); | 187 for (std::vector<Profile*>::const_iterator it = profiles.begin(); |
| 188 it != profiles.end(); ++it) { | 188 it != profiles.end(); ++it) { |
| 189 BrowserList::CloseAllBrowsersWithProfile(*it); | 189 BrowserList::CloseAllBrowsersWithProfile(*it); |
| 190 } | 190 } |
| 191 } | 191 } |
| OLD | NEW |