| 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 "base/files/file_path.h" |
| 5 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 6 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
| 7 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 8 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 10 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/policy/browser_policy_connector.h" | 13 #include "chrome/browser/policy/browser_policy_connector.h" |
| 13 #include "chrome/browser/policy/cloud/cloud_external_data_manager.h" | 14 #include "chrome/browser/policy/cloud/cloud_external_data_manager.h" |
| 14 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" | 15 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" |
| 15 #include "chrome/browser/policy/cloud/mock_device_management_service.h" | 16 #include "chrome/browser/policy/cloud/mock_device_management_service.h" |
| 16 #include "chrome/browser/policy/cloud/mock_user_cloud_policy_store.h" | 17 #include "chrome/browser/policy/cloud/mock_user_cloud_policy_store.h" |
| 17 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" | 18 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" |
| 18 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" | 19 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" |
| 19 #include "chrome/browser/prefs/browser_prefs.h" | 20 #include "chrome/browser/prefs/browser_prefs.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 22 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| 22 #include "chrome/browser/signin/fake_signin_manager.h" | 23 #include "chrome/browser/signin/fake_signin_manager.h" |
| 23 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 24 #include "chrome/browser/signin/signin_manager.h" | 25 #include "chrome/browser/signin/signin_manager.h" |
| 25 #include "chrome/browser/signin/signin_manager_factory.h" | 26 #include "chrome/browser/signin/signin_manager_factory.h" |
| 26 #include "chrome/test/base/testing_browser_process.h" | 27 #include "chrome/test/base/testing_browser_process.h" |
| 27 #include "chrome/test/base/testing_pref_service_syncable.h" | 28 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 28 #include "chrome/test/base/testing_profile.h" | 29 #include "chrome/test/base/testing_profile.h" |
| 30 #include "components/policy/core/common/schema_registry.h" |
| 29 #include "content/public/browser/browser_context.h" | 31 #include "content/public/browser/browser_context.h" |
| 30 #include "content/public/browser/notification_details.h" | 32 #include "content/public/browser/notification_details.h" |
| 31 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/notification_source.h" | 34 #include "content/public/browser/notification_source.h" |
| 33 #include "content/public/test/test_browser_thread_bundle.h" | 35 #include "content/public/test/test_browser_thread_bundle.h" |
| 34 #include "google_apis/gaia/gaia_constants.h" | 36 #include "google_apis/gaia/gaia_constants.h" |
| 35 #include "google_apis/gaia/google_service_auth_error.h" | 37 #include "google_apis/gaia/google_service_auth_error.h" |
| 36 #include "net/http/http_status_code.h" | 38 #include "net/http/http_status_code.h" |
| 37 #include "net/url_request/test_url_fetcher_factory.h" | 39 #include "net/url_request/test_url_fetcher_factory.h" |
| 38 #include "net/url_request/url_request_context_getter.h" | 40 #include "net/url_request/url_request_context_getter.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 profile_ = builder.Build().Pass(); | 158 profile_ = builder.Build().Pass(); |
| 157 url_factory_.set_remove_fetcher_on_delete(true); | 159 url_factory_.set_remove_fetcher_on_delete(true); |
| 158 signin_manager_ = static_cast<SigninManagerFake*>( | 160 signin_manager_ = static_cast<SigninManagerFake*>( |
| 159 SigninManagerFactory::GetForProfile(profile_.get())); | 161 SigninManagerFactory::GetForProfile(profile_.get())); |
| 160 | 162 |
| 161 mock_store_ = new MockUserCloudPolicyStore(); | 163 mock_store_ = new MockUserCloudPolicyStore(); |
| 162 EXPECT_CALL(*mock_store_, Load()).Times(AnyNumber()); | 164 EXPECT_CALL(*mock_store_, Load()).Times(AnyNumber()); |
| 163 manager_.reset(new UserCloudPolicyManager( | 165 manager_.reset(new UserCloudPolicyManager( |
| 164 profile_.get(), | 166 profile_.get(), |
| 165 scoped_ptr<UserCloudPolicyStore>(mock_store_), | 167 scoped_ptr<UserCloudPolicyStore>(mock_store_), |
| 168 base::FilePath(), |
| 166 scoped_ptr<CloudExternalDataManager>(), | 169 scoped_ptr<CloudExternalDataManager>(), |
| 170 base::MessageLoopProxy::current(), |
| 171 base::MessageLoopProxy::current(), |
| 167 base::MessageLoopProxy::current())); | 172 base::MessageLoopProxy::current())); |
| 173 manager_->Init(&schema_registry_); |
| 168 | 174 |
| 169 AddProfile(); | 175 AddProfile(); |
| 170 | 176 |
| 171 Mock::VerifyAndClearExpectations(mock_store_); | 177 Mock::VerifyAndClearExpectations(mock_store_); |
| 172 } | 178 } |
| 173 | 179 |
| 174 virtual void TearDown() OVERRIDE { | 180 virtual void TearDown() OVERRIDE { |
| 175 UserPolicySigninServiceFactory::SetDeviceManagementServiceForTesting(NULL); | 181 UserPolicySigninServiceFactory::SetDeviceManagementServiceForTesting(NULL); |
| 176 // Free the profile before we clear out the browser prefs. | 182 // Free the profile before we clear out the browser prefs. |
| 177 profile_.reset(); | 183 profile_.reset(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 fetch_request->SendResponse(DM_STATUS_SUCCESS, policy_blob); | 319 fetch_request->SendResponse(DM_STATUS_SUCCESS, policy_blob); |
| 314 | 320 |
| 315 // Complete the store which should cause the policy fetch callback to be | 321 // Complete the store which should cause the policy fetch callback to be |
| 316 // invoked. | 322 // invoked. |
| 317 mock_store_->NotifyStoreLoaded(); | 323 mock_store_->NotifyStoreLoaded(); |
| 318 Mock::VerifyAndClearExpectations(this); | 324 Mock::VerifyAndClearExpectations(this); |
| 319 } | 325 } |
| 320 | 326 |
| 321 scoped_ptr<TestingProfile> profile_; | 327 scoped_ptr<TestingProfile> profile_; |
| 322 MockUserCloudPolicyStore* mock_store_; // Not owned. | 328 MockUserCloudPolicyStore* mock_store_; // Not owned. |
| 329 SchemaRegistry schema_registry_; |
| 323 scoped_ptr<UserCloudPolicyManager> manager_; | 330 scoped_ptr<UserCloudPolicyManager> manager_; |
| 324 | 331 |
| 325 // BrowserPolicyConnector and UrlFetcherFactory want to initialize and free | 332 // BrowserPolicyConnector and UrlFetcherFactory want to initialize and free |
| 326 // various components asynchronously via tasks, so create fake threads here. | 333 // various components asynchronously via tasks, so create fake threads here. |
| 327 content::TestBrowserThreadBundle thread_bundle_; | 334 content::TestBrowserThreadBundle thread_bundle_; |
| 328 | 335 |
| 329 net::TestURLFetcherFactory url_factory_; | 336 net::TestURLFetcherFactory url_factory_; |
| 330 | 337 |
| 331 SigninManagerFake* signin_manager_; | 338 SigninManagerFake* signin_manager_; |
| 332 | 339 |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 base::RunLoop().RunUntilIdle(); | 783 base::RunLoop().RunUntilIdle(); |
| 777 EXPECT_FALSE(manager_->IsClientRegistered()); | 784 EXPECT_FALSE(manager_->IsClientRegistered()); |
| 778 #if !defined(OS_ANDROID) | 785 #if !defined(OS_ANDROID) |
| 779 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); | 786 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); |
| 780 #endif | 787 #endif |
| 781 } | 788 } |
| 782 | 789 |
| 783 } // namespace | 790 } // namespace |
| 784 | 791 |
| 785 } // namespace policy | 792 } // namespace policy |
| OLD | NEW |