summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/browser_command_controller_unittest.cc
diff options
context:
space:
mode:
authortapted <tapted@chromium.org>2014-09-15 16:49:40 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-15 23:51:58 +0000
commit1ab9b709cb4d691f667c843040b65b46a9c82ebd (patch)
tree21cfd5195a404967e7cadb577dccd23c3210cefb /chrome/browser/ui/browser_command_controller_unittest.cc
parent24f900df2092632a68d22f06d61ac828ea6b6d63 (diff)
downloadchromium_src-1ab9b709cb4d691f667c843040b65b46a9c82ebd.zip
chromium_src-1ab9b709cb4d691f667c843040b65b46a9c82ebd.tar.gz
chromium_src-1ab9b709cb4d691f667c843040b65b46a9c82ebd.tar.bz2
Ensure incognito TestingProfiles are incognito for their whole lifetime.
Otherwise keyed services see different profiles in unit_tests at different times since the incognito->GetOriginalProfile() changes. This is causing release code to pick up unnecessary workarounds to keep unit_tests green in try runs. The fix is achieved by adding `TestingProfile::Builder::BuildIncognito`, which differs from `Build` by requiring an |original_profile| argument, which will own the incognito profile (so no need to return scoped_ptr). This simplifies a lot of call sites, since they no longer need to do a scoped_ptr dance of their own. BUG=277296 Review URL: https://codereview.chromium.org/556173002 Cr-Commit-Position: refs/heads/master@{#294931}
Diffstat (limited to 'chrome/browser/ui/browser_command_controller_unittest.cc')
-rw-r--r--chrome/browser/ui/browser_command_controller_unittest.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/chrome/browser/ui/browser_command_controller_unittest.cc b/chrome/browser/ui/browser_command_controller_unittest.cc
index 9fe9857..a796437 100644
--- a/chrome/browser/ui/browser_command_controller_unittest.cc
+++ b/chrome/browser/ui/browser_command_controller_unittest.cc
@@ -246,16 +246,19 @@ TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledInGuestMode) {
ASSERT_TRUE(testing_profile_manager.SetUp());
// Set up guest a profile.
+ scoped_ptr<TestingProfile> original_profile =
+ TestingProfile::Builder().Build();
TestingProfile::Builder guest_builder;
- guest_builder.SetIncognito(); // Guest profiles are off the record.
guest_builder.SetGuestSession();
guest_builder.SetPath(ProfileManager::GetGuestProfilePath());
- scoped_ptr<TestingProfile>guest_profile = guest_builder.Build();
+ // Browsers in Guest mode must be off the record profiles.
+ TestingProfile* guest_profile =
+ guest_builder.BuildIncognito(original_profile.get());
ASSERT_TRUE(guest_profile->IsGuestSession());
// Create a new browser based on the guest profile.
- Browser::CreateParams profile_params(guest_profile.get(),
+ Browser::CreateParams profile_params(guest_profile,
chrome::GetActiveDesktop());
scoped_ptr<Browser> guest_browser(
chrome::CreateBrowserWithTestWindowForParams(&profile_params));
@@ -430,14 +433,10 @@ TEST_F(BrowserCommandControllerFullscreenTest,
TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) {
// Set up a profile with an off the record profile.
- TestingProfile::Builder builder;
- builder.SetIncognito();
- scoped_ptr<TestingProfile> profile2(builder.Build());
- TestingProfile::Builder builder2;
- scoped_ptr<TestingProfile> profile1 = builder2.Build();
- profile2->SetOriginalProfile(profile1.get());
+ scoped_ptr<TestingProfile> profile1 = TestingProfile::Builder().Build();
+ Profile* profile2 = profile1->GetOffTheRecordProfile();
+
EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get());
- profile1->SetOffTheRecordProfile(profile2.PassAs<Profile>());
// Create a new browser based on the off the record profile.
Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile(),