| 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
|
|
|