| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 class SigninManagerFake : public FakeSigninManager { | 81 class SigninManagerFake : public FakeSigninManager { |
| 82 public: | 82 public: |
| 83 explicit SigninManagerFake(Profile* profile) | 83 explicit SigninManagerFake(Profile* profile) |
| 84 : FakeSigninManager(profile) { | 84 : FakeSigninManager(profile) { |
| 85 Initialize(NULL); | 85 Initialize(NULL); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void ForceSignOut() { | 88 void ForceSignOut() { |
| 89 // Allow signing out now. | 89 // Allow signing out now. |
| 90 prohibit_signout_ = false; | 90 prohibit_signout_ = false; |
| 91 SignOut(); | 91 SignOut(signin_metrics::SIGNOUT_TEST); |
| 92 } | 92 } |
| 93 | 93 |
| 94 static KeyedService* Build(content::BrowserContext* profile) { | 94 static KeyedService* Build(content::BrowserContext* profile) { |
| 95 return new SigninManagerFake(static_cast<Profile*>(profile)); | 95 return new SigninManagerFake(static_cast<Profile*>(profile)); |
| 96 } | 96 } |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 UserCloudPolicyManager* BuildCloudPolicyManager( | 99 UserCloudPolicyManager* BuildCloudPolicyManager( |
| 100 content::BrowserContext* context) { | 100 content::BrowserContext* context) { |
| 101 MockUserCloudPolicyStore *store = new MockUserCloudPolicyStore(); | 101 MockUserCloudPolicyStore *store = new MockUserCloudPolicyStore(); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 | 569 |
| 570 TEST_F(UserPolicySigninServiceSignedInTest, SignOutAfterInit) { | 570 TEST_F(UserPolicySigninServiceSignedInTest, SignOutAfterInit) { |
| 571 // UserCloudPolicyManager should be initialized. | 571 // UserCloudPolicyManager should be initialized. |
| 572 EXPECT_EQ(mock_store_->signin_username_, kTestUser); | 572 EXPECT_EQ(mock_store_->signin_username_, kTestUser); |
| 573 ASSERT_TRUE(manager_->core()->service()); | 573 ASSERT_TRUE(manager_->core()->service()); |
| 574 | 574 |
| 575 // Signing out will clear the policy from the store. | 575 // Signing out will clear the policy from the store. |
| 576 EXPECT_CALL(*mock_store_, Clear()); | 576 EXPECT_CALL(*mock_store_, Clear()); |
| 577 | 577 |
| 578 // Now sign out. | 578 // Now sign out. |
| 579 SigninManagerFactory::GetForProfile(profile_.get())->SignOut(); | 579 SigninManagerFactory::GetForProfile(profile_.get())->SignOut( |
| 580 signin_metrics::SIGNOUT_TEST); |
| 580 | 581 |
| 581 // UserCloudPolicyManager should be shut down. | 582 // UserCloudPolicyManager should be shut down. |
| 582 ASSERT_FALSE(manager_->core()->service()); | 583 ASSERT_FALSE(manager_->core()->service()); |
| 583 } | 584 } |
| 584 | 585 |
| 585 TEST_F(UserPolicySigninServiceTest, RegisterPolicyClientOAuthFailure) { | 586 TEST_F(UserPolicySigninServiceTest, RegisterPolicyClientOAuthFailure) { |
| 586 UserPolicySigninService* signin_service = | 587 UserPolicySigninService* signin_service = |
| 587 UserPolicySigninServiceFactory::GetForProfile(profile_.get()); | 588 UserPolicySigninServiceFactory::GetForProfile(profile_.get()); |
| 588 RegisterPolicyClientWithCallback(signin_service); | 589 RegisterPolicyClientWithCallback(signin_service); |
| 589 Mock::VerifyAndClearExpectations(this); | 590 Mock::VerifyAndClearExpectations(this); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 base::RunLoop().RunUntilIdle(); | 813 base::RunLoop().RunUntilIdle(); |
| 813 EXPECT_FALSE(manager_->IsClientRegistered()); | 814 EXPECT_FALSE(manager_->IsClientRegistered()); |
| 814 #if !defined(OS_ANDROID) | 815 #if !defined(OS_ANDROID) |
| 815 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); | 816 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); |
| 816 #endif | 817 #endif |
| 817 } | 818 } |
| 818 | 819 |
| 819 } // namespace | 820 } // namespace |
| 820 | 821 |
| 821 } // namespace policy | 822 } // namespace policy |
| OLD | NEW |