| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 210 run_loop.RunUntilIdle(); | 210 run_loop.RunUntilIdle(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 virtual void AddProfile() { | 213 virtual void AddProfile() { |
| 214 // For this test, the user should not be signed in yet. | 214 // For this test, the user should not be signed in yet. |
| 215 DCHECK(signin_manager_->GetAuthenticatedUsername().empty()); | 215 DCHECK(!signin_manager_->IsAuthenticated()); |
| 216 | 216 |
| 217 // Initializing UserPolicySigninService while the user is not signed in | 217 // Initializing UserPolicySigninService while the user is not signed in |
| 218 // should result in the store being cleared to remove any lingering policy. | 218 // should result in the store being cleared to remove any lingering policy. |
| 219 EXPECT_CALL(*mock_store_, Clear()); | 219 EXPECT_CALL(*mock_store_, Clear()); |
| 220 | 220 |
| 221 // Let the SigninService know that the profile has been created. | 221 // Let the SigninService know that the profile has been created. |
| 222 content::NotificationService::current()->Notify( | 222 content::NotificationService::current()->Notify( |
| 223 chrome::NOTIFICATION_PROFILE_ADDED, | 223 chrome::NOTIFICATION_PROFILE_ADDED, |
| 224 content::Source<Profile>(profile_.get()), | 224 content::Source<Profile>(profile_.get()), |
| 225 content::NotificationService::NoDetails()); | 225 content::NotificationService::NoDetails()); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, |
| 390 content::Source<Profile>(profile_.get()), | 390 content::Source<Profile>(profile_.get()), |
| 391 content::NotificationService::NoDetails()); | 391 content::NotificationService::NoDetails()); |
| 392 } | 392 } |
| 393 }; | 393 }; |
| 394 | 394 |
| 395 TEST_F(UserPolicySigninServiceTest, InitWhileSignedOut) { | 395 TEST_F(UserPolicySigninServiceTest, InitWhileSignedOut) { |
| 396 // Make sure user is not signed in. | 396 // Make sure user is not signed in. |
| 397 ASSERT_TRUE(SigninManagerFactory::GetForProfile(profile_.get())-> | 397 ASSERT_FALSE(SigninManagerFactory::GetForProfile(profile_.get())-> |
| 398 GetAuthenticatedUsername().empty()); | 398 IsAuthenticated()); |
| 399 | 399 |
| 400 // UserCloudPolicyManager should not be initialized. | 400 // UserCloudPolicyManager should not be initialized. |
| 401 ASSERT_FALSE(manager_->core()->service()); | 401 ASSERT_FALSE(manager_->core()->service()); |
| 402 } | 402 } |
| 403 | 403 |
| 404 // TODO(joaodasilva): these tests rely on issuing the OAuth2 login refresh | 404 // TODO(joaodasilva): these tests rely on issuing the OAuth2 login refresh |
| 405 // token after signin. Revisit this after figuring how to handle that on | 405 // token after signin. Revisit this after figuring how to handle that on |
| 406 // Android. | 406 // Android. |
| 407 #if !defined(OS_ANDROID) | 407 #if !defined(OS_ANDROID) |
| 408 | 408 |
| (...skipping 397 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 |