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/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 "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/prefs/pref_service_syncable.h" | 9 #include "chrome/browser/prefs/pref_service_syncable.h" |
10 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 10 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 testing_facotries); | 92 testing_facotries); |
93 } | 93 } |
94 | 94 |
95 virtual void TearDown() { | 95 virtual void TearDown() { |
96 sync_->RemoveObserver(&observer_); | 96 sync_->RemoveObserver(&observer_); |
97 } | 97 } |
98 | 98 |
99 static KeyedService* BuildService(content::BrowserContext* browser_context) { | 99 static KeyedService* BuildService(content::BrowserContext* browser_context) { |
100 Profile* profile = static_cast<Profile*>(browser_context); | 100 Profile* profile = static_cast<Profile*>(browser_context); |
101 return new ProfileSyncService( | 101 return new ProfileSyncService( |
102 new ProfileSyncComponentsFactoryMock(), | 102 scoped_ptr<ProfileSyncComponentsFactory>( |
| 103 new ProfileSyncComponentsFactoryMock()), |
103 profile, | 104 profile, |
104 make_scoped_ptr(new SupervisedUserSigninManagerWrapper( | 105 make_scoped_ptr(new SupervisedUserSigninManagerWrapper( |
105 profile, SigninManagerFactory::GetForProfile(profile))), | 106 profile, SigninManagerFactory::GetForProfile(profile))), |
106 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 107 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
107 browser_sync::MANUAL_START); | 108 browser_sync::MANUAL_START); |
108 } | 109 } |
109 | 110 |
110 void CreateSyncService() { | 111 void CreateSyncService() { |
111 sync_ = static_cast<ProfileSyncService*>( | 112 sync_ = static_cast<ProfileSyncService*>( |
112 ProfileSyncServiceFactory::GetForProfile(profile_)); | 113 ProfileSyncServiceFactory::GetForProfile(profile_)); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 Profile* profile = static_cast<Profile*>(context); | 177 Profile* profile = static_cast<Profile*>(context); |
177 SigninManagerBase* signin = | 178 SigninManagerBase* signin = |
178 SigninManagerFactory::GetForProfile(profile); | 179 SigninManagerFactory::GetForProfile(profile); |
179 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, | 180 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, |
180 "test_user@gmail.com"); | 181 "test_user@gmail.com"); |
181 signin->SetAuthenticatedUsername("test_user@gmail.com"); | 182 signin->SetAuthenticatedUsername("test_user@gmail.com"); |
182 ProfileOAuth2TokenService* oauth2_token_service = | 183 ProfileOAuth2TokenService* oauth2_token_service = |
183 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 184 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
184 EXPECT_FALSE(signin->GetAuthenticatedUsername().empty()); | 185 EXPECT_FALSE(signin->GetAuthenticatedUsername().empty()); |
185 return new ProfileSyncService( | 186 return new ProfileSyncService( |
186 new ProfileSyncComponentsFactoryMock(), | 187 scoped_ptr<ProfileSyncComponentsFactory>( |
| 188 new ProfileSyncComponentsFactoryMock()), |
187 profile, | 189 profile, |
188 make_scoped_ptr(new SupervisedUserSigninManagerWrapper(profile, | 190 make_scoped_ptr(new SupervisedUserSigninManagerWrapper(profile, |
189 signin)), | 191 signin)), |
190 oauth2_token_service, | 192 oauth2_token_service, |
191 browser_sync::AUTO_START); | 193 browser_sync::AUTO_START); |
192 } | 194 } |
193 }; | 195 }; |
194 | 196 |
195 TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { | 197 TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { |
196 // We've never completed startup. | 198 // We've never completed startup. |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); | 522 profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); |
521 | 523 |
522 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 524 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
523 sync_->Initialize(); | 525 sync_->Initialize(); |
524 | 526 |
525 sync_->SetSetupInProgress(true); | 527 sync_->SetSetupInProgress(true); |
526 IssueTestTokens(); | 528 IssueTestTokens(); |
527 sync_->SetSetupInProgress(false); | 529 sync_->SetSetupInProgress(false); |
528 EXPECT_FALSE(sync_->sync_initialized()); | 530 EXPECT_FALSE(sync_->sync_initialized()); |
529 } | 531 } |
OLD | NEW |