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

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 profile,
100 SigninManagerFactory::GetForProfile(profile)),
98 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), 101 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
99 ProfileSyncService::MANUAL_START); 102 ProfileSyncService::MANUAL_START);
100 } 103 }
101 104
102 void CreateSyncService() { 105 void CreateSyncService() {
103 sync_ = static_cast<ProfileSyncService*>( 106 sync_ = static_cast<ProfileSyncService*>(
104 ProfileSyncServiceFactory::GetForProfile(profile_.get())); 107 ProfileSyncServiceFactory::GetForProfile(profile_.get()));
105 sync_->AddObserver(&observer_); 108 sync_->AddObserver(&observer_);
106 } 109 }
107 110
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 SigninManagerFactory::GetForProfile(profile); 158 SigninManagerFactory::GetForProfile(profile);
156 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, 159 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
157 "test_user@gmail.com"); 160 "test_user@gmail.com");
158 ProfileOAuth2TokenService* oauth2_token_service = 161 ProfileOAuth2TokenService* oauth2_token_service =
159 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 162 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
160 signin->Initialize(profile, NULL); 163 signin->Initialize(profile, NULL);
161 EXPECT_FALSE(signin->GetAuthenticatedUsername().empty()); 164 EXPECT_FALSE(signin->GetAuthenticatedUsername().empty());
162 return new ProfileSyncService( 165 return new ProfileSyncService(
163 new ProfileSyncComponentsFactoryMock(), 166 new ProfileSyncComponentsFactoryMock(),
164 profile, 167 profile,
165 signin, 168 new ManagedUserSigninManagerWrapper(profile, signin),
166 oauth2_token_service, 169 oauth2_token_service,
167 ProfileSyncService::AUTO_START); 170 ProfileSyncService::AUTO_START);
168 } 171 }
169 }; 172 };
170 173
171 TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { 174 TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) {
172 // We've never completed startup. 175 // We've never completed startup.
173 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); 176 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
174 SigninManagerFactory::GetForProfile( 177 SigninManagerFactory::GetForProfile(
175 profile_.get())->Initialize(profile_.get(), NULL); 178 profile_.get())->Initialize(profile_.get(), NULL);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); 517 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
515 518
516 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); 519 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
517 IssueTestTokens(); 520 IssueTestTokens();
518 521
519 sync_->SetSetupInProgress(true); 522 sync_->SetSetupInProgress(true);
520 sync_->Initialize(); 523 sync_->Initialize();
521 sync_->SetSetupInProgress(false); 524 sync_->SetSetupInProgress(false);
522 EXPECT_FALSE(sync_->sync_initialized()); 525 EXPECT_FALSE(sync_->sync_initialized());
523 } 526 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698