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

Side by Side Diff: chrome/browser/sync/profile_sync_service_startup_unittest.cc

Issue 137753012: [sync]: add ManagedUserSigninManagerWrapper and pass to ProfileSyncService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/managed_mode/managed_user_signin_manager_wrapper.h"
9 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" 10 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
10 #include "chrome/browser/signin/fake_signin_manager.h" 11 #include "chrome/browser/signin/fake_signin_manager.h"
11 #include "chrome/browser/signin/profile_oauth2_token_service.h" 12 #include "chrome/browser/signin/profile_oauth2_token_service.h"
12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
13 #include "chrome/browser/signin/signin_manager.h" 14 #include "chrome/browser/signin/signin_manager.h"
14 #include "chrome/browser/signin/signin_manager_factory.h" 15 #include "chrome/browser/signin/signin_manager_factory.h"
15 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" 16 #include "chrome/browser/sync/glue/sync_backend_host_mock.h"
16 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" 17 #include "chrome/browser/sync/profile_sync_components_factory_mock.h"
17 #include "chrome/browser/sync/profile_sync_service_factory.h" 18 #include "chrome/browser/sync/profile_sync_service_factory.h"
18 #include "chrome/browser/sync/profile_sync_test_util.h" 19 #include "chrome/browser/sync/profile_sync_test_util.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 sync_->RemoveObserver(&observer_); 88 sync_->RemoveObserver(&observer_);
88 profile_.reset(); 89 profile_.reset();
89 } 90 }
90 91
91 static BrowserContextKeyedService* BuildService( 92 static BrowserContextKeyedService* BuildService(
92 content::BrowserContext* browser_context) { 93 content::BrowserContext* browser_context) {
93 Profile* profile = static_cast<Profile*>(browser_context); 94 Profile* profile = static_cast<Profile*>(browser_context);
94 return new ProfileSyncService( 95 return new ProfileSyncService(
95 new ProfileSyncComponentsFactoryMock(), 96 new ProfileSyncComponentsFactoryMock(),
96 profile, 97 profile,
97 SigninManagerFactory::GetForProfile(profile), 98 new ManagedUserSigninManagerWrapper(
99 SigninManagerFactory::GetForProfile(profile)),
98 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), 100 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
99 ProfileSyncService::MANUAL_START); 101 ProfileSyncService::MANUAL_START);
100 } 102 }
101 103
102 void CreateSyncService() { 104 void CreateSyncService() {
103 sync_ = static_cast<ProfileSyncService*>( 105 sync_ = static_cast<ProfileSyncService*>(
104 ProfileSyncServiceFactory::GetForProfile(profile_.get())); 106 ProfileSyncServiceFactory::GetForProfile(profile_.get()));
105 sync_->AddObserver(&observer_); 107 sync_->AddObserver(&observer_);
106 } 108 }
107 109
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 SigninManagerFactory::GetForProfile(profile); 157 SigninManagerFactory::GetForProfile(profile);
156 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, 158 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
157 "test_user@gmail.com"); 159 "test_user@gmail.com");
158 ProfileOAuth2TokenService* oauth2_token_service = 160 ProfileOAuth2TokenService* oauth2_token_service =
159 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 161 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
160 signin->Initialize(profile, NULL); 162 signin->Initialize(profile, NULL);
161 EXPECT_FALSE(signin->GetAuthenticatedUsername().empty()); 163 EXPECT_FALSE(signin->GetAuthenticatedUsername().empty());
162 return new ProfileSyncService( 164 return new ProfileSyncService(
163 new ProfileSyncComponentsFactoryMock(), 165 new ProfileSyncComponentsFactoryMock(),
164 profile, 166 profile,
165 signin, 167 new ManagedUserSigninManagerWrapper(signin),
166 oauth2_token_service, 168 oauth2_token_service,
167 ProfileSyncService::AUTO_START); 169 ProfileSyncService::AUTO_START);
168 } 170 }
169 }; 171 };
170 172
171 TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { 173 TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) {
172 // We've never completed startup. 174 // We've never completed startup.
173 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); 175 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
174 SigninManagerFactory::GetForProfile( 176 SigninManagerFactory::GetForProfile(
175 profile_.get())->Initialize(profile_.get(), NULL); 177 profile_.get())->Initialize(profile_.get(), NULL);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); 516 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
515 517
516 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); 518 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
517 IssueTestTokens(); 519 IssueTestTokens();
518 520
519 sync_->SetSetupInProgress(true); 521 sync_->SetSetupInProgress(true);
520 sync_->Initialize(); 522 sync_->Initialize();
521 sync_->SetSetupInProgress(false); 523 sync_->SetSetupInProgress(false);
522 EXPECT_FALSE(sync_->sync_initialized()); 524 EXPECT_FALSE(sync_->sync_initialized());
523 } 525 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698