| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cloud/cloud_policy_manager.h" | 5 #include "components/policy/core/common/cloud/cloud_policy_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 new CloudPolicyManager(dm_protocol::kChromeUserPolicyType, std::string(), | 81 new CloudPolicyManager(dm_protocol::kChromeUserPolicyType, std::string(), |
| 82 &store_, task_runner, task_runner, task_runner); | 82 &store_, task_runner, task_runner, task_runner); |
| 83 Mock::VerifyAndClearExpectations(&store_); | 83 Mock::VerifyAndClearExpectations(&store_); |
| 84 return provider; | 84 return provider; |
| 85 } | 85 } |
| 86 | 86 |
| 87 void TestHarness::InstallEmptyPolicy() {} | 87 void TestHarness::InstallEmptyPolicy() {} |
| 88 | 88 |
| 89 void TestHarness::InstallStringPolicy(const std::string& policy_name, | 89 void TestHarness::InstallStringPolicy(const std::string& policy_name, |
| 90 const std::string& policy_value) { | 90 const std::string& policy_value) { |
| 91 store_.policy_map_.Set( | 91 store_.policy_map_.Set(policy_name, policy_level(), policy_scope(), |
| 92 policy_name, policy_level(), policy_scope(), POLICY_SOURCE_CLOUD, | 92 POLICY_SOURCE_CLOUD, |
| 93 base::MakeUnique<base::StringValue>(policy_value), nullptr); | 93 base::MakeUnique<base::Value>(policy_value), nullptr); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void TestHarness::InstallIntegerPolicy(const std::string& policy_name, | 96 void TestHarness::InstallIntegerPolicy(const std::string& policy_name, |
| 97 int policy_value) { | 97 int policy_value) { |
| 98 store_.policy_map_.Set(policy_name, policy_level(), policy_scope(), | 98 store_.policy_map_.Set(policy_name, policy_level(), policy_scope(), |
| 99 POLICY_SOURCE_CLOUD, | 99 POLICY_SOURCE_CLOUD, |
| 100 base::MakeUnique<base::Value>(policy_value), nullptr); | 100 base::MakeUnique<base::Value>(policy_value), nullptr); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void TestHarness::InstallBooleanPolicy(const std::string& policy_name, | 103 void TestHarness::InstallBooleanPolicy(const std::string& policy_name, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 167 } |
| 168 | 168 |
| 169 class CloudPolicyManagerTest : public testing::Test { | 169 class CloudPolicyManagerTest : public testing::Test { |
| 170 protected: | 170 protected: |
| 171 CloudPolicyManagerTest() | 171 CloudPolicyManagerTest() |
| 172 : policy_type_(dm_protocol::kChromeUserPolicyType) {} | 172 : policy_type_(dm_protocol::kChromeUserPolicyType) {} |
| 173 | 173 |
| 174 void SetUp() override { | 174 void SetUp() override { |
| 175 // Set up a policy map for testing. | 175 // Set up a policy map for testing. |
| 176 policy_map_.Set("key", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 176 policy_map_.Set("key", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 177 POLICY_SOURCE_CLOUD, | 177 POLICY_SOURCE_CLOUD, base::MakeUnique<base::Value>("value"), |
| 178 base::MakeUnique<base::StringValue>("value"), nullptr); | 178 nullptr); |
| 179 expected_bundle_.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 179 expected_bundle_.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
| 180 .CopyFrom(policy_map_); | 180 .CopyFrom(policy_map_); |
| 181 | 181 |
| 182 policy_.payload().mutable_passwordmanagerenabled()->set_value(false); | 182 policy_.payload().mutable_passwordmanagerenabled()->set_value(false); |
| 183 policy_.Build(); | 183 policy_.Build(); |
| 184 | 184 |
| 185 EXPECT_CALL(store_, Load()); | 185 EXPECT_CALL(store_, Load()); |
| 186 manager_.reset(new TestCloudPolicyManager(&store_, loop_.task_runner())); | 186 manager_.reset(new TestCloudPolicyManager(&store_, loop_.task_runner())); |
| 187 manager_->Init(&schema_registry_); | 187 manager_->Init(&schema_registry_); |
| 188 Mock::VerifyAndClearExpectations(&store_); | 188 Mock::VerifyAndClearExpectations(&store_); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 store_.policy_.reset(new em::PolicyData(policy_.policy_data())); | 348 store_.policy_.reset(new em::PolicyData(policy_.policy_data())); |
| 349 EXPECT_CALL(observer_, OnUpdatePolicy(manager_.get())); | 349 EXPECT_CALL(observer_, OnUpdatePolicy(manager_.get())); |
| 350 store_.NotifyStoreError(); | 350 store_.NotifyStoreError(); |
| 351 Mock::VerifyAndClearExpectations(&observer_); | 351 Mock::VerifyAndClearExpectations(&observer_); |
| 352 | 352 |
| 353 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 353 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
| 354 } | 354 } |
| 355 | 355 |
| 356 } // namespace | 356 } // namespace |
| 357 } // namespace policy | 357 } // namespace policy |
| OLD | NEW |