| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "chrome/browser/policy/browser_policy_connector.h" | 10 #include "chrome/browser/policy/browser_policy_connector.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 static BrowserContextKeyedService* Build(content::BrowserContext* profile) { | 77 static BrowserContextKeyedService* Build(content::BrowserContext* profile) { |
| 78 return new SigninManagerFake(static_cast<Profile*>(profile)); | 78 return new SigninManagerFake(static_cast<Profile*>(profile)); |
| 79 } | 79 } |
| 80 }; | 80 }; |
| 81 } // namespace | 81 } // namespace |
| 82 | 82 |
| 83 class UserPolicySigninServiceTest : public testing::Test { | 83 class UserPolicySigninServiceTest : public testing::Test { |
| 84 public: | 84 public: |
| 85 UserPolicySigninServiceTest() | 85 UserPolicySigninServiceTest() |
| 86 : loop_(MessageLoop::TYPE_IO), | 86 : loop_(base::MessageLoop::TYPE_IO), |
| 87 ui_thread_(content::BrowserThread::UI, &loop_), | 87 ui_thread_(content::BrowserThread::UI, &loop_), |
| 88 file_thread_(content::BrowserThread::FILE, &loop_), | 88 file_thread_(content::BrowserThread::FILE, &loop_), |
| 89 io_thread_(content::BrowserThread::IO, &loop_), | 89 io_thread_(content::BrowserThread::IO, &loop_), |
| 90 register_completed_(false) {} | 90 register_completed_(false) {} |
| 91 | 91 |
| 92 MOCK_METHOD1(OnPolicyRefresh, void(bool)); | 92 MOCK_METHOD1(OnPolicyRefresh, void(bool)); |
| 93 void OnRegisterCompleted(scoped_ptr<CloudPolicyClient> client) { | 93 void OnRegisterCompleted(scoped_ptr<CloudPolicyClient> client) { |
| 94 register_completed_ = true; | 94 register_completed_ = true; |
| 95 created_client_.swap(client); | 95 created_client_.swap(client); |
| 96 } | 96 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 257 } |
| 258 | 258 |
| 259 scoped_ptr<TestingProfile> profile_; | 259 scoped_ptr<TestingProfile> profile_; |
| 260 // Weak pointer to a MockUserCloudPolicyStore - lifetime is managed by the | 260 // Weak pointer to a MockUserCloudPolicyStore - lifetime is managed by the |
| 261 // UserCloudPolicyManager. | 261 // UserCloudPolicyManager. |
| 262 MockUserCloudPolicyStore* mock_store_; | 262 MockUserCloudPolicyStore* mock_store_; |
| 263 scoped_ptr<UserCloudPolicyManager> manager_; | 263 scoped_ptr<UserCloudPolicyManager> manager_; |
| 264 | 264 |
| 265 // BrowserPolicyConnector and UrlFetcherFactory want to initialize and free | 265 // BrowserPolicyConnector and UrlFetcherFactory want to initialize and free |
| 266 // various components asynchronously via tasks, so create fake threads here. | 266 // various components asynchronously via tasks, so create fake threads here. |
| 267 MessageLoop loop_; | 267 base::MessageLoop loop_; |
| 268 content::TestBrowserThread ui_thread_; | 268 content::TestBrowserThread ui_thread_; |
| 269 content::TestBrowserThread file_thread_; | 269 content::TestBrowserThread file_thread_; |
| 270 content::TestBrowserThread io_thread_; | 270 content::TestBrowserThread io_thread_; |
| 271 | 271 |
| 272 net::TestURLFetcherFactory url_factory_; | 272 net::TestURLFetcherFactory url_factory_; |
| 273 | 273 |
| 274 SigninManagerFake* signin_manager_; | 274 SigninManagerFake* signin_manager_; |
| 275 | 275 |
| 276 // Used in conjunction with OnRegisterCompleted() to test client registration | 276 // Used in conjunction with OnRegisterCompleted() to test client registration |
| 277 // callbacks. | 277 // callbacks. |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 fetch_request->SendResponse(DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED, | 702 fetch_request->SendResponse(DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED, |
| 703 em::DeviceManagementResponse()); | 703 em::DeviceManagementResponse()); |
| 704 base::RunLoop().RunUntilIdle(); | 704 base::RunLoop().RunUntilIdle(); |
| 705 EXPECT_FALSE(manager_->IsClientRegistered()); | 705 EXPECT_FALSE(manager_->IsClientRegistered()); |
| 706 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); | 706 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); |
| 707 } | 707 } |
| 708 | 708 |
| 709 } // namespace | 709 } // namespace |
| 710 | 710 |
| 711 } // namespace policy | 711 } // namespace policy |
| OLD | NEW |