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