OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/managed_bookmarks_policy_handler.h" | 5 #include "chrome/browser/policy/managed_bookmarks_policy_handler.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 .Set("url", "http://google.com/") | 174 .Set("url", "http://google.com/") |
175 .Build()) | 175 .Build()) |
176 .Build()); | 176 .Build()); |
177 EXPECT_TRUE(pref_value->Equals(expected.get())); | 177 EXPECT_TRUE(pref_value->Equals(expected.get())); |
178 } | 178 } |
179 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 179 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
180 | 180 |
181 TEST_F(ManagedBookmarksPolicyHandlerTest, WrongPolicyType) { | 181 TEST_F(ManagedBookmarksPolicyHandlerTest, WrongPolicyType) { |
182 PolicyMap policy; | 182 PolicyMap policy; |
183 // The expected type is base::ListValue, but this policy sets it as an | 183 // The expected type is base::ListValue, but this policy sets it as an |
184 // unparsed base::StringValue. Any type other than ListValue should fail. | 184 // unparsed base::Value. Any type other than ListValue should fail. |
185 policy.Set(key::kManagedBookmarks, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 185 policy.Set(key::kManagedBookmarks, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
186 POLICY_SOURCE_CLOUD, | 186 POLICY_SOURCE_CLOUD, |
187 base::MakeUnique<base::StringValue>("[" | 187 base::MakeUnique<base::Value>("[" |
188 " {" | 188 " {" |
189 " \"name\": \"Google\"," | 189 " \"name\": \"Google\"," |
190 " \"url\": \"google.com\"" | 190 " \"url\": \"google.com\"" |
191 " }," | 191 " }," |
192 "]"), | 192 "]"), |
193 nullptr); | 193 nullptr); |
194 UpdateProviderPolicy(policy); | 194 UpdateProviderPolicy(policy); |
195 EXPECT_FALSE(store_->GetValue(bookmarks::prefs::kManagedBookmarks, NULL)); | 195 EXPECT_FALSE(store_->GetValue(bookmarks::prefs::kManagedBookmarks, NULL)); |
196 } | 196 } |
197 | 197 |
198 #if BUILDFLAG(ENABLE_EXTENSIONS) | 198 #if BUILDFLAG(ENABLE_EXTENSIONS) |
199 TEST_F(ManagedBookmarksPolicyHandlerTest, UnknownKeys) { | 199 TEST_F(ManagedBookmarksPolicyHandlerTest, UnknownKeys) { |
200 PolicyMap policy; | 200 PolicyMap policy; |
201 policy.Set(key::kManagedBookmarks, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 201 policy.Set(key::kManagedBookmarks, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
202 POLICY_SOURCE_CLOUD, | 202 POLICY_SOURCE_CLOUD, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 .Append(extensions::DictionaryBuilder() | 260 .Append(extensions::DictionaryBuilder() |
261 .Set("name", "Google") | 261 .Set("name", "Google") |
262 .Set("url", "http://google.com/") | 262 .Set("url", "http://google.com/") |
263 .Build()) | 263 .Build()) |
264 .Build()); | 264 .Build()); |
265 EXPECT_TRUE(pref_value->Equals(expected.get())); | 265 EXPECT_TRUE(pref_value->Equals(expected.get())); |
266 } | 266 } |
267 #endif | 267 #endif |
268 | 268 |
269 } // namespace policy | 269 } // namespace policy |
OLD | NEW |