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 <utility> |
| 6 |
5 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
6 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
7 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
8 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
9 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
10 #include "base/time/time.h" | 12 #include "base/time/time.h" |
11 #include "build/build_config.h" | 13 #include "build/build_config.h" |
12 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 16 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 163 |
162 // UserCloudPolicyManagerFactory isn't a real | 164 // UserCloudPolicyManagerFactory isn't a real |
163 // BrowserContextKeyedServiceFactory (it derives from | 165 // BrowserContextKeyedServiceFactory (it derives from |
164 // BrowserContextKeyedBaseFactory and exposes its own APIs to get | 166 // BrowserContextKeyedBaseFactory and exposes its own APIs to get |
165 // instances) so we have to inject our testing factory via a special | 167 // instances) so we have to inject our testing factory via a special |
166 // API before creating the profile. | 168 // API before creating the profile. |
167 UserCloudPolicyManagerFactory::GetInstance()->RegisterTestingFactory( | 169 UserCloudPolicyManagerFactory::GetInstance()->RegisterTestingFactory( |
168 BuildCloudPolicyManager); | 170 BuildCloudPolicyManager); |
169 TestingProfile::Builder builder; | 171 TestingProfile::Builder builder; |
170 builder.SetPrefService( | 172 builder.SetPrefService( |
171 scoped_ptr<syncable_prefs::PrefServiceSyncable>(prefs.Pass())); | 173 scoped_ptr<syncable_prefs::PrefServiceSyncable>(std::move(prefs))); |
172 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), | 174 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
173 BuildFakeSigninManagerBase); | 175 BuildFakeSigninManagerBase); |
174 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), | 176 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
175 BuildFakeProfileOAuth2TokenService); | 177 BuildFakeProfileOAuth2TokenService); |
176 builder.AddTestingFactory(AccountFetcherServiceFactory::GetInstance(), | 178 builder.AddTestingFactory(AccountFetcherServiceFactory::GetInstance(), |
177 FakeAccountFetcherServiceBuilder::BuildForTests); | 179 FakeAccountFetcherServiceBuilder::BuildForTests); |
178 builder.AddTestingFactory(ChromeSigninClientFactory::GetInstance(), | 180 builder.AddTestingFactory(ChromeSigninClientFactory::GetInstance(), |
179 signin::BuildTestSigninClient); | 181 signin::BuildTestSigninClient); |
180 | 182 |
181 profile_ = builder.Build().Pass(); | 183 profile_ = builder.Build(); |
182 url_factory_.set_remove_fetcher_on_delete(true); | 184 url_factory_.set_remove_fetcher_on_delete(true); |
183 | 185 |
184 signin_manager_ = static_cast<FakeSigninManager*>( | 186 signin_manager_ = static_cast<FakeSigninManager*>( |
185 SigninManagerFactory::GetForProfile(profile_.get())); | 187 SigninManagerFactory::GetForProfile(profile_.get())); |
186 // Tests are responsible for freeing the UserCloudPolicyManager instances | 188 // Tests are responsible for freeing the UserCloudPolicyManager instances |
187 // they inject. | 189 // they inject. |
188 manager_.reset(UserCloudPolicyManagerFactory::GetForBrowserContext( | 190 manager_.reset(UserCloudPolicyManagerFactory::GetForBrowserContext( |
189 profile_.get())); | 191 profile_.get())); |
190 manager_->Init(&schema_registry_); | 192 manager_->Init(&schema_registry_); |
191 mock_store_ = static_cast<MockUserCloudPolicyStore*>( | 193 mock_store_ = static_cast<MockUserCloudPolicyStore*>( |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 base::RunLoop().RunUntilIdle(); | 821 base::RunLoop().RunUntilIdle(); |
820 EXPECT_FALSE(manager_->IsClientRegistered()); | 822 EXPECT_FALSE(manager_->IsClientRegistered()); |
821 #if !defined(OS_ANDROID) | 823 #if !defined(OS_ANDROID) |
822 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); | 824 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); |
823 #endif | 825 #endif |
824 } | 826 } |
825 | 827 |
826 } // namespace | 828 } // namespace |
827 | 829 |
828 } // namespace policy | 830 } // namespace policy |
OLD | NEW |