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 "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/prefs/pref_registry_simple.h" | 13 #include "base/prefs/pref_registry_simple.h" |
14 #include "base/prefs/testing_pref_service.h" | 14 #include "base/prefs/testing_pref_service.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder.h" | 18 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder.h" |
19 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 19 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 20 #include "chrome/browser/invalidation/fake_invalidation_service.h" |
20 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" | 21 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" |
21 #include "chrome/browser/policy/cloud/cloud_policy_service.h" | 22 #include "chrome/browser/policy/cloud/cloud_policy_service.h" |
22 #include "chrome/browser/policy/cloud/mock_cloud_policy_store.h" | 23 #include "chrome/browser/policy/cloud/mock_cloud_policy_store.h" |
23 #include "chrome/browser/policy/cloud/mock_device_management_service.h" | 24 #include "chrome/browser/policy/cloud/mock_device_management_service.h" |
24 #include "chrome/browser/policy/cloud/resource_cache.h" | 25 #include "chrome/browser/policy/cloud/resource_cache.h" |
25 #include "chrome/browser/policy/external_data_fetcher.h" | 26 #include "chrome/browser/policy/external_data_fetcher.h" |
26 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 27 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
27 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" | 28 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" |
28 #include "chrome/browser/prefs/browser_prefs.h" | 29 #include "chrome/browser/prefs/browser_prefs.h" |
29 #include "chrome/browser/prefs/pref_service_syncable.h" | 30 #include "chrome/browser/prefs/pref_service_syncable.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 139 } |
139 signin_profile_->ResetRequestContext(); | 140 signin_profile_->ResetRequestContext(); |
140 } | 141 } |
141 | 142 |
142 void CreateManager(bool wait_for_fetch) { | 143 void CreateManager(bool wait_for_fetch) { |
143 store_ = new MockCloudPolicyStore(); | 144 store_ = new MockCloudPolicyStore(); |
144 EXPECT_CALL(*store_, Load()); | 145 EXPECT_CALL(*store_, Load()); |
145 manager_.reset(new UserCloudPolicyManagerChromeOS( | 146 manager_.reset(new UserCloudPolicyManagerChromeOS( |
146 scoped_ptr<CloudPolicyStore>(store_), | 147 scoped_ptr<CloudPolicyStore>(store_), |
147 scoped_ptr<ResourceCache>(), | 148 scoped_ptr<ResourceCache>(), |
148 wait_for_fetch)); | 149 wait_for_fetch, |
| 150 &invalidation_service_)); |
149 manager_->Init(); | 151 manager_->Init(); |
150 manager_->AddObserver(&observer_); | 152 manager_->AddObserver(&observer_); |
151 manager_->Connect(&prefs_, &device_management_service_, NULL, | 153 manager_->Connect(&prefs_, &device_management_service_, NULL, |
152 USER_AFFILIATION_NONE); | 154 USER_AFFILIATION_NONE); |
153 Mock::VerifyAndClearExpectations(store_); | 155 Mock::VerifyAndClearExpectations(store_); |
154 EXPECT_FALSE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 156 EXPECT_FALSE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
155 EXPECT_FALSE(manager_->core()->service()->IsInitializationComplete()); | 157 EXPECT_FALSE(manager_->core()->service()->IsInitializationComplete()); |
156 | 158 |
157 if (!wait_for_fetch) { | 159 if (!wait_for_fetch) { |
158 // Create the UserCloudPolicyTokenForwarder, which forwards the refresh | 160 // Create the UserCloudPolicyTokenForwarder, which forwards the refresh |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 em::DeviceManagementResponse policy_blob_; | 279 em::DeviceManagementResponse policy_blob_; |
278 PolicyMap policy_map_; | 280 PolicyMap policy_map_; |
279 PolicyBundle expected_bundle_; | 281 PolicyBundle expected_bundle_; |
280 | 282 |
281 // Policy infrastructure. | 283 // Policy infrastructure. |
282 net::TestURLFetcherFactory test_url_fetcher_factory_; | 284 net::TestURLFetcherFactory test_url_fetcher_factory_; |
283 TestingPrefServiceSimple prefs_; | 285 TestingPrefServiceSimple prefs_; |
284 MockConfigurationPolicyObserver observer_; | 286 MockConfigurationPolicyObserver observer_; |
285 MockDeviceManagementService device_management_service_; | 287 MockDeviceManagementService device_management_service_; |
286 MockCloudPolicyStore* store_; | 288 MockCloudPolicyStore* store_; |
| 289 invalidation::FakeInvalidationService invalidation_service_; |
287 scoped_ptr<UserCloudPolicyManagerChromeOS> manager_; | 290 scoped_ptr<UserCloudPolicyManagerChromeOS> manager_; |
288 scoped_ptr<UserCloudPolicyTokenForwarder> token_forwarder_; | 291 scoped_ptr<UserCloudPolicyTokenForwarder> token_forwarder_; |
289 | 292 |
290 // Required by ProfileHelper to get the signin Profile context. | 293 // Required by ProfileHelper to get the signin Profile context. |
291 scoped_ptr<TestingProfileManager> profile_manager_; | 294 scoped_ptr<TestingProfileManager> profile_manager_; |
292 TestingProfile* profile_; | 295 TestingProfile* profile_; |
293 TestingProfile* signin_profile_; | 296 TestingProfile* signin_profile_; |
294 | 297 |
295 private: | 298 private: |
296 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOSTest); | 299 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOSTest); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 | 514 |
512 // The refresh scheduler takes care of the initial fetch for unmanaged users. | 515 // The refresh scheduler takes care of the initial fetch for unmanaged users. |
513 // It posts a delayed task with 0ms delay in this case, so spinning the loop | 516 // It posts a delayed task with 0ms delay in this case, so spinning the loop |
514 // issues the initial fetch. | 517 // issues the initial fetch. |
515 base::RunLoop loop; | 518 base::RunLoop loop; |
516 FetchPolicy( | 519 FetchPolicy( |
517 base::Bind(&base::RunLoop::RunUntilIdle, base::Unretained(&loop))); | 520 base::Bind(&base::RunLoop::RunUntilIdle, base::Unretained(&loop))); |
518 } | 521 } |
519 | 522 |
520 } // namespace policy | 523 } // namespace policy |
OLD | NEW |