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

Unified Diff: chrome/browser/policy/configuration_policy_handler_unittest.cc

Issue 10316022: Wire up the policy for controlling pinned apps in the ash launcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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/policy/configuration_policy_handler_unittest.cc
diff --git a/chrome/browser/policy/configuration_policy_handler_unittest.cc b/chrome/browser/policy/configuration_policy_handler_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..17bfeaab7733f09f39a6536dc3038c3bc5a4c21f
--- /dev/null
+++ b/chrome/browser/policy/configuration_policy_handler_unittest.cc
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/policy/configuration_policy_handler.h"
+#include "chrome/browser/policy/policy_error_map.h"
+#include "chrome/browser/policy/policy_map.h"
+#include "chrome/browser/prefs/pref_value_map.h"
+#include "chrome/common/pref_names.h"
+#include "policy/policy_constants.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace policy {
+
+TEST(ExtensionListPolicyHandlerTest, CheckPolicySettings) {
+ base::ListValue list;
+ PolicyMap policy_map;
+ PolicyErrorMap errors;
+ ExtensionListPolicyHandler handler(key::kExtensionInstallBlacklist,
+ prefs::kExtensionInstallDenyList,
+ true);
+
+ policy_map.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER, list.DeepCopy());
+ EXPECT_TRUE(handler.CheckPolicySettings(policy_map, &errors));
+ EXPECT_TRUE(errors.empty());
+
+ list.Append(Value::CreateStringValue("abcdefghijklmnopabcdefghijklmnop"));
+ policy_map.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER, list.DeepCopy());
+ EXPECT_TRUE(handler.CheckPolicySettings(policy_map, &errors));
+ EXPECT_TRUE(errors.empty());
+
+ list.Append(Value::CreateStringValue("*"));
+ policy_map.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER, list.DeepCopy());
+ EXPECT_TRUE(handler.CheckPolicySettings(policy_map, &errors));
+ EXPECT_TRUE(errors.empty());
+
+ list.Append(Value::CreateStringValue("invalid"));
+ policy_map.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER, list.DeepCopy());
+ EXPECT_FALSE(handler.CheckPolicySettings(policy_map, &errors));
+ EXPECT_FALSE(errors.empty());
+ EXPECT_FALSE(errors.GetErrors(key::kExtensionInstallBlacklist).empty());
+}
+
+TEST(ExtensionListPolicyHandlerTest, ApplyPolicySettings) {
+ base::ListValue list;
+ PolicyMap policy_map;
+ PrefValueMap prefs;
+ base::Value* value = NULL;
+ ExtensionListPolicyHandler handler(key::kExtensionInstallBlacklist,
+ prefs::kExtensionInstallDenyList,
+ false);
+
+ list.Append(Value::CreateStringValue("abcdefghijklmnopabcdefghijklmnop"));
+ policy_map.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER, list.DeepCopy());
+ handler.ApplyPolicySettings(policy_map, &prefs);
+ EXPECT_TRUE(prefs.GetValue(prefs::kExtensionInstallDenyList, &value));
+ EXPECT_TRUE(base::Value::Equals(&list, value));
+}
+
+} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698