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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/invalidation/invalidation_service_factory.h" | 11 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
12 #include "chrome/browser/signin/signin_manager.h" | 12 #include "chrome/browser/signin/signin_manager.h" |
13 #include "chrome/browser/signin/signin_manager_factory.h" | 13 #include "chrome/browser/signin/signin_manager_factory.h" |
14 #include "chrome/browser/signin/token_service.h" | 14 #include "chrome/browser/signin/token_service.h" |
15 #include "chrome/browser/signin/token_service_factory.h" | 15 #include "chrome/browser/signin/token_service_factory.h" |
16 #include "chrome/browser/sync/fake_oauth2_token_service.h" | 16 #include "chrome/browser/sync/fake_oauth2_token_service.h" |
17 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" | 17 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" |
18 #include "chrome/browser/sync/glue/data_type_controller.h" | 18 #include "chrome/browser/sync/glue/data_type_controller.h" |
| 19 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" |
19 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" | 20 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
20 #include "chrome/browser/sync/test_profile_sync_service.h" | 21 #include "chrome/browser/sync/test_profile_sync_service.h" |
21 #include "chrome/common/chrome_version_info.h" | 22 #include "chrome/common/chrome_version_info.h" |
22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
23 #include "chrome/test/base/testing_pref_service_syncable.h" | 24 #include "chrome/test/base/testing_pref_service_syncable.h" |
24 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
25 #include "content/public/test/test_browser_thread_bundle.h" | 26 #include "content/public/test/test_browser_thread_bundle.h" |
26 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
27 #include "google/cacheinvalidation/include/types.h" | 28 #include "google/cacheinvalidation/include/types.h" |
28 #include "google_apis/gaia/gaia_constants.h" | 29 #include "google_apis/gaia/gaia_constants.h" |
(...skipping 23 matching lines...) Expand all Loading... |
52 } | 53 } |
53 | 54 |
54 class ProfileSyncServiceTest : public testing::Test { | 55 class ProfileSyncServiceTest : public testing::Test { |
55 protected: | 56 protected: |
56 ProfileSyncServiceTest() | 57 ProfileSyncServiceTest() |
57 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | | 58 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | |
58 content::TestBrowserThreadBundle::REAL_FILE_THREAD | | 59 content::TestBrowserThreadBundle::REAL_FILE_THREAD | |
59 content::TestBrowserThreadBundle::REAL_IO_THREAD) { | 60 content::TestBrowserThreadBundle::REAL_IO_THREAD) { |
60 } | 61 } |
61 | 62 |
62 virtual void SetUp() OVERRIDE { | 63 virtual ~ProfileSyncServiceTest() {} |
| 64 |
| 65 virtual void SetUp() OVERRIDE { |
63 TestingProfile::Builder builder; | 66 TestingProfile::Builder builder; |
64 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), | 67 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
65 FakeOAuth2TokenService::BuildTokenService); | 68 FakeOAuth2TokenService::BuildTokenService); |
66 profile_ = builder.Build().Pass(); | 69 profile_ = builder.Build().Pass(); |
67 invalidation::InvalidationServiceFactory::GetInstance()-> | 70 invalidation::InvalidationServiceFactory::GetInstance()-> |
68 SetBuildOnlyFakeInvalidatorsForTest(true); | 71 SetBuildOnlyFakeInvalidatorsForTest(true); |
69 } | 72 } |
70 | 73 |
71 virtual void TearDown() OVERRIDE { | 74 virtual void TearDown() OVERRIDE { |
72 // Kill the service before the profile. | 75 // Kill the service before the profile. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 : service_(service), first_setup_in_progress_(false) {} | 168 : service_(service), first_setup_in_progress_(false) {} |
166 virtual void OnStateChanged() OVERRIDE { | 169 virtual void OnStateChanged() OVERRIDE { |
167 first_setup_in_progress_ = service_->FirstSetupInProgress(); | 170 first_setup_in_progress_ = service_->FirstSetupInProgress(); |
168 } | 171 } |
169 bool first_setup_in_progress() const { return first_setup_in_progress_; } | 172 bool first_setup_in_progress() const { return first_setup_in_progress_; } |
170 private: | 173 private: |
171 ProfileSyncService* service_; | 174 ProfileSyncService* service_; |
172 bool first_setup_in_progress_; | 175 bool first_setup_in_progress_; |
173 }; | 176 }; |
174 | 177 |
175 TEST_F(ProfileSyncServiceTest, InitialState) { | 178 // A variant of the SyncBackendHostMock that won't automatically |
176 SigninManagerBase* signin = | 179 // call back when asked to initialized. Allows us to test things |
177 SigninManagerFactory::GetForProfile(profile_.get()); | 180 // that could happen while backend init is in progress. |
178 ProfileOAuth2TokenService* oauth2_token_service = | 181 class SyncBackendHostNoReturn : public SyncBackendHostMock { |
179 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 182 virtual void Initialize( |
180 service_.reset(new TestProfileSyncService( | 183 SyncFrontend* frontend, |
181 new ProfileSyncComponentsFactoryMock(), | 184 scoped_ptr<base::Thread> sync_thread, |
182 profile_.get(), | 185 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
183 signin, | 186 const GURL& service_url, |
184 oauth2_token_service, | 187 const syncer::SyncCredentials& credentials, |
185 ProfileSyncService::MANUAL_START, | 188 bool delete_sync_data_folder, |
186 true)); | 189 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, |
187 service_->Initialize(); | 190 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler, |
188 EXPECT_TRUE( | 191 syncer::ReportUnrecoverableErrorFunction |
189 service_->sync_service_url().spec() == | 192 report_unrecoverable_error_function) OVERRIDE {} |
190 ProfileSyncService::kSyncServerUrl || | 193 }; |
191 service_->sync_service_url().spec() == | 194 |
192 ProfileSyncService::kDevServerUrl); | 195 ACTION(ReturnNewSyncBackendHostMock) { |
193 } | 196 return new browser_sync::SyncBackendHostMock(); |
194 | 197 } |
195 // Tests that the sync service doesn't forget to notify observers about | 198 |
196 // setup state. | 199 ACTION(ReturnNewSyncBackendHostNoReturn) { |
197 TEST(ProfileSyncServiceTestBasic, SetupInProgress) { | 200 return new browser_sync::SyncBackendHostNoReturn(); |
198 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 201 } |
199 ProfileSyncService service( | 202 |
200 NULL, profile.get(), NULL, NULL, | 203 // A test harness that uses a real ProfileSyncService and in most cases a |
201 ProfileSyncService::MANUAL_START); | 204 // MockSyncBackendHost. |
202 TestProfileSyncServiceObserver observer(&service); | 205 // |
203 service.AddObserver(&observer); | 206 // This is useful if we want to test the ProfileSyncService and don't care about |
204 service.SetSetupInProgress(true); | 207 // testing the SyncBackendHost. It's easier to use than the other tests, since |
| 208 // it doesn't involve any threads. |
| 209 class ProfileSyncServiceSimpleTest : public ::testing::Test { |
| 210 protected: |
| 211 ProfileSyncServiceSimpleTest() |
| 212 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} |
| 213 virtual ~ProfileSyncServiceSimpleTest() {} |
| 214 |
| 215 virtual void SetUp() OVERRIDE { |
| 216 TestingProfile::Builder builder; |
| 217 |
| 218 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
| 219 FakeOAuth2TokenService::BuildTokenService); |
| 220 invalidation::InvalidationServiceFactory::GetInstance()-> |
| 221 SetBuildOnlyFakeInvalidatorsForTest(true); |
| 222 |
| 223 profile_ = builder.Build().Pass(); |
| 224 } |
| 225 |
| 226 virtual void TearDown() OVERRIDE { |
| 227 // Kill the service before the profile. |
| 228 if (service_) |
| 229 service_->Shutdown(); |
| 230 |
| 231 service_.reset(); |
| 232 profile_.reset(); |
| 233 } |
| 234 |
| 235 void IssueTestTokens() { |
| 236 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()) |
| 237 ->UpdateCredentials("test", "oauth2_login_token"); |
| 238 } |
| 239 |
| 240 void CreateService(ProfileSyncService::StartBehavior behavior) { |
| 241 SigninManagerBase* signin = |
| 242 SigninManagerFactory::GetForProfile(profile_.get()); |
| 243 signin->SetAuthenticatedUsername("test"); |
| 244 ProfileOAuth2TokenService* oauth2_token_service = |
| 245 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); |
| 246 components_factory_ = new StrictMock<ProfileSyncComponentsFactoryMock>(); |
| 247 service_.reset(new ProfileSyncService( |
| 248 components_factory_, |
| 249 profile_.get(), |
| 250 signin, |
| 251 oauth2_token_service, |
| 252 behavior)); |
| 253 } |
| 254 |
| 255 void ShutdownAndDeleteService() { |
| 256 if (service_) |
| 257 service_->Shutdown(); |
| 258 service_.reset(); |
| 259 } |
| 260 |
| 261 void Initialize() { |
| 262 service_->Initialize(); |
| 263 } |
| 264 |
| 265 void ExpectDataTypeManagerCreation() { |
| 266 EXPECT_CALL(*components_factory_, CreateDataTypeManager(_, _, _, _, _, _)). |
| 267 WillOnce(ReturnNewDataTypeManager()); |
| 268 } |
| 269 |
| 270 void ExpectSyncBackendHostCreation() { |
| 271 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _)). |
| 272 WillOnce(ReturnNewSyncBackendHostMock()); |
| 273 } |
| 274 |
| 275 void PrepareDelayedInitSyncBackendHost() { |
| 276 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _)). |
| 277 WillOnce(ReturnNewSyncBackendHostNoReturn()); |
| 278 } |
| 279 |
| 280 TestingProfile* profile() { |
| 281 return profile_.get(); |
| 282 } |
| 283 |
| 284 ProfileSyncService* service() { |
| 285 return service_.get(); |
| 286 } |
| 287 |
| 288 ProfileSyncComponentsFactoryMock* components_factory() { |
| 289 return components_factory_; |
| 290 } |
| 291 |
| 292 private: |
| 293 scoped_ptr<TestingProfile> profile_; |
| 294 scoped_ptr<ProfileSyncService> service_; |
| 295 |
| 296 // Pointer to the components factory. Not owned. May be null. |
| 297 ProfileSyncComponentsFactoryMock* components_factory_; |
| 298 |
| 299 content::TestBrowserThreadBundle thread_bundle_; |
| 300 }; |
| 301 |
| 302 // Verify that the server URLs are sane. |
| 303 TEST_F(ProfileSyncServiceSimpleTest, InitialState) { |
| 304 CreateService(ProfileSyncService::AUTO_START); |
| 305 Initialize(); |
| 306 const std::string& url = service()->sync_service_url().spec(); |
| 307 EXPECT_TRUE(url == ProfileSyncService::kSyncServerUrl || |
| 308 url == ProfileSyncService::kDevServerUrl); |
| 309 } |
| 310 |
| 311 // Verify a successful initialization. |
| 312 TEST_F(ProfileSyncServiceSimpleTest, SuccessfulInitialization) { |
| 313 profile()->GetTestingPrefService()->SetManagedPref( |
| 314 prefs::kSyncManaged, |
| 315 Value::CreateBooleanValue(false)); |
| 316 IssueTestTokens(); |
| 317 CreateService(ProfileSyncService::AUTO_START); |
| 318 ExpectDataTypeManagerCreation(); |
| 319 ExpectSyncBackendHostCreation(); |
| 320 Initialize(); |
| 321 EXPECT_FALSE(service()->IsManaged()); |
| 322 EXPECT_TRUE(service()->sync_initialized()); |
| 323 } |
| 324 |
| 325 |
| 326 // Verify that the SetSetupInProgress function call updates state |
| 327 // and notifies observers. |
| 328 TEST_F(ProfileSyncServiceSimpleTest, SetupInProgress) { |
| 329 CreateService(ProfileSyncService::MANUAL_START); |
| 330 Initialize(); |
| 331 |
| 332 TestProfileSyncServiceObserver observer(service()); |
| 333 service()->AddObserver(&observer); |
| 334 |
| 335 service()->SetSetupInProgress(true); |
205 EXPECT_TRUE(observer.first_setup_in_progress()); | 336 EXPECT_TRUE(observer.first_setup_in_progress()); |
206 service.SetSetupInProgress(false); | 337 service()->SetSetupInProgress(false); |
207 EXPECT_FALSE(observer.first_setup_in_progress()); | 338 EXPECT_FALSE(observer.first_setup_in_progress()); |
208 service.RemoveObserver(&observer); | 339 |
209 } | 340 service()->RemoveObserver(&observer); |
210 | 341 } |
211 TEST_F(ProfileSyncServiceTest, DisabledByPolicy) { | 342 |
212 profile_->GetTestingPrefService()->SetManagedPref( | 343 // Verify that disable by enterprise policy works. |
| 344 TEST_F(ProfileSyncServiceSimpleTest, DisabledByPolicyBeforeInit) { |
| 345 profile()->GetTestingPrefService()->SetManagedPref( |
213 prefs::kSyncManaged, | 346 prefs::kSyncManaged, |
214 Value::CreateBooleanValue(true)); | 347 Value::CreateBooleanValue(true)); |
215 SigninManagerBase* signin = | 348 IssueTestTokens(); |
216 SigninManagerFactory::GetForProfile(profile_.get()); | 349 CreateService(ProfileSyncService::AUTO_START); |
217 ProfileOAuth2TokenService* oauth2_token_service = | 350 Initialize(); |
218 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 351 EXPECT_TRUE(service()->IsManaged()); |
219 service_.reset(new TestProfileSyncService( | 352 EXPECT_FALSE(service()->sync_initialized()); |
220 new ProfileSyncComponentsFactoryMock(), | 353 } |
221 profile_.get(), | 354 |
222 signin, | 355 // Verify that disable by enterprise policy works even after the backend has |
223 oauth2_token_service, | 356 // been initialized. |
224 ProfileSyncService::MANUAL_START, | 357 TEST_F(ProfileSyncServiceSimpleTest, DisabledByPolicyAfterInit) { |
225 true)); | 358 IssueTestTokens(); |
226 service_->Initialize(); | 359 CreateService(ProfileSyncService::AUTO_START); |
227 EXPECT_TRUE(service_->IsManaged()); | 360 ExpectDataTypeManagerCreation(); |
228 } | 361 ExpectSyncBackendHostCreation(); |
229 | 362 Initialize(); |
230 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { | 363 |
231 SigninManagerBase* signin = | 364 EXPECT_FALSE(service()->IsManaged()); |
232 SigninManagerFactory::GetForProfile(profile_.get()); | 365 EXPECT_TRUE(service()->sync_initialized()); |
233 signin->SetAuthenticatedUsername("test"); | 366 |
234 ProfileOAuth2TokenService* oauth2_token_service = | 367 profile()->GetTestingPrefService()->SetManagedPref( |
235 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 368 prefs::kSyncManaged, |
236 ProfileSyncComponentsFactoryMock* factory = | 369 Value::CreateBooleanValue(true)); |
237 new ProfileSyncComponentsFactoryMock(); | 370 |
238 service_.reset(new TestProfileSyncService( | 371 EXPECT_TRUE(service()->IsManaged()); |
239 factory, | 372 EXPECT_FALSE(service()->sync_initialized()); |
240 profile_.get(), | 373 } |
241 signin, | 374 |
242 oauth2_token_service, | 375 // Exercies the ProfileSyncService's code paths related to getting shut down |
243 ProfileSyncService::AUTO_START, | 376 // before the backend initialize call returns. |
244 true)); | 377 TEST_F(ProfileSyncServiceSimpleTest, AbortedByShutdown) { |
245 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _, _)).Times(0); | 378 CreateService(ProfileSyncService::AUTO_START); |
246 EXPECT_CALL(*factory, CreateBookmarkSyncComponents(_, _)). | 379 PrepareDelayedInitSyncBackendHost(); |
247 Times(0); | 380 |
248 service_->RegisterDataTypeController( | 381 IssueTestTokens(); |
249 new BookmarkDataTypeController(service_->factory(), | 382 Initialize(); |
250 profile_.get(), | 383 EXPECT_FALSE(service()->sync_initialized()); |
251 service_.get())); | 384 |
252 | 385 ShutdownAndDeleteService(); |
253 service_->Initialize(); | 386 } |
254 service_->Shutdown(); | 387 |
255 service_.reset(); | 388 // Test StopAndSuppress() before we've initialized the backend. |
256 } | 389 TEST_F(ProfileSyncServiceSimpleTest, EarlyStopAndSuppress) { |
257 | 390 CreateService(ProfileSyncService::AUTO_START); |
258 TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) { | 391 IssueTestTokens(); |
259 SigninManagerBase* signin = | 392 |
260 SigninManagerFactory::GetForProfile(profile_.get()); | 393 service()->StopAndSuppress(); |
261 signin->SetAuthenticatedUsername("test"); | 394 EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
262 ProfileOAuth2TokenService* oauth2_token_service = | 395 |
263 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 396 // Because of supression, this should fail. |
264 ProfileSyncComponentsFactoryMock* factory = | 397 Initialize(); |
265 new ProfileSyncComponentsFactoryMock(); | 398 EXPECT_FALSE(service()->sync_initialized()); |
266 service_.reset(new TestProfileSyncService( | 399 |
267 factory, | 400 // Remove suppression. This should be enough to allow init to happen. |
268 profile_.get(), | 401 ExpectDataTypeManagerCreation(); |
269 signin, | 402 ExpectSyncBackendHostCreation(); |
270 oauth2_token_service, | 403 service()->UnsuppressAndStart(); |
271 ProfileSyncService::AUTO_START, | 404 EXPECT_TRUE(service()->sync_initialized()); |
272 true)); | |
273 // Register the bookmark data type. | |
274 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _, _)). | |
275 WillRepeatedly(ReturnNewDataTypeManager()); | |
276 | |
277 IssueTestTokens(); | |
278 | |
279 service_->Initialize(); | |
280 EXPECT_TRUE(service_->sync_initialized()); | |
281 EXPECT_TRUE(service_->GetBackendForTest() != NULL); | |
282 EXPECT_FALSE( | 405 EXPECT_FALSE( |
283 profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); | 406 profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
284 | 407 } |
285 service_->StopAndSuppress(); | 408 |
286 EXPECT_FALSE(service_->sync_initialized()); | 409 // Test StopAndSuppress() after we've initialized the backend. |
287 EXPECT_TRUE( | 410 TEST_F(ProfileSyncServiceSimpleTest, DisableAndEnableSyncTemporarily) { |
288 profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); | 411 CreateService(ProfileSyncService::AUTO_START); |
289 | 412 IssueTestTokens(); |
290 service_->UnsuppressAndStart(); | 413 ExpectDataTypeManagerCreation(); |
291 EXPECT_TRUE(service_->sync_initialized()); | 414 ExpectSyncBackendHostCreation(); |
| 415 Initialize(); |
| 416 |
| 417 EXPECT_TRUE(service()->sync_initialized()); |
| 418 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
| 419 |
| 420 testing::Mock::VerifyAndClearExpectations(components_factory()); |
| 421 |
| 422 service()->StopAndSuppress(); |
| 423 EXPECT_FALSE(service()->sync_initialized()); |
| 424 EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
| 425 |
| 426 ExpectDataTypeManagerCreation(); |
| 427 ExpectSyncBackendHostCreation(); |
| 428 |
| 429 service()->UnsuppressAndStart(); |
| 430 EXPECT_TRUE(service()->sync_initialized()); |
292 EXPECT_FALSE( | 431 EXPECT_FALSE( |
293 profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); | 432 profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
294 } | 433 } |
295 | 434 |
296 // Certain ProfileSyncService tests don't apply to Chrome OS, for example | 435 // Certain ProfileSyncService tests don't apply to Chrome OS, for example |
297 // things that deal with concepts like "signing out" and policy. | 436 // things that deal with concepts like "signing out" and policy. |
298 #if !defined (OS_CHROMEOS) | 437 #if !defined (OS_CHROMEOS) |
299 | 438 |
300 TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) { | 439 TEST_F(ProfileSyncServiceSimpleTest, EnableSyncAndSignOut) { |
301 SigninManager* signin = | 440 CreateService(ProfileSyncService::AUTO_START); |
302 SigninManagerFactory::GetForProfile(profile_.get()); | 441 ExpectDataTypeManagerCreation(); |
303 signin->SetAuthenticatedUsername("test"); | 442 ExpectSyncBackendHostCreation(); |
304 ProfileOAuth2TokenService* oauth2_token_service = | 443 IssueTestTokens(); |
305 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 444 Initialize(); |
306 ProfileSyncComponentsFactoryMock* factory = | 445 |
307 new ProfileSyncComponentsFactoryMock(); | 446 EXPECT_TRUE(service()->sync_initialized()); |
308 service_.reset(new TestProfileSyncService( | 447 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
309 factory, | 448 |
310 profile_.get(), | 449 SigninManagerFactory::GetForProfile(profile())->SignOut(); |
311 signin, | 450 EXPECT_FALSE(service()->sync_initialized()); |
312 oauth2_token_service, | |
313 ProfileSyncService::AUTO_START, | |
314 true)); | |
315 // Register the bookmark data type. | |
316 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _, _)). | |
317 WillRepeatedly(ReturnNewDataTypeManager()); | |
318 | |
319 IssueTestTokens(); | |
320 | |
321 service_->Initialize(); | |
322 EXPECT_TRUE(service_->sync_initialized()); | |
323 EXPECT_TRUE(service_->GetBackendForTest() != NULL); | |
324 EXPECT_FALSE( | |
325 profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); | |
326 | |
327 signin->SignOut(); | |
328 EXPECT_FALSE(service_->sync_initialized()); | |
329 } | 451 } |
330 | 452 |
331 #endif // !defined(OS_CHROMEOS) | 453 #endif // !defined(OS_CHROMEOS) |
332 | 454 |
333 TEST_F(ProfileSyncServiceTest, JsControllerHandlersBasic) { | 455 TEST_F(ProfileSyncServiceTest, JsControllerHandlersBasic) { |
334 StartSyncService(); | 456 StartSyncService(); |
335 EXPECT_TRUE(service_->sync_initialized()); | 457 EXPECT_TRUE(service_->sync_initialized()); |
336 EXPECT_TRUE(service_->GetBackendForTest() != NULL); | 458 EXPECT_TRUE(service_->GetBackendForTest() != NULL); |
337 | 459 |
338 base::WeakPtr<syncer::JsController> js_controller = | 460 base::WeakPtr<syncer::JsController> js_controller = |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 EXPECT_TRUE(token_status.next_token_request_time.is_null()); | 638 EXPECT_TRUE(token_status.next_token_request_time.is_null()); |
517 | 639 |
518 // Simulate successful connection. | 640 // Simulate successful connection. |
519 service_->OnConnectionStatusChange(syncer::CONNECTION_OK); | 641 service_->OnConnectionStatusChange(syncer::CONNECTION_OK); |
520 token_status = service_->GetSyncTokenStatus(); | 642 token_status = service_->GetSyncTokenStatus(); |
521 EXPECT_EQ(syncer::CONNECTION_OK, token_status.connection_status); | 643 EXPECT_EQ(syncer::CONNECTION_OK, token_status.connection_status); |
522 } | 644 } |
523 | 645 |
524 } // namespace | 646 } // namespace |
525 } // namespace browser_sync | 647 } // namespace browser_sync |
OLD | NEW |