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

Side by Side 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: rebase Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/policy/configuration_policy_handler.h"
6 #include "chrome/browser/policy/policy_error_map.h"
7 #include "chrome/browser/policy/policy_map.h"
8 #include "chrome/browser/prefs/pref_value_map.h"
9 #include "chrome/common/pref_names.h"
10 #include "policy/policy_constants.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace policy {
14
15 TEST(ExtensionListPolicyHandlerTest, CheckPolicySettings) {
16 base::ListValue list;
17 PolicyMap policy_map;
18 PolicyErrorMap errors;
19 ExtensionListPolicyHandler handler(key::kExtensionInstallBlacklist,
20 prefs::kExtensionInstallDenyList,
21 true);
22
23 policy_map.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
24 POLICY_SCOPE_USER, list.DeepCopy());
25 EXPECT_TRUE(handler.CheckPolicySettings(policy_map, &errors));
26 EXPECT_TRUE(errors.empty());
27
28 list.Append(Value::CreateStringValue("abcdefghijklmnopabcdefghijklmnop"));
29 policy_map.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
30 POLICY_SCOPE_USER, list.DeepCopy());
31 EXPECT_TRUE(handler.CheckPolicySettings(policy_map, &errors));
32 EXPECT_TRUE(errors.empty());
33
34 list.Append(Value::CreateStringValue("*"));
35 policy_map.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
36 POLICY_SCOPE_USER, list.DeepCopy());
37 EXPECT_TRUE(handler.CheckPolicySettings(policy_map, &errors));
38 EXPECT_TRUE(errors.empty());
39
40 list.Append(Value::CreateStringValue("invalid"));
41 policy_map.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
42 POLICY_SCOPE_USER, list.DeepCopy());
43 EXPECT_FALSE(handler.CheckPolicySettings(policy_map, &errors));
44 EXPECT_FALSE(errors.empty());
45 EXPECT_FALSE(errors.GetErrors(key::kExtensionInstallBlacklist).empty());
46 }
47
48 TEST(ExtensionListPolicyHandlerTest, ApplyPolicySettings) {
49 base::ListValue list;
50 PolicyMap policy_map;
51 PrefValueMap prefs;
52 base::Value* value = NULL;
53 ExtensionListPolicyHandler handler(key::kExtensionInstallBlacklist,
54 prefs::kExtensionInstallDenyList,
55 false);
56
57 list.Append(Value::CreateStringValue("abcdefghijklmnopabcdefghijklmnop"));
58 policy_map.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
59 POLICY_SCOPE_USER, list.DeepCopy());
60 handler.ApplyPolicySettings(policy_map, &prefs);
61 EXPECT_TRUE(prefs.GetValue(prefs::kExtensionInstallDenyList, &value));
62 EXPECT_TRUE(base::Value::Equals(&list, value));
63 }
64
65 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698