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

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

Issue 388963002: Get rid of the rest of CreateStringValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad rebase 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/policy_map.h" 5 #include "components/policy/core/common/policy_map.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "components/policy/core/common/external_data_manager.h" 9 #include "components/policy/core/common/external_data_manager.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 }; 44 };
45 45
46 scoped_ptr<ExternalDataFetcher> PolicyMapTest::CreateExternalDataFetcher( 46 scoped_ptr<ExternalDataFetcher> PolicyMapTest::CreateExternalDataFetcher(
47 const std::string& policy) const { 47 const std::string& policy) const {
48 return make_scoped_ptr( 48 return make_scoped_ptr(
49 new ExternalDataFetcher(base::WeakPtr<ExternalDataManager>(), policy)); 49 new ExternalDataFetcher(base::WeakPtr<ExternalDataManager>(), policy));
50 } 50 }
51 51
52 TEST_F(PolicyMapTest, SetAndGet) { 52 TEST_F(PolicyMapTest, SetAndGet) {
53 PolicyMap map; 53 PolicyMap map;
54 SetPolicy(&map, kTestPolicyName1, base::Value::CreateStringValue("aaa")); 54 SetPolicy(&map, kTestPolicyName1, new base::StringValue("aaa"));
55 base::StringValue expected("aaa"); 55 base::StringValue expected("aaa");
56 EXPECT_TRUE(expected.Equals(map.GetValue(kTestPolicyName1))); 56 EXPECT_TRUE(expected.Equals(map.GetValue(kTestPolicyName1)));
57 SetPolicy(&map, kTestPolicyName1, base::Value::CreateStringValue("bbb")); 57 SetPolicy(&map, kTestPolicyName1, new base::StringValue("bbb"));
58 base::StringValue expected_b("bbb"); 58 base::StringValue expected_b("bbb");
59 EXPECT_TRUE(expected_b.Equals(map.GetValue(kTestPolicyName1))); 59 EXPECT_TRUE(expected_b.Equals(map.GetValue(kTestPolicyName1)));
60 SetPolicy(&map, kTestPolicyName1, 60 SetPolicy(&map, kTestPolicyName1,
61 CreateExternalDataFetcher("dummy").release()); 61 CreateExternalDataFetcher("dummy").release());
62 EXPECT_FALSE(map.GetValue(kTestPolicyName1)); 62 EXPECT_FALSE(map.GetValue(kTestPolicyName1));
63 const PolicyMap::Entry* entry = map.Get(kTestPolicyName1); 63 const PolicyMap::Entry* entry = map.Get(kTestPolicyName1);
64 ASSERT_TRUE(entry != NULL); 64 ASSERT_TRUE(entry != NULL);
65 EXPECT_EQ(POLICY_LEVEL_MANDATORY, entry->level); 65 EXPECT_EQ(POLICY_LEVEL_MANDATORY, entry->level);
66 EXPECT_EQ(POLICY_SCOPE_USER, entry->scope); 66 EXPECT_EQ(POLICY_SCOPE_USER, entry->scope);
67 EXPECT_TRUE(ExternalDataFetcher::Equals( 67 EXPECT_TRUE(ExternalDataFetcher::Equals(
68 entry->external_data_fetcher, CreateExternalDataFetcher("dummy").get())); 68 entry->external_data_fetcher, CreateExternalDataFetcher("dummy").get()));
69 map.Set(kTestPolicyName1, POLICY_LEVEL_RECOMMENDED, 69 map.Set(kTestPolicyName1, POLICY_LEVEL_RECOMMENDED,
70 POLICY_SCOPE_MACHINE, NULL, NULL); 70 POLICY_SCOPE_MACHINE, NULL, NULL);
71 EXPECT_FALSE(map.GetValue(kTestPolicyName1)); 71 EXPECT_FALSE(map.GetValue(kTestPolicyName1));
72 entry = map.Get(kTestPolicyName1); 72 entry = map.Get(kTestPolicyName1);
73 ASSERT_TRUE(entry != NULL); 73 ASSERT_TRUE(entry != NULL);
74 EXPECT_EQ(POLICY_LEVEL_RECOMMENDED, entry->level); 74 EXPECT_EQ(POLICY_LEVEL_RECOMMENDED, entry->level);
75 EXPECT_EQ(POLICY_SCOPE_MACHINE, entry->scope); 75 EXPECT_EQ(POLICY_SCOPE_MACHINE, entry->scope);
76 EXPECT_FALSE(entry->external_data_fetcher); 76 EXPECT_FALSE(entry->external_data_fetcher);
77 } 77 }
78 78
79 TEST_F(PolicyMapTest, Equals) { 79 TEST_F(PolicyMapTest, Equals) {
80 PolicyMap a; 80 PolicyMap a;
81 SetPolicy(&a, kTestPolicyName1, base::Value::CreateStringValue("aaa")); 81 SetPolicy(&a, kTestPolicyName1, new base::StringValue("aaa"));
82 PolicyMap a2; 82 PolicyMap a2;
83 SetPolicy(&a2, kTestPolicyName1, base::Value::CreateStringValue("aaa")); 83 SetPolicy(&a2, kTestPolicyName1, new base::StringValue("aaa"));
84 PolicyMap b; 84 PolicyMap b;
85 SetPolicy(&b, kTestPolicyName1, base::Value::CreateStringValue("bbb")); 85 SetPolicy(&b, kTestPolicyName1, new base::StringValue("bbb"));
86 PolicyMap c; 86 PolicyMap c;
87 SetPolicy(&c, kTestPolicyName1, base::Value::CreateStringValue("aaa")); 87 SetPolicy(&c, kTestPolicyName1, new base::StringValue("aaa"));
88 SetPolicy(&c, kTestPolicyName2, new base::FundamentalValue(true)); 88 SetPolicy(&c, kTestPolicyName2, new base::FundamentalValue(true));
89 PolicyMap d; 89 PolicyMap d;
90 SetPolicy(&d, kTestPolicyName1, 90 SetPolicy(&d, kTestPolicyName1,
91 CreateExternalDataFetcher("ddd").release()); 91 CreateExternalDataFetcher("ddd").release());
92 PolicyMap d2; 92 PolicyMap d2;
93 SetPolicy(&d2, kTestPolicyName1, 93 SetPolicy(&d2, kTestPolicyName1,
94 CreateExternalDataFetcher("ddd").release()); 94 CreateExternalDataFetcher("ddd").release());
95 PolicyMap e; 95 PolicyMap e;
96 SetPolicy(&e, kTestPolicyName1, 96 SetPolicy(&e, kTestPolicyName1,
97 CreateExternalDataFetcher("eee").release()); 97 CreateExternalDataFetcher("eee").release());
(...skipping 24 matching lines...) Expand all
122 PolicyMap empty1; 122 PolicyMap empty1;
123 PolicyMap empty2; 123 PolicyMap empty2;
124 EXPECT_TRUE(empty1.Equals(empty2)); 124 EXPECT_TRUE(empty1.Equals(empty2));
125 EXPECT_TRUE(empty2.Equals(empty1)); 125 EXPECT_TRUE(empty2.Equals(empty1));
126 EXPECT_FALSE(empty1.Equals(a)); 126 EXPECT_FALSE(empty1.Equals(a));
127 EXPECT_FALSE(a.Equals(empty1)); 127 EXPECT_FALSE(a.Equals(empty1));
128 } 128 }
129 129
130 TEST_F(PolicyMapTest, Swap) { 130 TEST_F(PolicyMapTest, Swap) {
131 PolicyMap a; 131 PolicyMap a;
132 SetPolicy(&a, kTestPolicyName1, base::Value::CreateStringValue("aaa")); 132 SetPolicy(&a, kTestPolicyName1, new base::StringValue("aaa"));
133 SetPolicy(&a, kTestPolicyName2, 133 SetPolicy(&a, kTestPolicyName2,
134 CreateExternalDataFetcher("dummy").release()); 134 CreateExternalDataFetcher("dummy").release());
135 PolicyMap b; 135 PolicyMap b;
136 SetPolicy(&b, kTestPolicyName1, base::Value::CreateStringValue("bbb")); 136 SetPolicy(&b, kTestPolicyName1, new base::StringValue("bbb"));
137 SetPolicy(&b, kTestPolicyName3, new base::FundamentalValue(true)); 137 SetPolicy(&b, kTestPolicyName3, new base::FundamentalValue(true));
138 138
139 a.Swap(&b); 139 a.Swap(&b);
140 base::StringValue expected("bbb"); 140 base::StringValue expected("bbb");
141 EXPECT_TRUE(expected.Equals(a.GetValue(kTestPolicyName1))); 141 EXPECT_TRUE(expected.Equals(a.GetValue(kTestPolicyName1)));
142 base::FundamentalValue expected_bool(true); 142 base::FundamentalValue expected_bool(true);
143 EXPECT_TRUE(expected_bool.Equals(a.GetValue(kTestPolicyName3))); 143 EXPECT_TRUE(expected_bool.Equals(a.GetValue(kTestPolicyName3)));
144 EXPECT_FALSE(a.GetValue(kTestPolicyName2)); 144 EXPECT_FALSE(a.GetValue(kTestPolicyName2));
145 EXPECT_FALSE(a.Get(kTestPolicyName2)); 145 EXPECT_FALSE(a.Get(kTestPolicyName2));
146 base::StringValue expected_a("aaa"); 146 base::StringValue expected_a("aaa");
147 EXPECT_TRUE(expected_a.Equals(b.GetValue(kTestPolicyName1))); 147 EXPECT_TRUE(expected_a.Equals(b.GetValue(kTestPolicyName1)));
148 EXPECT_FALSE(b.GetValue(kTestPolicyName3)); 148 EXPECT_FALSE(b.GetValue(kTestPolicyName3));
149 EXPECT_FALSE(a.GetValue(kTestPolicyName2)); 149 EXPECT_FALSE(a.GetValue(kTestPolicyName2));
150 const PolicyMap::Entry* entry = b.Get(kTestPolicyName2); 150 const PolicyMap::Entry* entry = b.Get(kTestPolicyName2);
151 ASSERT_TRUE(entry); 151 ASSERT_TRUE(entry);
152 EXPECT_TRUE(ExternalDataFetcher::Equals( 152 EXPECT_TRUE(ExternalDataFetcher::Equals(
153 CreateExternalDataFetcher("dummy").get(), entry->external_data_fetcher)); 153 CreateExternalDataFetcher("dummy").get(), entry->external_data_fetcher));
154 154
155 b.Clear(); 155 b.Clear();
156 a.Swap(&b); 156 a.Swap(&b);
157 PolicyMap empty; 157 PolicyMap empty;
158 EXPECT_TRUE(a.Equals(empty)); 158 EXPECT_TRUE(a.Equals(empty));
159 EXPECT_FALSE(b.Equals(empty)); 159 EXPECT_FALSE(b.Equals(empty));
160 } 160 }
161 161
162 TEST_F(PolicyMapTest, MergeFrom) { 162 TEST_F(PolicyMapTest, MergeFrom) {
163 PolicyMap a; 163 PolicyMap a;
164 a.Set(kTestPolicyName1, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 164 a.Set(kTestPolicyName1,
165 base::Value::CreateStringValue("google.com"), NULL); 165 POLICY_LEVEL_MANDATORY,
166 POLICY_SCOPE_USER,
167 new base::StringValue("google.com"),
168 NULL);
166 a.Set(kTestPolicyName2, 169 a.Set(kTestPolicyName2,
167 POLICY_LEVEL_MANDATORY, 170 POLICY_LEVEL_MANDATORY,
168 POLICY_SCOPE_MACHINE, 171 POLICY_SCOPE_MACHINE,
169 new base::FundamentalValue(true), 172 new base::FundamentalValue(true),
170 NULL); 173 NULL);
171 a.Set(kTestPolicyName3, 174 a.Set(kTestPolicyName3,
172 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 175 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
173 NULL, CreateExternalDataFetcher("a").release()); 176 NULL, CreateExternalDataFetcher("a").release());
174 a.Set(kTestPolicyName4, 177 a.Set(kTestPolicyName4,
175 POLICY_LEVEL_RECOMMENDED, 178 POLICY_LEVEL_RECOMMENDED,
176 POLICY_SCOPE_USER, 179 POLICY_SCOPE_USER,
177 new base::FundamentalValue(false), 180 new base::FundamentalValue(false),
178 NULL); 181 NULL);
179 a.Set(kTestPolicyName5, 182 a.Set(kTestPolicyName5,
180 POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_MACHINE, 183 POLICY_LEVEL_RECOMMENDED,
181 base::Value::CreateStringValue("google.com/q={x}"), NULL); 184 POLICY_SCOPE_MACHINE,
185 new base::StringValue("google.com/q={x}"),
186 NULL);
182 187
183 PolicyMap b; 188 PolicyMap b;
184 b.Set(kTestPolicyName1, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 189 b.Set(kTestPolicyName1,
185 base::Value::CreateStringValue("chromium.org"), NULL); 190 POLICY_LEVEL_MANDATORY,
191 POLICY_SCOPE_MACHINE,
192 new base::StringValue("chromium.org"),
193 NULL);
186 b.Set(kTestPolicyName2, 194 b.Set(kTestPolicyName2,
187 POLICY_LEVEL_MANDATORY, 195 POLICY_LEVEL_MANDATORY,
188 POLICY_SCOPE_MACHINE, 196 POLICY_SCOPE_MACHINE,
189 new base::FundamentalValue(false), 197 new base::FundamentalValue(false),
190 NULL); 198 NULL);
191 b.Set(kTestPolicyName3, 199 b.Set(kTestPolicyName3,
192 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 200 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
193 NULL, CreateExternalDataFetcher("b").release()); 201 NULL, CreateExternalDataFetcher("b").release());
194 b.Set(kTestPolicyName4, 202 b.Set(kTestPolicyName4,
195 POLICY_LEVEL_RECOMMENDED, 203 POLICY_LEVEL_RECOMMENDED,
196 POLICY_SCOPE_MACHINE, 204 POLICY_SCOPE_MACHINE,
197 new base::FundamentalValue(true), 205 new base::FundamentalValue(true),
198 NULL); 206 NULL);
199 b.Set(kTestPolicyName5, 207 b.Set(kTestPolicyName5,
200 POLICY_LEVEL_MANDATORY, 208 POLICY_LEVEL_MANDATORY,
201 POLICY_SCOPE_MACHINE, 209 POLICY_SCOPE_MACHINE,
202 base::Value::CreateStringValue(std::string()), 210 new base::StringValue(std::string()),
203 NULL); 211 NULL);
204 b.Set(kTestPolicyName6, 212 b.Set(kTestPolicyName6,
205 POLICY_LEVEL_RECOMMENDED, 213 POLICY_LEVEL_RECOMMENDED,
206 POLICY_SCOPE_USER, 214 POLICY_SCOPE_USER,
207 new base::FundamentalValue(true), 215 new base::FundamentalValue(true),
208 NULL); 216 NULL);
209 217
210 a.MergeFrom(b); 218 a.MergeFrom(b);
211 219
212 PolicyMap c; 220 PolicyMap c;
213 // POLICY_SCOPE_MACHINE over POLICY_SCOPE_USER. 221 // POLICY_SCOPE_MACHINE over POLICY_SCOPE_USER.
214 c.Set(kTestPolicyName1, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 222 c.Set(kTestPolicyName1,
215 base::Value::CreateStringValue("chromium.org"), NULL); 223 POLICY_LEVEL_MANDATORY,
224 POLICY_SCOPE_MACHINE,
225 new base::StringValue("chromium.org"),
226 NULL);
216 // |a| has precedence over |b|. 227 // |a| has precedence over |b|.
217 c.Set(kTestPolicyName2, 228 c.Set(kTestPolicyName2,
218 POLICY_LEVEL_MANDATORY, 229 POLICY_LEVEL_MANDATORY,
219 POLICY_SCOPE_MACHINE, 230 POLICY_SCOPE_MACHINE,
220 new base::FundamentalValue(true), 231 new base::FundamentalValue(true),
221 NULL); 232 NULL);
222 c.Set(kTestPolicyName3, 233 c.Set(kTestPolicyName3,
223 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 234 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
224 NULL, CreateExternalDataFetcher("a").release()); 235 NULL, CreateExternalDataFetcher("a").release());
225 // POLICY_SCOPE_MACHINE over POLICY_SCOPE_USER for POLICY_LEVEL_RECOMMENDED. 236 // POLICY_SCOPE_MACHINE over POLICY_SCOPE_USER for POLICY_LEVEL_RECOMMENDED.
226 c.Set(kTestPolicyName4, 237 c.Set(kTestPolicyName4,
227 POLICY_LEVEL_RECOMMENDED, 238 POLICY_LEVEL_RECOMMENDED,
228 POLICY_SCOPE_MACHINE, 239 POLICY_SCOPE_MACHINE,
229 new base::FundamentalValue(true), 240 new base::FundamentalValue(true),
230 NULL); 241 NULL);
231 // POLICY_LEVEL_MANDATORY over POLICY_LEVEL_RECOMMENDED. 242 // POLICY_LEVEL_MANDATORY over POLICY_LEVEL_RECOMMENDED.
232 c.Set(kTestPolicyName5, 243 c.Set(kTestPolicyName5,
233 POLICY_LEVEL_MANDATORY, 244 POLICY_LEVEL_MANDATORY,
234 POLICY_SCOPE_MACHINE, 245 POLICY_SCOPE_MACHINE,
235 base::Value::CreateStringValue(std::string()), 246 new base::StringValue(std::string()),
236 NULL); 247 NULL);
237 // Merge new ones. 248 // Merge new ones.
238 c.Set(kTestPolicyName6, 249 c.Set(kTestPolicyName6,
239 POLICY_LEVEL_RECOMMENDED, 250 POLICY_LEVEL_RECOMMENDED,
240 POLICY_SCOPE_USER, 251 POLICY_SCOPE_USER,
241 new base::FundamentalValue(true), 252 new base::FundamentalValue(true),
242 NULL); 253 NULL);
243 254
244 EXPECT_TRUE(a.Equals(c)); 255 EXPECT_TRUE(a.Equals(c));
245 } 256 }
246 257
247 TEST_F(PolicyMapTest, GetDifferingKeys) { 258 TEST_F(PolicyMapTest, GetDifferingKeys) {
248 PolicyMap a; 259 PolicyMap a;
249 a.Set(kTestPolicyName1, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 260 a.Set(kTestPolicyName1,
250 base::Value::CreateStringValue("google.com"), NULL); 261 POLICY_LEVEL_MANDATORY,
262 POLICY_SCOPE_USER,
263 new base::StringValue("google.com"),
264 NULL);
251 a.Set(kTestPolicyName2, 265 a.Set(kTestPolicyName2,
252 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 266 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
253 NULL, CreateExternalDataFetcher("dummy").release()); 267 NULL, CreateExternalDataFetcher("dummy").release());
254 a.Set(kTestPolicyName3, 268 a.Set(kTestPolicyName3,
255 POLICY_LEVEL_MANDATORY, 269 POLICY_LEVEL_MANDATORY,
256 POLICY_SCOPE_MACHINE, 270 POLICY_SCOPE_MACHINE,
257 new base::FundamentalValue(true), 271 new base::FundamentalValue(true),
258 NULL); 272 NULL);
259 a.Set(kTestPolicyName4, 273 a.Set(kTestPolicyName4,
260 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 274 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
261 NULL, CreateExternalDataFetcher("a").release()); 275 NULL, CreateExternalDataFetcher("a").release());
262 a.Set(kTestPolicyName5, 276 a.Set(kTestPolicyName5,
263 POLICY_LEVEL_RECOMMENDED, 277 POLICY_LEVEL_RECOMMENDED,
264 POLICY_SCOPE_USER, 278 POLICY_SCOPE_USER,
265 new base::FundamentalValue(false), 279 new base::FundamentalValue(false),
266 NULL); 280 NULL);
267 a.Set(kTestPolicyName6, 281 a.Set(kTestPolicyName6,
268 POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_MACHINE, 282 POLICY_LEVEL_RECOMMENDED,
269 base::Value::CreateStringValue("google.com/q={x}"), NULL); 283 POLICY_SCOPE_MACHINE,
284 new base::StringValue("google.com/q={x}"),
285 NULL);
270 a.Set(kTestPolicyName7, 286 a.Set(kTestPolicyName7,
271 POLICY_LEVEL_MANDATORY, 287 POLICY_LEVEL_MANDATORY,
272 POLICY_SCOPE_USER, 288 POLICY_SCOPE_USER,
273 new base::FundamentalValue(true), 289 new base::FundamentalValue(true),
274 NULL); 290 NULL);
275 291
276 PolicyMap b; 292 PolicyMap b;
277 b.Set(kTestPolicyName1, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 293 b.Set(kTestPolicyName1,
278 base::Value::CreateStringValue("google.com"), NULL); 294 POLICY_LEVEL_MANDATORY,
295 POLICY_SCOPE_USER,
296 new base::StringValue("google.com"),
297 NULL);
279 b.Set(kTestPolicyName2, 298 b.Set(kTestPolicyName2,
280 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 299 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
281 NULL, CreateExternalDataFetcher("dummy").release()); 300 NULL, CreateExternalDataFetcher("dummy").release());
282 b.Set(kTestPolicyName3, 301 b.Set(kTestPolicyName3,
283 POLICY_LEVEL_MANDATORY, 302 POLICY_LEVEL_MANDATORY,
284 POLICY_SCOPE_MACHINE, 303 POLICY_SCOPE_MACHINE,
285 new base::FundamentalValue(false), 304 new base::FundamentalValue(false),
286 NULL); 305 NULL);
287 b.Set(kTestPolicyName4, 306 b.Set(kTestPolicyName4,
288 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 307 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
289 NULL, CreateExternalDataFetcher("b").release()); 308 NULL, CreateExternalDataFetcher("b").release());
290 b.Set(kTestPolicyName5, 309 b.Set(kTestPolicyName5,
291 POLICY_LEVEL_MANDATORY, 310 POLICY_LEVEL_MANDATORY,
292 POLICY_SCOPE_USER, 311 POLICY_SCOPE_USER,
293 new base::FundamentalValue(false), 312 new base::FundamentalValue(false),
294 NULL); 313 NULL);
295 b.Set(kTestPolicyName6, POLICY_LEVEL_RECOMMENDED, 314 b.Set(kTestPolicyName6,
296 POLICY_SCOPE_USER, base::Value::CreateStringValue("google.com/q={x}"), 315 POLICY_LEVEL_RECOMMENDED,
316 POLICY_SCOPE_USER,
317 new base::StringValue("google.com/q={x}"),
297 NULL); 318 NULL);
298 b.Set(kTestPolicyName8, 319 b.Set(kTestPolicyName8,
299 POLICY_LEVEL_RECOMMENDED, 320 POLICY_LEVEL_RECOMMENDED,
300 POLICY_SCOPE_USER, 321 POLICY_SCOPE_USER,
301 new base::FundamentalValue(true), 322 new base::FundamentalValue(true),
302 NULL); 323 NULL);
303 324
304 std::set<std::string> diff; 325 std::set<std::string> diff;
305 std::set<std::string> diff2; 326 std::set<std::string> diff2;
306 a.GetDifferingKeys(b, &diff); 327 a.GetDifferingKeys(b, &diff);
(...skipping 13 matching lines...) Expand all
320 EXPECT_TRUE(diff.find(kTestPolicyName6) != diff.end()); 341 EXPECT_TRUE(diff.find(kTestPolicyName6) != diff.end());
321 // Not in |a|. 342 // Not in |a|.
322 EXPECT_TRUE(diff.find(kTestPolicyName8) != diff.end()); 343 EXPECT_TRUE(diff.find(kTestPolicyName8) != diff.end());
323 // Not in |b|. 344 // Not in |b|.
324 EXPECT_TRUE(diff.find(kTestPolicyName7) != diff.end()); 345 EXPECT_TRUE(diff.find(kTestPolicyName7) != diff.end());
325 // No surprises. 346 // No surprises.
326 EXPECT_EQ(6u, diff.size()); 347 EXPECT_EQ(6u, diff.size());
327 } 348 }
328 349
329 } // namespace policy 350 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698