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/files/file_util.h" | 5 #include "base/files/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/account_tracker_service_factory.h" | 10 #include "chrome/browser/signin/account_tracker_service_factory.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 BuildService)); | 114 BuildService)); |
115 | 115 |
116 profile_ = profile_manager_.CreateTestingProfile( | 116 profile_ = profile_manager_.CreateTestingProfile( |
117 "sync-startup-test", scoped_ptr<PrefServiceSyncable>(), | 117 "sync-startup-test", scoped_ptr<PrefServiceSyncable>(), |
118 base::UTF8ToUTF16("sync-startup-test"), 0, std::string(), | 118 base::UTF8ToUTF16("sync-startup-test"), 0, std::string(), |
119 testing_facotries); | 119 testing_facotries); |
120 } | 120 } |
121 | 121 |
122 void TearDown() override { sync_->RemoveObserver(&observer_); } | 122 void TearDown() override { sync_->RemoveObserver(&observer_); } |
123 | 123 |
124 static KeyedService* BuildService(content::BrowserContext* browser_context) { | 124 static scoped_ptr<KeyedService> BuildService( |
| 125 content::BrowserContext* browser_context) { |
125 Profile* profile = static_cast<Profile*>(browser_context); | 126 Profile* profile = static_cast<Profile*>(browser_context); |
126 return new TestProfileSyncServiceNoBackup( | 127 return make_scoped_ptr(new TestProfileSyncServiceNoBackup( |
127 scoped_ptr<ProfileSyncComponentsFactory>( | 128 scoped_ptr<ProfileSyncComponentsFactory>( |
128 new ProfileSyncComponentsFactoryMock()), | 129 new ProfileSyncComponentsFactoryMock()), |
129 profile, | 130 profile, make_scoped_ptr(new SupervisedUserSigninManagerWrapper( |
130 make_scoped_ptr(new SupervisedUserSigninManagerWrapper( | 131 profile, SigninManagerFactory::GetForProfile(profile))), |
131 profile, SigninManagerFactory::GetForProfile(profile))), | |
132 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 132 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
133 browser_sync::MANUAL_START); | 133 browser_sync::MANUAL_START)); |
134 } | 134 } |
135 | 135 |
136 void CreateSyncService() { | 136 void CreateSyncService() { |
137 sync_ = static_cast<ProfileSyncService*>( | 137 sync_ = static_cast<ProfileSyncService*>( |
138 ProfileSyncServiceFactory::GetForProfile(profile_)); | 138 ProfileSyncServiceFactory::GetForProfile(profile_)); |
139 sync_->AddObserver(&observer_); | 139 sync_->AddObserver(&observer_); |
140 } | 140 } |
141 | 141 |
142 void IssueTestTokens(const std::string& account_id) { | 142 void IssueTestTokens(const std::string& account_id) { |
143 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) | 143 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest { | 210 class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest { |
211 public: | 211 public: |
212 void SetUp() override { | 212 void SetUp() override { |
213 ProfileSyncServiceStartupTest::SetUp(); | 213 ProfileSyncServiceStartupTest::SetUp(); |
214 sync_ = static_cast<ProfileSyncService*>( | 214 sync_ = static_cast<ProfileSyncService*>( |
215 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 215 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
216 profile_, BuildCrosService)); | 216 profile_, BuildCrosService)); |
217 sync_->AddObserver(&observer_); | 217 sync_->AddObserver(&observer_); |
218 } | 218 } |
219 | 219 |
220 static KeyedService* BuildCrosService(content::BrowserContext* context) { | 220 static scoped_ptr<KeyedService> BuildCrosService( |
| 221 content::BrowserContext* context) { |
221 Profile* profile = static_cast<Profile*>(context); | 222 Profile* profile = static_cast<Profile*>(context); |
222 FakeSigninManagerForTesting* signin = | 223 FakeSigninManagerForTesting* signin = |
223 static_cast<FakeSigninManagerForTesting*>( | 224 static_cast<FakeSigninManagerForTesting*>( |
224 SigninManagerFactory::GetForProfile(profile)); | 225 SigninManagerFactory::GetForProfile(profile)); |
225 SimulateTestUserSignin(profile, signin, nullptr); | 226 SimulateTestUserSignin(profile, signin, nullptr); |
226 ProfileOAuth2TokenService* oauth2_token_service = | 227 ProfileOAuth2TokenService* oauth2_token_service = |
227 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 228 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
228 EXPECT_TRUE(signin->IsAuthenticated()); | 229 EXPECT_TRUE(signin->IsAuthenticated()); |
229 return new TestProfileSyncServiceNoBackup( | 230 return make_scoped_ptr(new TestProfileSyncServiceNoBackup( |
230 scoped_ptr<ProfileSyncComponentsFactory>( | 231 scoped_ptr<ProfileSyncComponentsFactory>( |
231 new ProfileSyncComponentsFactoryMock()), | 232 new ProfileSyncComponentsFactoryMock()), |
232 profile, | 233 profile, make_scoped_ptr( |
233 make_scoped_ptr(new SupervisedUserSigninManagerWrapper(profile, | 234 new SupervisedUserSigninManagerWrapper(profile, signin)), |
234 signin)), | 235 oauth2_token_service, browser_sync::AUTO_START)); |
235 oauth2_token_service, | |
236 browser_sync::AUTO_START); | |
237 } | 236 } |
238 }; | 237 }; |
239 | 238 |
240 TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { | 239 TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { |
241 // We've never completed startup. | 240 // We've never completed startup. |
242 profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); | 241 profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); |
243 CreateSyncService(); | 242 CreateSyncService(); |
244 SetUpSyncBackendHost(); | 243 SetUpSyncBackendHost(); |
245 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); | 244 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); |
246 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0); | 245 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); | 572 profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); |
574 | 573 |
575 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 574 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
576 sync_->Initialize(); | 575 sync_->Initialize(); |
577 | 576 |
578 sync_->SetSetupInProgress(true); | 577 sync_->SetSetupInProgress(true); |
579 IssueTestTokens(account_id); | 578 IssueTestTokens(account_id); |
580 sync_->SetSetupInProgress(false); | 579 sync_->SetSetupInProgress(false); |
581 EXPECT_FALSE(sync_->IsSyncActive()); | 580 EXPECT_FALSE(sync_->IsSyncActive()); |
582 } | 581 } |
OLD | NEW |