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

Unified Diff: chrome/browser/managed_mode_unittest.cc

Issue 10542023: Disable modifying extensions when in managed mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Improve/fix InitImpl() Created 8 years, 6 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
Index: chrome/browser/managed_mode_unittest.cc
===================================================================
--- chrome/browser/managed_mode_unittest.cc (revision 141651)
+++ chrome/browser/managed_mode_unittest.cc (working copy)
@@ -36,12 +36,20 @@
EnterManagedModeImpl(profile, callback);
}
+ void ForceManagedModeForTesting(Profile* profile) {
+ SetInManagedMode(true, profile);
+ }
+
// ManagedMode overrides:
- virtual bool IsInManagedModeImpl() OVERRIDE {
+ virtual bool IsInManagedModeImpl() const OVERRIDE {
return in_managed_mode_;
}
- virtual void SetInManagedMode(bool in_managed_mode) OVERRIDE {
+ virtual void SetInManagedMode(bool in_managed_mode,
+ Profile* newly_managed_profile) OVERRIDE {
+ if (in_managed_mode)
+ ASSERT_TRUE(newly_managed_profile);
+ managed_profile_ = newly_managed_profile;
in_managed_mode_ = in_managed_mode;
}
@@ -96,7 +104,7 @@
}
void CheckManagedMode(bool success) {
- EXPECT_EQ(managed_mode_->IsInManagedModeImpl(), success);
+ EXPECT_EQ(success, managed_mode_->IsInManagedModeImpl());
DidEnterManagedMode(success);
}
@@ -151,8 +159,9 @@
BrowserFixture managed_mode_browser(&managed_mode_, &managed_mode_profile_);
BrowserFixture other_browser(&managed_mode_, &other_profile_);
- // If we're already in managed mode, entering should immediately succeed.
- managed_mode_.SetInManagedMode(true);
+ // If we're already in managed mode in this profile, entering should
+ // immediately succeed.
+ managed_mode_.ForceManagedModeForTesting(&managed_mode_profile_);
managed_mode_.EnterManagedModeForTesting(&managed_mode_profile_,
CreateExpectedCallback(true));
}
@@ -228,3 +237,16 @@
managed_mode_.EnterManagedModeForTesting(&managed_mode_profile_,
CreateExpectedCallback(false));
}
+
+TEST_F(ManagedModeTest, ExtensionManagementPolicyProvider) {
+ BrowserFixture managed_mode_browser(&managed_mode_, &managed_mode_profile_);
+
+ EXPECT_TRUE(managed_mode_.UserMayLoad(NULL, NULL));
+ EXPECT_TRUE(managed_mode_.UserMayModifySettings(NULL, NULL));
+
+ managed_mode_.ForceManagedModeForTesting(&managed_mode_profile_);
+ EXPECT_FALSE(managed_mode_.UserMayLoad(NULL, NULL));
+ EXPECT_FALSE(managed_mode_.UserMayModifySettings(NULL, NULL));
+
+ EXPECT_FALSE(managed_mode_.GetDebugPolicyProviderName().empty());
+}

Powered by Google App Engine
This is Rietveld 408576698