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

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

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

Powered by Google App Engine
This is Rietveld 408576698