| 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/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "chrome/browser/policy/browser_policy_connector.h" | 7 #include "chrome/browser/policy/browser_policy_connector.h" |
| 8 #include "chrome/browser/policy/mock_cloud_policy_store.h" | 8 #include "chrome/browser/policy/mock_user_cloud_policy_store.h" |
| 9 #include "chrome/browser/policy/user_cloud_policy_manager.h" | 9 #include "chrome/browser/policy/user_cloud_policy_manager.h" |
| 10 #include "chrome/browser/policy/user_policy_signin_service.h" | 10 #include "chrome/browser/policy/user_policy_signin_service.h" |
| 11 #include "chrome/browser/policy/user_policy_signin_service_factory.h" | 11 #include "chrome/browser/policy/user_policy_signin_service_factory.h" |
| 12 #include "chrome/browser/prefs/browser_prefs.h" | 12 #include "chrome/browser/prefs/browser_prefs.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/signin/signin_manager.h" | 14 #include "chrome/browser/signin/signin_manager.h" |
| 15 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
| 16 #include "chrome/browser/signin/signin_manager_fake.h" | 16 #include "chrome/browser/signin/signin_manager_fake.h" |
| 17 #include "chrome/browser/signin/token_service.h" | 17 #include "chrome/browser/signin/token_service.h" |
| 18 #include "chrome/browser/signin/token_service_factory.h" | 18 #include "chrome/browser/signin/token_service_factory.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 43 io_thread_(content::BrowserThread::IO, &loop_) {} | 43 io_thread_(content::BrowserThread::IO, &loop_) {} |
| 44 | 44 |
| 45 virtual void SetUp() OVERRIDE { | 45 virtual void SetUp() OVERRIDE { |
| 46 g_browser_process->browser_policy_connector()->Init(); | 46 g_browser_process->browser_policy_connector()->Init(); |
| 47 | 47 |
| 48 local_state_.reset(new TestingPrefService); | 48 local_state_.reset(new TestingPrefService); |
| 49 chrome::RegisterLocalState(local_state_.get()); | 49 chrome::RegisterLocalState(local_state_.get()); |
| 50 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState( | 50 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState( |
| 51 local_state_.get()); | 51 local_state_.get()); |
| 52 | 52 |
| 53 // Create a UserCloudPolicyManager with a MockCloudPolicyStore, and build a | 53 // Create a UserCloudPolicyManager with a MockUserCloudPolicyStore, and |
| 54 // TestingProfile that uses it. | 54 // build a TestingProfile that uses it. |
| 55 mock_store_ = new MockCloudPolicyStore(); | 55 mock_store_ = new MockUserCloudPolicyStore(); |
| 56 scoped_ptr<UserCloudPolicyManager> manager(new UserCloudPolicyManager( | 56 scoped_ptr<UserCloudPolicyManager> manager(new UserCloudPolicyManager( |
| 57 scoped_ptr<CloudPolicyStore>(mock_store_), false)); | 57 scoped_ptr<UserCloudPolicyStore>(mock_store_))); |
| 58 TestingProfile::Builder builder; | 58 TestingProfile::Builder builder; |
| 59 builder.SetUserCloudPolicyManager(manager.Pass()); | 59 builder.SetUserCloudPolicyManager(manager.Pass()); |
| 60 profile_ = builder.Build().Pass(); | 60 profile_ = builder.Build().Pass(); |
| 61 profile_->CreateRequestContext(); | 61 profile_->CreateRequestContext(); |
| 62 profile_->GetPrefs()->SetBoolean(prefs::kLoadCloudPolicyOnSignin, true); | 62 profile_->GetPrefs()->SetBoolean(prefs::kLoadCloudPolicyOnSignin, true); |
| 63 SigninManagerFactory::GetInstance()->SetTestingFactory( | 63 SigninManagerFactory::GetInstance()->SetTestingFactory( |
| 64 profile_.get(), FakeSigninManager::Build); | 64 profile_.get(), FakeSigninManager::Build); |
| 65 | 65 |
| 66 // Make sure the UserPolicySigninService is created. | 66 // Make sure the UserPolicySigninService is created. |
| 67 UserPolicySigninServiceFactory::GetForProfile(profile_.get()); | 67 UserPolicySigninServiceFactory::GetForProfile(profile_.get()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 78 testing_browser_process->SetBrowserPolicyConnector(NULL); | 78 testing_browser_process->SetBrowserPolicyConnector(NULL); |
| 79 base::RunLoop run_loop; | 79 base::RunLoop run_loop; |
| 80 run_loop.RunUntilIdle(); | 80 run_loop.RunUntilIdle(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool IsRequestActive() { | 83 bool IsRequestActive() { |
| 84 return url_factory_.GetFetcherByID(0); | 84 return url_factory_.GetFetcherByID(0); |
| 85 } | 85 } |
| 86 | 86 |
| 87 scoped_ptr<TestingProfile> profile_; | 87 scoped_ptr<TestingProfile> profile_; |
| 88 // Weak pointer to a MockCloudPolicyStore - lifetime is managed by the | 88 // Weak pointer to a MockUserCloudPolicyStore - lifetime is managed by the |
| 89 // UserCloudPolicyManager. | 89 // UserCloudPolicyManager. |
| 90 MockCloudPolicyStore* mock_store_; | 90 MockUserCloudPolicyStore* mock_store_; |
| 91 | 91 |
| 92 // BrowserPolicyConnector and UrlFetcherFactory want to initialize and free | 92 // BrowserPolicyConnector and UrlFetcherFactory want to initialize and free |
| 93 // various components asynchronously via tasks, so create fake threads here. | 93 // various components asynchronously via tasks, so create fake threads here. |
| 94 MessageLoop loop_; | 94 MessageLoop loop_; |
| 95 content::TestBrowserThread ui_thread_; | 95 content::TestBrowserThread ui_thread_; |
| 96 content::TestBrowserThread file_thread_; | 96 content::TestBrowserThread file_thread_; |
| 97 content::TestBrowserThread io_thread_; | 97 content::TestBrowserThread io_thread_; |
| 98 | 98 |
| 99 net::TestURLFetcherFactory url_factory_; | 99 net::TestURLFetcherFactory url_factory_; |
| 100 | 100 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // Now sign out. | 268 // Now sign out. |
| 269 SigninManagerFactory::GetForProfile(profile_.get())->SignOut(); | 269 SigninManagerFactory::GetForProfile(profile_.get())->SignOut(); |
| 270 | 270 |
| 271 // UserCloudPolicyManager should be shut down. | 271 // UserCloudPolicyManager should be shut down. |
| 272 ASSERT_FALSE(profile_->GetUserCloudPolicyManager()->cloud_policy_service()); | 272 ASSERT_FALSE(profile_->GetUserCloudPolicyManager()->cloud_policy_service()); |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace | 275 } // namespace |
| 276 | 276 |
| 277 } // namespace policy | 277 } // namespace policy |
| OLD | NEW |