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

Side by Side Diff: chrome/browser/policy/schema_map_unittest.cc

Issue 68933002: Added SchemaMap::GetChanges(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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
« no previous file with comments | « chrome/browser/policy/schema_map.cc ('k') | components/policy/core/common/policy_namespace.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « chrome/browser/policy/schema_map.cc ('k') | components/policy/core/common/policy_namespace.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698