From 1ab9b709cb4d691f667c843040b65b46a9c82ebd Mon Sep 17 00:00:00 2001 From: tapted Date: Mon, 15 Sep 2014 16:49:40 -0700 Subject: 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} --- .../browser/ui/browser_command_controller_unittest.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'chrome/browser/ui/browser_command_controller_unittest.cc') 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 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_ptrguest_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 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 profile2(builder.Build()); - TestingProfile::Builder builder2; - scoped_ptr profile1 = builder2.Build(); - profile2->SetOriginalProfile(profile1.get()); + scoped_ptr profile1 = TestingProfile::Builder().Build(); + Profile* profile2 = profile1->GetOffTheRecordProfile(); + EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get()); - profile1->SetOffTheRecordProfile(profile2.PassAs()); // Create a new browser based on the off the record profile. Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile(), -- cgit v1.1