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

Side by Side Diff: components/policy/core/common/schema_map_unittest.cc

Issue 383263005: Remove more CreateIntegerValue calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/SetBoolean/SetInteger Created 6 years, 5 months 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
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 "components/policy/core/common/schema_map.h" 5 #include "components/policy/core/common/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 "components/policy/core/common/external_data_fetcher.h" 9 #include "components/policy/core/common/external_data_fetcher.h"
10 #include "components/policy/core/common/external_data_manager.h" 10 #include "components/policy/core/common/external_data_manager.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 PolicyNamespace extension_ns(POLICY_DOMAIN_EXTENSIONS, "abc"); 159 PolicyNamespace extension_ns(POLICY_DOMAIN_EXTENSIONS, "abc");
160 PolicyMap& map = expected_bundle.Get(extension_ns); 160 PolicyMap& map = expected_bundle.Get(extension_ns);
161 base::ListValue list; 161 base::ListValue list;
162 list.AppendString("a"); 162 list.AppendString("a");
163 list.AppendString("b"); 163 list.AppendString("b");
164 map.Set("list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 164 map.Set("list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
165 list.DeepCopy(), NULL); 165 list.DeepCopy(), NULL);
166 map.Set("boolean", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 166 map.Set("boolean", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
167 base::Value::CreateBooleanValue(true), NULL); 167 base::Value::CreateBooleanValue(true), NULL);
168 map.Set("integer", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 168 map.Set("integer",
169 base::Value::CreateIntegerValue(1), NULL); 169 POLICY_LEVEL_MANDATORY,
170 POLICY_SCOPE_USER,
171 new base::FundamentalValue(1),
172 NULL);
170 map.Set("null", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 173 map.Set("null", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
171 base::Value::CreateNullValue(), NULL); 174 base::Value::CreateNullValue(), NULL);
172 map.Set("double", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 175 map.Set("double", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
173 base::Value::CreateDoubleValue(1.2), NULL); 176 base::Value::CreateDoubleValue(1.2), NULL);
174 base::DictionaryValue dict; 177 base::DictionaryValue dict;
175 dict.SetString("a", "b"); 178 dict.SetString("a", "b");
176 dict.SetInteger("b", 2); 179 dict.SetInteger("b", 2);
177 map.Set("object", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 180 map.Set("object", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
178 dict.DeepCopy(), NULL); 181 dict.DeepCopy(), NULL);
179 map.Set("string", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 182 map.Set("string", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
180 base::Value::CreateStringValue("value"), NULL); 183 base::Value::CreateStringValue("value"), NULL);
181 184
182 bundle.MergeFrom(expected_bundle); 185 bundle.MergeFrom(expected_bundle);
183 bundle.Get(extension_ns).Set("Unexpected", 186 bundle.Get(extension_ns).Set("Unexpected",
184 POLICY_LEVEL_MANDATORY, 187 POLICY_LEVEL_MANDATORY,
185 POLICY_SCOPE_USER, 188 POLICY_SCOPE_USER,
186 base::Value::CreateStringValue("to-be-removed"), 189 base::Value::CreateStringValue("to-be-removed"),
187 NULL); 190 NULL);
188 191
189 schema_map->FilterBundle(&bundle); 192 schema_map->FilterBundle(&bundle);
190 EXPECT_TRUE(bundle.Equals(expected_bundle)); 193 EXPECT_TRUE(bundle.Equals(expected_bundle));
191 194
192 // Mismatched types are also removed. 195 // Mismatched types are also removed.
193 bundle.Clear(); 196 bundle.Clear();
194 PolicyMap& badmap = bundle.Get(extension_ns); 197 PolicyMap& badmap = bundle.Get(extension_ns);
195 badmap.Set("list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 198 badmap.Set("list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
196 base::Value::CreateBooleanValue(false), NULL); 199 base::Value::CreateBooleanValue(false), NULL);
197 badmap.Set("boolean", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 200 badmap.Set("boolean",
198 base::Value::CreateIntegerValue(0), NULL); 201 POLICY_LEVEL_MANDATORY,
202 POLICY_SCOPE_USER,
203 new base::FundamentalValue(0),
204 NULL);
199 badmap.Set("integer", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 205 badmap.Set("integer", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
200 base::Value::CreateBooleanValue(false), NULL); 206 base::Value::CreateBooleanValue(false), NULL);
201 badmap.Set("null", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 207 badmap.Set("null", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
202 base::Value::CreateBooleanValue(false), NULL); 208 base::Value::CreateBooleanValue(false), NULL);
203 badmap.Set("double", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 209 badmap.Set("double", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
204 base::Value::CreateBooleanValue(false), NULL); 210 base::Value::CreateBooleanValue(false), NULL);
205 badmap.Set("object", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 211 badmap.Set("object", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
206 base::Value::CreateBooleanValue(false), NULL); 212 base::Value::CreateBooleanValue(false), NULL);
207 badmap.Set("string", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 213 badmap.Set("string", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
208 NULL, 214 NULL,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 newer = new SchemaMap(map); 310 newer = new SchemaMap(map);
305 newer->GetChanges(older, &removed, &added); 311 newer->GetChanges(older, &removed, &added);
306 ASSERT_EQ(2u, removed.size()); 312 ASSERT_EQ(2u, removed.size());
307 EXPECT_EQ(PolicyNamespace(POLICY_DOMAIN_CHROME, ""), removed[0]); 313 EXPECT_EQ(PolicyNamespace(POLICY_DOMAIN_CHROME, ""), removed[0]);
308 EXPECT_EQ(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "xyz"), removed[1]); 314 EXPECT_EQ(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "xyz"), removed[1]);
309 ASSERT_EQ(1u, added.size()); 315 ASSERT_EQ(1u, added.size());
310 EXPECT_EQ(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"), added[0]); 316 EXPECT_EQ(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"), added[0]);
311 } 317 }
312 318
313 } // namespace policy 319 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/registry_dict_win.cc ('k') | components/policy/tools/generate_policy_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698