Commit 550f9f68 authored by Swapnil's avatar Swapnil Committed by Commit Bot

Add a browser test for the profile manager with multiple profiles

A browser test was missing to validate that the browser does not crash
when multiple profiles are added. This browser test validates the same.

Bug: 708210
Change-Id: I346b060cc5b20b631411044f71114d7b4603559d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2041435
Commit-Queue: Swapnil Gupta <swapnilgupta@google.com>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827715}
parent 822d04b6
......@@ -548,6 +548,49 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, SwitchToProfile) {
EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath());
}
// Prepares the setup for AddMultipleProfiles test, creates multiple browser
// windows with multiple browser windows.
IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, PRE_AddMultipleProfiles) {
ProfileManager* profile_manager = g_browser_process->profile_manager();
ProfileAttributesStorage& storage =
profile_manager->GetProfileAttributesStorage();
size_t initial_profile_count = profile_manager->GetNumberOfProfiles();
base::FilePath path_profile1 =
GetFirstNonSigninNonLockScreenAppProfile(&storage);
ASSERT_NE(0U, initial_profile_count);
EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
// Create an additional profile.
base::FilePath path_profile2 =
profile_manager->GenerateNextProfileDirectoryPath();
base::RunLoop run_loop;
profile_manager->CreateProfileAsync(
path_profile2, base::Bind(&OnUnblockOnProfileCreation, &run_loop),
base::string16(), std::string());
// Run the message loop to allow profile creation to take place; the loop is
// terminated by OnUnblockOnProfileCreation when the profile is created.
run_loop.Run();
BrowserList* browser_list = BrowserList::GetInstance();
ASSERT_EQ(initial_profile_count + 1U, storage.GetNumberOfProfiles());
EXPECT_EQ(1U, browser_list->size());
// Open a browser window for the first profile.
profiles::SwitchToProfile(path_profile1, false, kOnProfileSwitchDoNothing);
EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
ASSERT_EQ(1U, browser_list->size());
EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath());
// Open a browser window for the second profile.
profiles::SwitchToProfile(path_profile2, false, kOnProfileSwitchDoNothing);
EXPECT_EQ(2U, chrome::GetTotalBrowserCount());
ASSERT_EQ(2U, browser_list->size());
EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath());
}
IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, AddMultipleProfiles) {
// Verifies that the browser doesn't crash when it is restarted.
}
// Flakes on Windows: http://crbug.com/314905
#if defined(OS_WIN)
#define MAYBE_EphemeralProfile DISABLED_EphemeralProfile
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment