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 <memory> | 5 #include <memory> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 31 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
32 #include "components/policy/core/common/cloud/mock_device_management_service.h" | 32 #include "components/policy/core/common/cloud/mock_device_management_service.h" |
33 #include "components/policy/core/common/cloud/mock_user_cloud_policy_store.h" | 33 #include "components/policy/core/common/cloud/mock_user_cloud_policy_store.h" |
34 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" | 34 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" |
35 #include "components/policy/core/common/schema_registry.h" | 35 #include "components/policy/core/common/schema_registry.h" |
36 #include "components/prefs/pref_service.h" | 36 #include "components/prefs/pref_service.h" |
37 #include "components/signin/core/browser/account_tracker_service.h" | 37 #include "components/signin/core/browser/account_tracker_service.h" |
38 #include "components/signin/core/browser/fake_account_fetcher_service.h" | 38 #include "components/signin/core/browser/fake_account_fetcher_service.h" |
39 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" | 39 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" |
40 #include "components/signin/core/browser/signin_manager.h" | 40 #include "components/signin/core/browser/signin_manager.h" |
41 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 41 #include "components/sync_preferences/testing_pref_service_syncable.h" |
42 #include "content/public/browser/browser_context.h" | 42 #include "content/public/browser/browser_context.h" |
43 #include "content/public/browser/notification_details.h" | 43 #include "content/public/browser/notification_details.h" |
44 #include "content/public/browser/notification_service.h" | 44 #include "content/public/browser/notification_service.h" |
45 #include "content/public/browser/notification_source.h" | 45 #include "content/public/browser/notification_source.h" |
46 #include "content/public/test/test_browser_thread_bundle.h" | 46 #include "content/public/test/test_browser_thread_bundle.h" |
47 #include "google_apis/gaia/gaia_constants.h" | 47 #include "google_apis/gaia/gaia_constants.h" |
48 #include "google_apis/gaia/google_service_auth_error.h" | 48 #include "google_apis/gaia/google_service_auth_error.h" |
49 #include "net/base/net_errors.h" | 49 #include "net/base/net_errors.h" |
50 #include "net/http/http_status_code.h" | 50 #include "net/http/http_status_code.h" |
51 #include "net/url_request/test_url_fetcher_factory.h" | 51 #include "net/url_request/test_url_fetcher_factory.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 base::ThreadTaskRunnerHandle::Get()); | 148 base::ThreadTaskRunnerHandle::Get()); |
149 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( | 149 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( |
150 system_request_context_getter_.get()); | 150 system_request_context_getter_.get()); |
151 TestingBrowserProcess::GetGlobal()->SetLocalState(local_state_.get()); | 151 TestingBrowserProcess::GetGlobal()->SetLocalState(local_state_.get()); |
152 | 152 |
153 g_browser_process->browser_policy_connector()->Init( | 153 g_browser_process->browser_policy_connector()->Init( |
154 local_state_.get(), system_request_context_getter_); | 154 local_state_.get(), system_request_context_getter_); |
155 | 155 |
156 // Create a testing profile with cloud-policy-on-signin enabled, and bring | 156 // Create a testing profile with cloud-policy-on-signin enabled, and bring |
157 // up a UserCloudPolicyManager with a MockUserCloudPolicyStore. | 157 // up a UserCloudPolicyManager with a MockUserCloudPolicyStore. |
158 std::unique_ptr<syncable_prefs::TestingPrefServiceSyncable> prefs( | 158 std::unique_ptr<sync_preferences::TestingPrefServiceSyncable> prefs( |
159 new syncable_prefs::TestingPrefServiceSyncable()); | 159 new sync_preferences::TestingPrefServiceSyncable()); |
160 chrome::RegisterUserProfilePrefs(prefs->registry()); | 160 chrome::RegisterUserProfilePrefs(prefs->registry()); |
161 | 161 |
162 // UserCloudPolicyManagerFactory isn't a real | 162 // UserCloudPolicyManagerFactory isn't a real |
163 // BrowserContextKeyedServiceFactory (it derives from | 163 // BrowserContextKeyedServiceFactory (it derives from |
164 // BrowserContextKeyedBaseFactory and exposes its own APIs to get | 164 // BrowserContextKeyedBaseFactory and exposes its own APIs to get |
165 // instances) so we have to inject our testing factory via a special | 165 // instances) so we have to inject our testing factory via a special |
166 // API before creating the profile. | 166 // API before creating the profile. |
167 UserCloudPolicyManagerFactory::GetInstance()->RegisterTestingFactory( | 167 UserCloudPolicyManagerFactory::GetInstance()->RegisterTestingFactory( |
168 BuildCloudPolicyManager); | 168 BuildCloudPolicyManager); |
169 TestingProfile::Builder builder; | 169 TestingProfile::Builder builder; |
170 builder.SetPrefService( | 170 builder.SetPrefService( |
171 std::unique_ptr<syncable_prefs::PrefServiceSyncable>(std::move(prefs))); | 171 std::unique_ptr<sync_preferences::PrefServiceSyncable>( |
| 172 std::move(prefs))); |
172 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), | 173 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
173 BuildFakeSigninManagerBase); | 174 BuildFakeSigninManagerBase); |
174 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), | 175 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
175 BuildFakeProfileOAuth2TokenService); | 176 BuildFakeProfileOAuth2TokenService); |
176 builder.AddTestingFactory(AccountFetcherServiceFactory::GetInstance(), | 177 builder.AddTestingFactory(AccountFetcherServiceFactory::GetInstance(), |
177 FakeAccountFetcherServiceBuilder::BuildForTests); | 178 FakeAccountFetcherServiceBuilder::BuildForTests); |
178 builder.AddTestingFactory(ChromeSigninClientFactory::GetInstance(), | 179 builder.AddTestingFactory(ChromeSigninClientFactory::GetInstance(), |
179 signin::BuildTestSigninClient); | 180 signin::BuildTestSigninClient); |
180 | 181 |
181 profile_ = builder.Build(); | 182 profile_ = builder.Build(); |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 base::RunLoop().RunUntilIdle(); | 821 base::RunLoop().RunUntilIdle(); |
821 EXPECT_FALSE(manager_->IsClientRegistered()); | 822 EXPECT_FALSE(manager_->IsClientRegistered()); |
822 #if !defined(OS_ANDROID) | 823 #if !defined(OS_ANDROID) |
823 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); | 824 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); |
824 #endif | 825 #endif |
825 } | 826 } |
826 | 827 |
827 } // namespace | 828 } // namespace |
828 | 829 |
829 } // namespace policy | 830 } // namespace policy |
OLD | NEW |