| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/configuration_policy_provider_test.h" | 5 #include "chrome/browser/policy/configuration_policy_provider_test.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/policy/asynchronous_policy_loader.h" | 9 #include "chrome/browser/policy/asynchronous_policy_loader.h" |
| 10 #include "chrome/browser/policy/asynchronous_policy_provider.h" | 10 #include "chrome/browser/policy/asynchronous_policy_provider.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 AsynchronousPolicyTestBase::TearDown(); | 69 AsynchronousPolicyTestBase::TearDown(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void ConfigurationPolicyProviderTest::CheckValue( | 72 void ConfigurationPolicyProviderTest::CheckValue( |
| 73 const char* policy_name, | 73 const char* policy_name, |
| 74 ConfigurationPolicyType policy_type, | 74 ConfigurationPolicyType policy_type, |
| 75 const base::Value& expected_value, | 75 const base::Value& expected_value, |
| 76 base::Closure install_value) { | 76 base::Closure install_value) { |
| 77 // Install the value, reload policy and check the provider for the value. | 77 // Install the value, reload policy and check the provider for the value. |
| 78 install_value.Run(); | 78 install_value.Run(); |
| 79 provider_->ForceReload(); | 79 provider_->RefreshPolicies(); |
| 80 loop_.RunAllPending(); | 80 loop_.RunAllPending(); |
| 81 PolicyMap policy_map; | 81 PolicyMap policy_map; |
| 82 EXPECT_TRUE(provider_->Provide(&policy_map)); | 82 EXPECT_TRUE(provider_->Provide(&policy_map)); |
| 83 EXPECT_EQ(1U, policy_map.size()); | 83 EXPECT_EQ(1U, policy_map.size()); |
| 84 EXPECT_TRUE(base::Value::Equals(&expected_value, | 84 EXPECT_TRUE(base::Value::Equals(&expected_value, |
| 85 policy_map.Get(policy_type))); | 85 policy_map.Get(policy_type))); |
| 86 } | 86 } |
| 87 | 87 |
| 88 TEST_P(ConfigurationPolicyProviderTest, Empty) { | 88 TEST_P(ConfigurationPolicyProviderTest, Empty) { |
| 89 provider_->ForceReload(); | 89 provider_->RefreshPolicies(); |
| 90 loop_.RunAllPending(); | 90 loop_.RunAllPending(); |
| 91 PolicyMap policy_map; | 91 PolicyMap policy_map; |
| 92 EXPECT_TRUE(provider_->Provide(&policy_map)); | 92 EXPECT_TRUE(provider_->Provide(&policy_map)); |
| 93 EXPECT_TRUE(policy_map.empty()); | 93 EXPECT_TRUE(policy_map.empty()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 TEST_P(ConfigurationPolicyProviderTest, StringValue) { | 96 TEST_P(ConfigurationPolicyProviderTest, StringValue) { |
| 97 const char kTestString[] = "string_value"; | 97 const char kTestString[] = "string_value"; |
| 98 StringValue expected_value(kTestString); | 98 StringValue expected_value(kTestString); |
| 99 CheckValue(test_policy_definitions::kKeyString, | 99 CheckValue(test_policy_definitions::kKeyString, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 CheckValue(test_policy_definitions::kKeyStringList, | 134 CheckValue(test_policy_definitions::kKeyStringList, |
| 135 test_policy_definitions::kPolicyStringList, | 135 test_policy_definitions::kPolicyStringList, |
| 136 expected_value, | 136 expected_value, |
| 137 base::Bind(&PolicyProviderTestHarness::InstallStringListPolicy, | 137 base::Bind(&PolicyProviderTestHarness::InstallStringListPolicy, |
| 138 base::Unretained(test_harness_.get()), | 138 base::Unretained(test_harness_.get()), |
| 139 test_policy_definitions::kKeyStringList, | 139 test_policy_definitions::kKeyStringList, |
| 140 &expected_value)); | 140 &expected_value)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace policy | 143 } // namespace policy |
| OLD | NEW |