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

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

Issue 16072014: Don't open the 'stats for nerds' in a non-incognito window when incognito is forced. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: renamed getter, left a comment at GetLastUsedProfile Created 7 years, 7 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
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/task_manager/task_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/task_manager/task_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698