Index: chrome/browser/profiles/profile_manager_unittest.cc |
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc |
index ecd48e99c889315882ec32eb5a369e38f5c5c56b..7a68ffaf021059bd32a058009f4fcba324b40dcf 100644 |
--- a/chrome/browser/profiles/profile_manager_unittest.cc |
+++ b/chrome/browser/profiles/profile_manager_unittest.cc |
@@ -20,6 +20,7 @@ |
#include "chrome/browser/history/history_service_factory.h" |
#include "chrome/browser/io_thread.h" |
#include "chrome/browser/prefs/browser_prefs.h" |
+#include "chrome/browser/prefs/incognito_mode_prefs.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_info_cache.h" |
#include "chrome/browser/profiles/profile_manager.h" |
@@ -428,6 +429,37 @@ TEST_F(ProfileManagerTest, InitProfileInfoCacheForAProfile) { |
cache.GetAvatarIconIndexOfProfileAtIndex(profile_index)); |
} |
+TEST_F(ProfileManagerTest, GetLastUsedProfileAllowedByPolicy) { |
+ ProfileManager* profile_manager = g_browser_process->profile_manager(); |
+ ASSERT_TRUE(profile_manager); |
+ |
+ Profile* profile = profile_manager->GetLastUsedProfileAllowedByPolicy(); |
+ ASSERT_TRUE(profile); |
+ EXPECT_FALSE(profile->IsOffTheRecord()); |
+ PrefService* prefs = profile->GetPrefs(); |
+ EXPECT_EQ(IncognitoModePrefs::ENABLED, |
+ IncognitoModePrefs::GetAvailability(prefs)); |
+ |
+ // Attach an incognito Profile to the TestingProfile. |
+ ASSERT_FALSE(profile->GetOffTheRecordProfile()); |
+ TestingProfile* incognito_profile = new TestingProfile(); |
+ incognito_profile->set_incognito(true); |
+ EXPECT_TRUE(incognito_profile->IsOffTheRecord()); |
+ TestingProfile* testing_profile = static_cast<TestingProfile*>(profile); |
+ testing_profile->SetOffTheRecordProfile(incognito_profile); |
+ ASSERT_TRUE(profile->GetOffTheRecordProfile()); |
+ |
+ IncognitoModePrefs::SetAvailability(prefs, IncognitoModePrefs::DISABLED); |
+ EXPECT_FALSE( |
+ profile_manager->GetLastUsedProfileAllowedByPolicy()->IsOffTheRecord()); |
+ |
+ // GetLastUsedProfileAllowedByPolicy() returns the incognito Profile when |
+ // incognito mode is forced. |
+ IncognitoModePrefs::SetAvailability(prefs, IncognitoModePrefs::FORCED); |
+ EXPECT_TRUE( |
+ profile_manager->GetLastUsedProfileAllowedByPolicy()->IsOffTheRecord()); |
+} |
+ |
#if !defined(OS_ANDROID) |
// There's no Browser object on Android. |
TEST_F(ProfileManagerTest, LastOpenedProfiles) { |