OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/schema_map.h" | 5 #include "chrome/browser/policy/schema_map.h" |
6 | 6 |
7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/policy/external_data_fetcher.h" | 9 #include "chrome/browser/policy/external_data_fetcher.h" |
10 #include "chrome/browser/policy/external_data_manager.h" | 10 #include "chrome/browser/policy/external_data_manager.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 bundle.Get(unknown_ns).Set("Surprise", | 271 bundle.Get(unknown_ns).Set("Surprise", |
272 POLICY_LEVEL_MANDATORY, | 272 POLICY_LEVEL_MANDATORY, |
273 POLICY_SCOPE_USER, | 273 POLICY_SCOPE_USER, |
274 base::Value::CreateStringValue("value 5"), | 274 base::Value::CreateStringValue("value 5"), |
275 NULL); | 275 NULL); |
276 | 276 |
277 schema_map->FilterBundle(&bundle); | 277 schema_map->FilterBundle(&bundle); |
278 EXPECT_TRUE(bundle.Equals(expected_bundle)); | 278 EXPECT_TRUE(bundle.Equals(expected_bundle)); |
279 } | 279 } |
280 | 280 |
| 281 TEST_F(SchemaMapTest, GetChanges) { |
| 282 DomainMap map; |
| 283 map[POLICY_DOMAIN_CHROME][""] = Schema(); |
| 284 scoped_refptr<SchemaMap> older = new SchemaMap(map); |
| 285 map[POLICY_DOMAIN_CHROME][""] = Schema(); |
| 286 scoped_refptr<SchemaMap> newer = new SchemaMap(map); |
| 287 |
| 288 PolicyNamespaceList removed; |
| 289 PolicyNamespaceList added; |
| 290 newer->GetChanges(older, &removed, &added); |
| 291 EXPECT_TRUE(removed.empty()); |
| 292 EXPECT_TRUE(added.empty()); |
| 293 |
| 294 map[POLICY_DOMAIN_CHROME][""] = Schema(); |
| 295 map[POLICY_DOMAIN_EXTENSIONS]["xyz"] = Schema(); |
| 296 newer = new SchemaMap(map); |
| 297 newer->GetChanges(older, &removed, &added); |
| 298 EXPECT_TRUE(removed.empty()); |
| 299 ASSERT_EQ(1u, added.size()); |
| 300 EXPECT_EQ(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "xyz"), added[0]); |
| 301 |
| 302 older = newer; |
| 303 map[POLICY_DOMAIN_EXTENSIONS]["abc"] = Schema(); |
| 304 newer = new SchemaMap(map); |
| 305 newer->GetChanges(older, &removed, &added); |
| 306 ASSERT_EQ(2u, removed.size()); |
| 307 EXPECT_EQ(PolicyNamespace(POLICY_DOMAIN_CHROME, ""), removed[0]); |
| 308 EXPECT_EQ(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "xyz"), removed[1]); |
| 309 ASSERT_EQ(1u, added.size()); |
| 310 EXPECT_EQ(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"), added[0]); |
| 311 } |
| 312 |
281 } // namespace policy | 313 } // namespace policy |
OLD | NEW |