OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/policy/configuration_policy_handler_chromeos.h" | 5 #include "chrome/browser/policy/configuration_policy_handler_chromeos.h" |
6 | 6 |
7 #include "chrome/browser/policy/policy_error_map.h" | 7 #include "chrome/browser/policy/policy_error_map.h" |
8 #include "chrome/browser/policy/policy_map.h" | 8 #include "chrome/browser/policy/policy_map.h" |
| 9 #include "chrome/browser/prefs/pref_value_map.h" |
| 10 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h" |
| 11 #include "chrome/common/pref_names.h" |
9 #include "policy/policy_constants.h" | 12 #include "policy/policy_constants.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
11 | 14 |
12 namespace policy { | 15 namespace policy { |
13 | 16 |
14 TEST(NetworkConfigurationPolicyHandlerTest, Empty) { | 17 TEST(NetworkConfigurationPolicyHandlerTest, Empty) { |
15 PolicyMap policy_map; | 18 PolicyMap policy_map; |
16 NetworkConfigurationPolicyHandler handler( | 19 NetworkConfigurationPolicyHandler handler( |
17 key::kOpenNetworkConfiguration, | 20 key::kOpenNetworkConfiguration, |
18 chromeos::NetworkUIData::ONC_SOURCE_USER_POLICY); | 21 chromeos::NetworkUIData::ONC_SOURCE_USER_POLICY); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 PolicyErrorMap errors; | 105 PolicyErrorMap errors; |
103 handler.PrepareForDisplaying(&policy_map); | 106 handler.PrepareForDisplaying(&policy_map); |
104 const Value* sanitized = policy_map.GetValue(key::kOpenNetworkConfiguration); | 107 const Value* sanitized = policy_map.GetValue(key::kOpenNetworkConfiguration); |
105 ASSERT_TRUE(sanitized); | 108 ASSERT_TRUE(sanitized); |
106 std::string sanitized_onc; | 109 std::string sanitized_onc; |
107 EXPECT_TRUE(sanitized->GetAsString(&sanitized_onc)); | 110 EXPECT_TRUE(sanitized->GetAsString(&sanitized_onc)); |
108 EXPECT_FALSE(sanitized_onc.empty()); | 111 EXPECT_FALSE(sanitized_onc.empty()); |
109 EXPECT_EQ(std::string::npos, sanitized_onc.find("pass")); | 112 EXPECT_EQ(std::string::npos, sanitized_onc.find("pass")); |
110 } | 113 } |
111 | 114 |
| 115 TEST(PinnedLauncherAppsPolicyHandler, PrefTranslation) { |
| 116 base::ListValue list; |
| 117 PolicyMap policy_map; |
| 118 PrefValueMap prefs; |
| 119 base::ListValue expected_pinned_apps; |
| 120 base::Value* value = NULL; |
| 121 PinnedLauncherAppsPolicyHandler handler; |
| 122 |
| 123 policy_map.Set(key::kPinnedLauncherApps, POLICY_LEVEL_MANDATORY, |
| 124 POLICY_SCOPE_USER, list.DeepCopy()); |
| 125 handler.ApplyPolicySettings(policy_map, &prefs); |
| 126 EXPECT_TRUE(prefs.GetValue(prefs::kPinnedLauncherApps, &value)); |
| 127 EXPECT_TRUE(base::Value::Equals(&expected_pinned_apps, value)); |
| 128 |
| 129 base::StringValue entry1("abcdefghijklmnopabcdefghijklmnop"); |
| 130 base::DictionaryValue* entry1_dict = new base::DictionaryValue(); |
| 131 entry1_dict->Set(ChromeLauncherController::kPinnedAppsPrefAppIDPath, |
| 132 entry1.DeepCopy()); |
| 133 expected_pinned_apps.Append(entry1_dict); |
| 134 list.Append(entry1.DeepCopy()); |
| 135 policy_map.Set(key::kPinnedLauncherApps, POLICY_LEVEL_MANDATORY, |
| 136 POLICY_SCOPE_USER, list.DeepCopy()); |
| 137 prefs.Clear(); |
| 138 handler.ApplyPolicySettings(policy_map, &prefs); |
| 139 EXPECT_TRUE(prefs.GetValue(prefs::kPinnedLauncherApps, &value)); |
| 140 EXPECT_TRUE(base::Value::Equals(&expected_pinned_apps, value)); |
| 141 } |
| 142 |
112 } // namespace policy | 143 } // namespace policy |
OLD | NEW |