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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 MATCHER_P(ProtoMatches, proto, "") { | 170 MATCHER_P(ProtoMatches, proto, "") { |
171 return arg.SerializePartialAsString() == proto.SerializePartialAsString(); | 171 return arg.SerializePartialAsString() == proto.SerializePartialAsString(); |
172 } | 172 } |
173 | 173 |
174 class CloudPolicyManagerTest : public testing::Test { | 174 class CloudPolicyManagerTest : public testing::Test { |
175 protected: | 175 protected: |
176 CloudPolicyManagerTest() | 176 CloudPolicyManagerTest() |
177 : policy_ns_key_(dm_protocol::kChromeUserPolicyType, std::string()) {} | 177 : policy_ns_key_(dm_protocol::kChromeUserPolicyType, std::string()) {} |
178 | 178 |
179 virtual void SetUp() override { | 179 void SetUp() override { |
180 // Set up a policy map for testing. | 180 // Set up a policy map for testing. |
181 policy_map_.Set("key", | 181 policy_map_.Set("key", |
182 POLICY_LEVEL_MANDATORY, | 182 POLICY_LEVEL_MANDATORY, |
183 POLICY_SCOPE_USER, | 183 POLICY_SCOPE_USER, |
184 new base::StringValue("value"), | 184 new base::StringValue("value"), |
185 NULL); | 185 NULL); |
186 expected_bundle_.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 186 expected_bundle_.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
187 .CopyFrom(policy_map_); | 187 .CopyFrom(policy_map_); |
188 | 188 |
189 policy_.payload().mutable_passwordmanagerenabled()->set_value(false); | 189 policy_.payload().mutable_passwordmanagerenabled()->set_value(false); |
190 policy_.Build(); | 190 policy_.Build(); |
191 | 191 |
192 EXPECT_CALL(store_, Load()); | 192 EXPECT_CALL(store_, Load()); |
193 manager_.reset(new TestCloudPolicyManager(&store_, | 193 manager_.reset(new TestCloudPolicyManager(&store_, |
194 loop_.message_loop_proxy())); | 194 loop_.message_loop_proxy())); |
195 manager_->Init(&schema_registry_); | 195 manager_->Init(&schema_registry_); |
196 Mock::VerifyAndClearExpectations(&store_); | 196 Mock::VerifyAndClearExpectations(&store_); |
197 manager_->AddObserver(&observer_); | 197 manager_->AddObserver(&observer_); |
198 } | 198 } |
199 | 199 |
200 virtual void TearDown() override { | 200 void TearDown() override { |
201 manager_->RemoveObserver(&observer_); | 201 manager_->RemoveObserver(&observer_); |
202 manager_->Shutdown(); | 202 manager_->Shutdown(); |
203 } | 203 } |
204 | 204 |
205 // Required by the refresh scheduler that's created by the manager. | 205 // Required by the refresh scheduler that's created by the manager. |
206 base::MessageLoop loop_; | 206 base::MessageLoop loop_; |
207 | 207 |
208 // Testing policy. | 208 // Testing policy. |
209 const PolicyNamespaceKey policy_ns_key_; | 209 const PolicyNamespaceKey policy_ns_key_; |
210 UserPolicyBuilder policy_; | 210 UserPolicyBuilder policy_; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 store_.policy_.reset(new em::PolicyData(policy_.policy_data())); | 356 store_.policy_.reset(new em::PolicyData(policy_.policy_data())); |
357 EXPECT_CALL(observer_, OnUpdatePolicy(manager_.get())); | 357 EXPECT_CALL(observer_, OnUpdatePolicy(manager_.get())); |
358 store_.NotifyStoreError(); | 358 store_.NotifyStoreError(); |
359 Mock::VerifyAndClearExpectations(&observer_); | 359 Mock::VerifyAndClearExpectations(&observer_); |
360 | 360 |
361 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 361 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
362 } | 362 } |
363 | 363 |
364 } // namespace | 364 } // namespace |
365 } // namespace policy | 365 } // namespace policy |
OLD | NEW |