Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Unified Diff: chrome/browser/profiles/profile_manager_browsertest.cc

Issue 933503004: Always load signin profile on Chrome OS startup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..9c9c3388763f66849525d87e40a6469803965a2f 100644
--- a/chrome/browser/profiles/profile_manager_browsertest.cc
+++ b/chrome/browser/profiles/profile_manager_browsertest.cc
@@ -265,6 +265,24 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
}
}
+base::FilePath GetNonSigninProfileAt(const ProfileInfoCache& cache,
mtomasz 2015/02/25 05:49:41 This can go to anon namespace next to other utilit
Ivan Podogov 2015/02/25 11:11:03 Done.
+ size_t index) {
+#if defined(OS_CHROMEOS)
+ base::FilePath result;
+ size_t i, profile_num = cache.GetNumberOfProfiles();
+ for (i = 0; i != profile_num; ++i) {
+ base::FilePath path = cache.GetPathOfProfileAtIndex(i);
+ if (path.BaseName().value() == chrome::kInitialProfile)
mtomasz 2015/02/25 05:49:41 Can we assume that all non-signin profiles are ini
+ continue;
+ if (index-- == 0)
mtomasz 2015/02/25 05:49:41 This method is always called with index = 0. Can w
Ivan Podogov 2015/02/25 11:11:03 Done.
+ return path;
+ }
+ return result;
+#else
+ return cache.GetPathOfProfileAtIndex(index);
+#endif
+}
+
IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
SwitchToProfile) {
#if defined(OS_WIN) && defined(USE_ASH)
@@ -280,10 +298,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 +318,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 +333,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 +341,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 +368,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 +387,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 +413,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.

Powered by Google App Engine
This is Rietveld 408576698