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/files/file_path.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.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 "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 service->RegisterForPolicy( | 136 service->RegisterForPolicy( |
137 kTestUser, | 137 kTestUser, |
138 #if !defined(OS_ANDROID) | 138 #if !defined(OS_ANDROID) |
139 "mock_oauth_token", | 139 "mock_oauth_token", |
140 #endif | 140 #endif |
141 base::Bind(&UserPolicySigninServiceTest::OnRegisterCompleted, | 141 base::Bind(&UserPolicySigninServiceTest::OnRegisterCompleted, |
142 base::Unretained(this))); | 142 base::Unretained(this))); |
143 ASSERT_TRUE(IsRequestActive()); | 143 ASSERT_TRUE(IsRequestActive()); |
144 } | 144 } |
145 | 145 |
146 virtual void SetUp() OVERRIDE { | 146 virtual void SetUp() override { |
147 UserPolicySigninServiceFactory::SetDeviceManagementServiceForTesting( | 147 UserPolicySigninServiceFactory::SetDeviceManagementServiceForTesting( |
148 &device_management_service_); | 148 &device_management_service_); |
149 | 149 |
150 local_state_.reset(new TestingPrefServiceSimple); | 150 local_state_.reset(new TestingPrefServiceSimple); |
151 chrome::RegisterLocalState(local_state_->registry()); | 151 chrome::RegisterLocalState(local_state_->registry()); |
152 system_request_context_getter_ = new net::TestURLRequestContextGetter( | 152 system_request_context_getter_ = new net::TestURLRequestContextGetter( |
153 base::MessageLoopProxy::current()); | 153 base::MessageLoopProxy::current()); |
154 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( | 154 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( |
155 system_request_context_getter_.get()); | 155 system_request_context_getter_.get()); |
156 TestingBrowserProcess::GetGlobal()->SetLocalState(local_state_.get()); | 156 TestingBrowserProcess::GetGlobal()->SetLocalState(local_state_.get()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 profile_.get())); | 189 profile_.get())); |
190 manager_->Init(&schema_registry_); | 190 manager_->Init(&schema_registry_); |
191 mock_store_ = static_cast<MockUserCloudPolicyStore*>( | 191 mock_store_ = static_cast<MockUserCloudPolicyStore*>( |
192 manager_->core()->store()); | 192 manager_->core()->store()); |
193 DCHECK(mock_store_); | 193 DCHECK(mock_store_); |
194 AddProfile(); | 194 AddProfile(); |
195 | 195 |
196 Mock::VerifyAndClearExpectations(mock_store_); | 196 Mock::VerifyAndClearExpectations(mock_store_); |
197 } | 197 } |
198 | 198 |
199 virtual void TearDown() OVERRIDE { | 199 virtual void TearDown() override { |
200 UserPolicySigninServiceFactory::SetDeviceManagementServiceForTesting(NULL); | 200 UserPolicySigninServiceFactory::SetDeviceManagementServiceForTesting(NULL); |
201 UserCloudPolicyManagerFactory::GetInstance()->ClearTestingFactory(); | 201 UserCloudPolicyManagerFactory::GetInstance()->ClearTestingFactory(); |
202 // Free the profile before we clear out the browser prefs. | 202 // Free the profile before we clear out the browser prefs. |
203 profile_.reset(); | 203 profile_.reset(); |
204 TestingBrowserProcess* testing_browser_process = | 204 TestingBrowserProcess* testing_browser_process = |
205 TestingBrowserProcess::GetGlobal(); | 205 TestingBrowserProcess::GetGlobal(); |
206 testing_browser_process->SetLocalState(NULL); | 206 testing_browser_process->SetLocalState(NULL); |
207 local_state_.reset(); | 207 local_state_.reset(); |
208 testing_browser_process->SetBrowserPolicyConnector(NULL); | 208 testing_browser_process->SetBrowserPolicyConnector(NULL); |
209 base::RunLoop run_loop; | 209 base::RunLoop run_loop; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 // Weak ptr to the MockDeviceManagementService (object is owned by the | 369 // Weak ptr to the MockDeviceManagementService (object is owned by the |
370 // BrowserPolicyConnector). | 370 // BrowserPolicyConnector). |
371 MockDeviceManagementService device_management_service_; | 371 MockDeviceManagementService device_management_service_; |
372 | 372 |
373 scoped_ptr<TestingPrefServiceSimple> local_state_; | 373 scoped_ptr<TestingPrefServiceSimple> local_state_; |
374 scoped_refptr<net::URLRequestContextGetter> system_request_context_getter_; | 374 scoped_refptr<net::URLRequestContextGetter> system_request_context_getter_; |
375 }; | 375 }; |
376 | 376 |
377 class UserPolicySigninServiceSignedInTest : public UserPolicySigninServiceTest { | 377 class UserPolicySigninServiceSignedInTest : public UserPolicySigninServiceTest { |
378 public: | 378 public: |
379 virtual void AddProfile() OVERRIDE { | 379 virtual void AddProfile() override { |
380 // UserCloudPolicyManager should not be initialized. | 380 // UserCloudPolicyManager should not be initialized. |
381 ASSERT_FALSE(manager_->core()->service()); | 381 ASSERT_FALSE(manager_->core()->service()); |
382 | 382 |
383 // Set the user as signed in. | 383 // Set the user as signed in. |
384 SigninManagerFactory::GetForProfile(profile_.get())-> | 384 SigninManagerFactory::GetForProfile(profile_.get())-> |
385 SetAuthenticatedUsername(kTestUser); | 385 SetAuthenticatedUsername(kTestUser); |
386 | 386 |
387 // Let the SigninService know that the profile has been created. | 387 // Let the SigninService know that the profile has been created. |
388 content::NotificationService::current()->Notify( | 388 content::NotificationService::current()->Notify( |
389 chrome::NOTIFICATION_PROFILE_ADDED, | 389 chrome::NOTIFICATION_PROFILE_ADDED, |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 base::RunLoop().RunUntilIdle(); | 806 base::RunLoop().RunUntilIdle(); |
807 EXPECT_FALSE(manager_->IsClientRegistered()); | 807 EXPECT_FALSE(manager_->IsClientRegistered()); |
808 #if !defined(OS_ANDROID) | 808 #if !defined(OS_ANDROID) |
809 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); | 809 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); |
810 #endif | 810 #endif |
811 } | 811 } |
812 | 812 |
813 } // namespace | 813 } // namespace |
814 | 814 |
815 } // namespace policy | 815 } // namespace policy |
OLD | NEW |