summaryrefslogtreecommitdiffstats
path: root/extensions/browser/management_policy_unittest.cc
diff options
context:
space:
mode:
authorbinjin <binjin@chromium.org>2014-10-13 12:00:20 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-13 19:00:53 +0000
commitcccacefd3fc1ff73b976144fe1aeb74e47e848e6 (patch)
tree19e40c7b2ab7419415a0bd0a5c27f804cd8273d9 /extensions/browser/management_policy_unittest.cc
parent4fe17db0bc563f663538bf15a483578d18401957 (diff)
downloadchromium_src-cccacefd3fc1ff73b976144fe1aeb74e47e848e6.zip
chromium_src-cccacefd3fc1ff73b976144fe1aeb74e47e848e6.tar.gz
chromium_src-cccacefd3fc1ff73b976144fe1aeb74e47e848e6.tar.bz2
Add recommended extension installation support
Extensions on recommended installation list will be automatically installed just like forced installed extensions, but are allowed to be disabled (not allowed to be uninstalled). This CL adds a new ExternalLoader for recommended extension (use EXTERNAL_PREF_DOWNLOAD as location), another MustRemainInstalled() function to interface of ManagementPolicy, and related WebUI changes. BUG=177351 Review URL: https://codereview.chromium.org/536753003 Cr-Commit-Position: refs/heads/master@{#299336}
Diffstat (limited to 'extensions/browser/management_policy_unittest.cc')
-rw-r--r--extensions/browser/management_policy_unittest.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/extensions/browser/management_policy_unittest.cc b/extensions/browser/management_policy_unittest.cc
index 52373c1..bcedc2c 100644
--- a/extensions/browser/management_policy_unittest.cc
+++ b/extensions/browser/management_policy_unittest.cc
@@ -22,6 +22,8 @@ class ManagementPolicyTest : public testing::Test {
must_remain_disabled_.SetProhibitedActions(
TestProvider::MUST_REMAIN_DISABLED);
must_remain_disabled_.SetDisableReason(Extension::DISABLE_SIDELOAD_WIPEOUT);
+ must_remain_installed_.SetProhibitedActions(
+ TestProvider::MUST_REMAIN_INSTALLED);
restrict_all_.SetProhibitedActions(TestProvider::PROHIBIT_MODIFY_STATUS |
TestProvider::PROHIBIT_LOAD |
TestProvider::MUST_REMAIN_ENABLED);
@@ -35,6 +37,7 @@ class ManagementPolicyTest : public testing::Test {
TestProvider no_load_;
TestProvider must_remain_enabled_;
TestProvider must_remain_disabled_;
+ TestProvider must_remain_installed_;
TestProvider restrict_all_;
};
@@ -176,6 +179,34 @@ TEST_F(ManagementPolicyTest, MustRemainDisabled) {
EXPECT_TRUE(error.empty());
}
+TEST_F(ManagementPolicyTest, MustRemainInstalled) {
+ // No providers registered.
+ base::string16 error;
+ EXPECT_FALSE(policy_.MustRemainInstalled(NULL, &error));
+ EXPECT_TRUE(error.empty());
+
+ // One provider, no relevant restriction.
+ policy_.RegisterProvider(&allow_all_);
+ EXPECT_FALSE(policy_.MustRemainInstalled(NULL, &error));
+ EXPECT_TRUE(error.empty());
+
+ // Two providers, no relevant restrictions.
+ policy_.RegisterProvider(&no_modify_status_);
+ EXPECT_FALSE(policy_.MustRemainInstalled(NULL, &error));
+ EXPECT_TRUE(error.empty());
+
+ // Three providers, one with a relevant restriction.
+ policy_.RegisterProvider(&must_remain_installed_);
+ EXPECT_TRUE(policy_.MustRemainInstalled(NULL, &error));
+ EXPECT_FALSE(error.empty());
+
+ // Remove the restriction.
+ policy_.UnregisterProvider(&must_remain_installed_);
+ error.clear();
+ EXPECT_FALSE(policy_.MustRemainInstalled(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.