Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc

Issue 338993007: Track when and how a profile is signed out via UMA. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: SignOut() param in Android tests Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698