Index: chrome/browser/profiles/profile_manager_browsertest.cc |
diff --git a/chrome/browser/profiles/profile_manager_browsertest.cc b/chrome/browser/profiles/profile_manager_browsertest.cc |
index f07472902f85fa851324cbb7d1a820141d046a84..de4ce482052b452b5e9b5aaf923e2e19f0761898 100644 |
--- a/chrome/browser/profiles/profile_manager_browsertest.cc |
+++ b/chrome/browser/profiles/profile_manager_browsertest.cc |
@@ -265,6 +265,22 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, |
} |
} |
+base::FilePath GetNonSigninProfileAt(const ProfileInfoCache& cache, |
+ size_t index) { |
+ base::FilePath result; |
+ size_t i, profile_num = cache.GetNumberOfProfiles(); |
+ for (i = 0; i != profile_num; ++i) { |
+ base::FilePath path = cache.GetPathOfProfileAtIndex(i); |
+#if defined(OS_CHROMEOS) |
mtomasz
2015/02/20 02:00:42
On OS different than Chrome OS, this loop is unnec
Ivan Podogov
2015/02/24 11:43:17
Done.
|
+ if (path.BaseName().value() == chrome::kInitialProfile) |
+ continue; |
+#endif |
+ if (index-- == 0) |
+ return path; |
+ } |
+ return result; |
+} |
+ |
IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, |
SwitchToProfile) { |
#if defined(OS_WIN) && defined(USE_ASH) |
@@ -280,10 +296,11 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, |
ProfileManager* profile_manager = g_browser_process->profile_manager(); |
ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
- base::FilePath path_profile1 = cache.GetPathOfProfileAtIndex(0); |
+ size_t initial_profile_count = profile_manager->GetNumberOfProfiles(); |
+ base::FilePath path_profile1 = GetNonSigninProfileAt(cache, 0); |
- ASSERT_EQ(profile_manager->GetNumberOfProfiles(), 1U); |
- EXPECT_EQ(chrome::GetTotalBrowserCount(), 1U); |
+ ASSERT_NE(0U, initial_profile_count); |
+ EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
// Create an additional profile. |
base::FilePath path_profile2 = |
@@ -299,14 +316,14 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, |
chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
BrowserList* browser_list = BrowserList::GetInstance(desktop_type); |
- ASSERT_EQ(cache.GetNumberOfProfiles(), 2U); |
+ ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles()); |
EXPECT_EQ(1U, browser_list->size()); |
// Open a browser window for the first profile. |
profiles::SwitchToProfile(path_profile1, desktop_type, false, |
kOnProfileSwitchDoNothing, |
ProfileMetrics::SWITCH_PROFILE_ICON); |
- EXPECT_EQ(chrome::GetTotalBrowserCount(), 1U); |
+ EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
EXPECT_EQ(1U, browser_list->size()); |
EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
@@ -314,7 +331,7 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, |
profiles::SwitchToProfile(path_profile2, desktop_type, false, |
kOnProfileSwitchDoNothing, |
ProfileMetrics::SWITCH_PROFILE_ICON); |
- EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U); |
+ EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); |
EXPECT_EQ(2U, browser_list->size()); |
EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
@@ -322,7 +339,7 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, |
profiles::SwitchToProfile(path_profile1, desktop_type, false, |
kOnProfileSwitchDoNothing, |
ProfileMetrics::SWITCH_PROFILE_ICON); |
- EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U); |
+ EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); |
EXPECT_EQ(2U, browser_list->size()); |
EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
@@ -349,9 +366,10 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, MAYBE_EphemeralProfile) { |
ProfileManager* profile_manager = g_browser_process->profile_manager(); |
ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
- base::FilePath path_profile1 = cache.GetPathOfProfileAtIndex(0); |
+ size_t initial_profile_count = profile_manager->GetNumberOfProfiles(); |
+ base::FilePath path_profile1 = GetNonSigninProfileAt(cache, 0); |
- ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); |
+ ASSERT_NE(0U, initial_profile_count); |
EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
// Create an ephemeral profile. |
@@ -367,7 +385,7 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, MAYBE_EphemeralProfile) { |
chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
BrowserList* browser_list = BrowserList::GetInstance(desktop_type); |
- ASSERT_EQ(2U, cache.GetNumberOfProfiles()); |
+ ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles()); |
EXPECT_EQ(1U, browser_list->size()); |
// Open a browser window for the second profile. |
@@ -393,13 +411,13 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, MAYBE_EphemeralProfile) { |
browser_list->get(2)->window()->Close(); |
content::RunAllPendingInMessageLoop(); |
EXPECT_EQ(2U, browser_list->size()); |
- ASSERT_EQ(2U, cache.GetNumberOfProfiles()); |
+ ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles()); |
// The second should though. |
browser_list->get(1)->window()->Close(); |
content::RunAllPendingInMessageLoop(); |
EXPECT_EQ(1U, browser_list->size()); |
- ASSERT_EQ(1U, cache.GetNumberOfProfiles()); |
+ EXPECT_EQ(initial_profile_count, cache.GetNumberOfProfiles()); |
} |
// The test makes sense on those platforms where the keychain exists. |