| 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 .Build()) | 174 .Build()) |
| 175 .Build()); | 175 .Build()); |
| 176 EXPECT_TRUE(pref_value->Equals(expected.get())); | 176 EXPECT_TRUE(pref_value->Equals(expected.get())); |
| 177 } | 177 } |
| 178 #endif // defined(ENABLE_EXTENSIONS) | 178 #endif // defined(ENABLE_EXTENSIONS) |
| 179 | 179 |
| 180 TEST_F(ManagedBookmarksPolicyHandlerTest, WrongPolicyType) { | 180 TEST_F(ManagedBookmarksPolicyHandlerTest, WrongPolicyType) { |
| 181 PolicyMap policy; | 181 PolicyMap policy; |
| 182 // The expected type is base::ListValue, but this policy sets it as an | 182 // The expected type is base::ListValue, but this policy sets it as an |
| 183 // unparsed base::StringValue. Any type other than ListValue should fail. | 183 // unparsed base::StringValue. Any type other than ListValue should fail. |
| 184 policy.Set( | 184 policy.Set(key::kManagedBookmarks, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 185 key::kManagedBookmarks, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 185 POLICY_SOURCE_CLOUD, |
| 186 POLICY_SOURCE_CLOUD, | 186 base::MakeUnique<base::StringValue>("[" |
| 187 base::WrapUnique(new base::StringValue("[" | 187 " {" |
| 188 " {" | 188 " \"name\": \"Google\"," |
| 189 " \"name\": \"Google\"," | 189 " \"url\": \"google.com\"" |
| 190 " \"url\": \"google.com\"" | 190 " }," |
| 191 " }," | 191 "]"), |
| 192 "]")), | 192 nullptr); |
| 193 nullptr); | |
| 194 UpdateProviderPolicy(policy); | 193 UpdateProviderPolicy(policy); |
| 195 EXPECT_FALSE(store_->GetValue(bookmarks::prefs::kManagedBookmarks, NULL)); | 194 EXPECT_FALSE(store_->GetValue(bookmarks::prefs::kManagedBookmarks, NULL)); |
| 196 } | 195 } |
| 197 | 196 |
| 198 #if defined(ENABLE_EXTENSIONS) | 197 #if defined(ENABLE_EXTENSIONS) |
| 199 TEST_F(ManagedBookmarksPolicyHandlerTest, UnknownKeys) { | 198 TEST_F(ManagedBookmarksPolicyHandlerTest, UnknownKeys) { |
| 200 PolicyMap policy; | 199 PolicyMap policy; |
| 201 policy.Set(key::kManagedBookmarks, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 200 policy.Set(key::kManagedBookmarks, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 202 POLICY_SOURCE_CLOUD, | 201 POLICY_SOURCE_CLOUD, |
| 203 base::JSONReader::Read("[" | 202 base::JSONReader::Read("[" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 .Append(extensions::DictionaryBuilder() | 259 .Append(extensions::DictionaryBuilder() |
| 261 .Set("name", "Google") | 260 .Set("name", "Google") |
| 262 .Set("url", "http://google.com/") | 261 .Set("url", "http://google.com/") |
| 263 .Build()) | 262 .Build()) |
| 264 .Build()); | 263 .Build()); |
| 265 EXPECT_TRUE(pref_value->Equals(expected.get())); | 264 EXPECT_TRUE(pref_value->Equals(expected.get())); |
| 266 } | 265 } |
| 267 #endif | 266 #endif |
| 268 | 267 |
| 269 } // namespace policy | 268 } // namespace policy |
| OLD | NEW |