OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/cloud/component_cloud_policy_service.h" | 5 #include "components/policy/core/common/cloud/component_cloud_policy_service.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
| 9 #include <utility> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 17 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
17 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" | 18 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" |
18 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" | 19 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 RunUntilIdle(); | 147 RunUntilIdle(); |
147 } | 148 } |
148 | 149 |
149 void RunUntilIdle() { | 150 void RunUntilIdle() { |
150 base::RunLoop().RunUntilIdle(); | 151 base::RunLoop().RunUntilIdle(); |
151 } | 152 } |
152 | 153 |
153 void Connect() { | 154 void Connect() { |
154 client_ = new MockCloudPolicyClient(); | 155 client_ = new MockCloudPolicyClient(); |
155 service_.reset(new ComponentCloudPolicyService( | 156 service_.reset(new ComponentCloudPolicyService( |
156 &delegate_, ®istry_, &core_, client_, owned_cache_.Pass(), | 157 &delegate_, ®istry_, &core_, client_, std::move(owned_cache_), |
157 request_context_, loop_.task_runner(), loop_.task_runner())); | 158 request_context_, loop_.task_runner(), loop_.task_runner())); |
158 | 159 |
159 client_->SetDMToken(ComponentPolicyBuilder::kFakeToken); | 160 client_->SetDMToken(ComponentPolicyBuilder::kFakeToken); |
160 EXPECT_EQ(1u, client_->types_to_fetch_.size()); | 161 EXPECT_EQ(1u, client_->types_to_fetch_.size()); |
161 core_.Connect(scoped_ptr<CloudPolicyClient>(client_)); | 162 core_.Connect(scoped_ptr<CloudPolicyClient>(client_)); |
162 EXPECT_EQ(2u, client_->types_to_fetch_.size()); | 163 EXPECT_EQ(2u, client_->types_to_fetch_.size()); |
163 | 164 |
164 // Also initialize the refresh scheduler, so that calls to | 165 // Also initialize the refresh scheduler, so that calls to |
165 // core()->RefreshSoon() trigger a FetchPolicy() call on the mock |client_|. | 166 // core()->RefreshSoon() trigger a FetchPolicy() call on the mock |client_|. |
166 // The |service_| should never trigger new fetches. | 167 // The |service_| should never trigger new fetches. |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 EXPECT_TRUE(ContainsKey(contents, kTestExtension)); | 576 EXPECT_TRUE(ContainsKey(contents, kTestExtension)); |
576 EXPECT_FALSE(ContainsKey(contents, kTestExtension2)); | 577 EXPECT_FALSE(ContainsKey(contents, kTestExtension2)); |
577 | 578 |
578 // And the service isn't publishing policy for the second extension anymore. | 579 // And the service isn't publishing policy for the second extension anymore. |
579 expected_bundle.Clear(); | 580 expected_bundle.Clear(); |
580 expected_bundle.Get(ns).CopyFrom(expected_policy_); | 581 expected_bundle.Get(ns).CopyFrom(expected_policy_); |
581 EXPECT_TRUE(service_->policy().Equals(expected_bundle)); | 582 EXPECT_TRUE(service_->policy().Equals(expected_bundle)); |
582 } | 583 } |
583 | 584 |
584 } // namespace policy | 585 } // namespace policy |
OLD | NEW |