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

Unified Diff: chrome/browser/extensions/management_policy_unittest.cc

Issue 54903011: Add management policy function allowing extensions to be disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: responded to review comments Created 7 years, 1 month 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/extensions/management_policy.cc ('k') | chrome/browser/extensions/test_management_policy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/management_policy_unittest.cc
diff --git a/chrome/browser/extensions/management_policy_unittest.cc b/chrome/browser/extensions/management_policy_unittest.cc
index 1f1d86e85e890cdad0dc5db3b2d947c4f42f08d0..0ac3f4b0c15fcb9ef4427fbabb679be7af9994f8 100644
--- a/chrome/browser/extensions/management_policy_unittest.cc
+++ b/chrome/browser/extensions/management_policy_unittest.cc
@@ -19,6 +19,9 @@ class ManagementPolicyTest : public testing::Test {
no_load_.SetProhibitedActions(TestProvider::PROHIBIT_LOAD);
must_remain_enabled_.SetProhibitedActions(
TestProvider::MUST_REMAIN_ENABLED);
+ must_remain_disabled_.SetProhibitedActions(
+ TestProvider::MUST_REMAIN_DISABLED);
+ must_remain_disabled_.SetDisableReason(Extension::DISABLE_SIDELOAD_WIPEOUT);
restrict_all_.SetProhibitedActions(TestProvider::PROHIBIT_MODIFY_STATUS |
TestProvider::PROHIBIT_LOAD |
TestProvider::MUST_REMAIN_ENABLED);
@@ -31,6 +34,7 @@ class ManagementPolicyTest : public testing::Test {
TestProvider no_modify_status_;
TestProvider no_load_;
TestProvider must_remain_enabled_;
+ TestProvider must_remain_disabled_;
TestProvider restrict_all_;
};
@@ -142,6 +146,36 @@ TEST_F(ManagementPolicyTest, MustRemainEnabled) {
EXPECT_TRUE(error.empty());
}
+TEST_F(ManagementPolicyTest, MustRemainDisabled) {
+ // No providers registered.
+ string16 error;
+ EXPECT_FALSE(policy_.MustRemainDisabled(NULL, NULL, &error));
+ EXPECT_TRUE(error.empty());
+
+ // One provider, no relevant restriction.
+ policy_.RegisterProvider(&allow_all_);
+ EXPECT_FALSE(policy_.MustRemainDisabled(NULL, NULL, &error));
+ EXPECT_TRUE(error.empty());
+
+ // Two providers, no relevant restrictions.
+ policy_.RegisterProvider(&no_modify_status_);
+ EXPECT_FALSE(policy_.MustRemainDisabled(NULL, NULL, &error));
+ EXPECT_TRUE(error.empty());
+
+ // Three providers, one with a relevant restriction.
+ Extension::DisableReason reason = Extension::DISABLE_NONE;
+ policy_.RegisterProvider(&must_remain_disabled_);
+ EXPECT_TRUE(policy_.MustRemainDisabled(NULL, &reason, &error));
+ EXPECT_FALSE(error.empty());
+ EXPECT_EQ(Extension::DISABLE_SIDELOAD_WIPEOUT, reason);
+
+ // Remove the restriction.
+ policy_.UnregisterProvider(&must_remain_disabled_);
+ error.clear();
+ EXPECT_FALSE(policy_.MustRemainDisabled(NULL, NULL, &error));
+ EXPECT_TRUE(error.empty());
+}
+
// Tests error handling in the ManagementPolicy.
TEST_F(ManagementPolicyTest, ErrorHandling) {
// The error parameter should be unchanged if no restriction was found.
« no previous file with comments | « chrome/browser/extensions/management_policy.cc ('k') | chrome/browser/extensions/test_management_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698