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 "components/policy/core/common/configuration_policy_provider_test.h" | 5 #include "components/policy/core/common/configuration_policy_provider_test.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 CheckValue(test_keys::kKeyInteger, | 277 CheckValue(test_keys::kKeyInteger, |
278 expected_value, | 278 expected_value, |
279 base::Bind(&PolicyProviderTestHarness::InstallIntegerPolicy, | 279 base::Bind(&PolicyProviderTestHarness::InstallIntegerPolicy, |
280 base::Unretained(test_harness_.get()), | 280 base::Unretained(test_harness_.get()), |
281 test_keys::kKeyInteger, | 281 test_keys::kKeyInteger, |
282 42)); | 282 42)); |
283 } | 283 } |
284 | 284 |
285 TEST_P(ConfigurationPolicyProviderTest, StringListValue) { | 285 TEST_P(ConfigurationPolicyProviderTest, StringListValue) { |
286 base::ListValue expected_value; | 286 base::ListValue expected_value; |
287 expected_value.Set(0U, new base::Value("first")); | 287 expected_value.AppendString("first"); |
288 expected_value.Set(1U, new base::Value("second")); | 288 expected_value.AppendString("second"); |
289 CheckValue(test_keys::kKeyStringList, | 289 CheckValue(test_keys::kKeyStringList, |
290 expected_value, | 290 expected_value, |
291 base::Bind(&PolicyProviderTestHarness::InstallStringListPolicy, | 291 base::Bind(&PolicyProviderTestHarness::InstallStringListPolicy, |
292 base::Unretained(test_harness_.get()), | 292 base::Unretained(test_harness_.get()), |
293 test_keys::kKeyStringList, | 293 test_keys::kKeyStringList, |
294 &expected_value)); | 294 &expected_value)); |
295 } | 295 } |
296 | 296 |
297 TEST_P(ConfigurationPolicyProviderTest, DictionaryValue) { | 297 TEST_P(ConfigurationPolicyProviderTest, DictionaryValue) { |
298 base::DictionaryValue expected_value; | 298 base::DictionaryValue expected_value; |
299 expected_value.SetBoolean("bool", true); | 299 expected_value.SetBoolean("bool", true); |
300 expected_value.SetDouble("double", 123.456); | 300 expected_value.SetDouble("double", 123.456); |
301 expected_value.SetInteger("int", 123); | 301 expected_value.SetInteger("int", 123); |
302 expected_value.SetString("string", "omg"); | 302 expected_value.SetString("string", "omg"); |
303 | 303 |
304 base::ListValue* list = new base::ListValue(); | 304 base::ListValue* list = new base::ListValue(); |
305 list->Set(0U, new base::Value("first")); | 305 list->AppendString("first"); |
306 list->Set(1U, new base::Value("second")); | 306 list->AppendString("second"); |
307 expected_value.Set("array", list); | 307 expected_value.Set("array", list); |
308 | 308 |
309 base::DictionaryValue* dict = new base::DictionaryValue(); | 309 base::DictionaryValue* dict = new base::DictionaryValue(); |
310 dict->SetString("sub", "value"); | 310 dict->SetString("sub", "value"); |
311 list = new base::ListValue(); | 311 list = new base::ListValue(); |
312 std::unique_ptr<base::DictionaryValue> sub(new base::DictionaryValue()); | 312 std::unique_ptr<base::DictionaryValue> sub(new base::DictionaryValue()); |
313 sub->SetInteger("aaa", 111); | 313 sub->SetInteger("aaa", 111); |
314 sub->SetInteger("bbb", 222); | 314 sub->SetInteger("bbb", 222); |
315 list->Append(std::move(sub)); | 315 list->Append(std::move(sub)); |
316 sub.reset(new base::DictionaryValue()); | 316 sub.reset(new base::DictionaryValue()); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, | 415 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, |
416 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) | 416 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) |
417 .CopyFrom(expected_policy); | 417 .CopyFrom(expected_policy); |
418 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, | 418 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, |
419 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) | 419 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) |
420 .CopyFrom(expected_policy); | 420 .CopyFrom(expected_policy); |
421 EXPECT_TRUE(provider_->policies().Equals(expected_bundle)); | 421 EXPECT_TRUE(provider_->policies().Equals(expected_bundle)); |
422 } | 422 } |
423 | 423 |
424 } // namespace policy | 424 } // namespace policy |
OLD | NEW |