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

Side by Side Diff: components/sync/driver/glue/sync_backend_host_impl_unittest.cc

Issue 2644373003: Revert of [Sync] Make directory types registration explicit in ModelTypeRegistry (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/sync/driver/glue/sync_backend_host_impl.h" 5 #include "components/sync/driver/glue/sync_backend_host_impl.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 EXPECT_TRUE( 316 EXPECT_TRUE(
317 fake_manager_->GetTypesWithEmptyProgressMarkerToken(ControlTypes()) 317 fake_manager_->GetTypesWithEmptyProgressMarkerToken(ControlTypes())
318 .Empty()); 318 .Empty());
319 319
320 ModelTypeSet ready_types = ConfigureDataTypes(); 320 ModelTypeSet ready_types = ConfigureDataTypes();
321 // Nigori is always downloaded so won't be ready. 321 // Nigori is always downloaded so won't be ready.
322 EXPECT_EQ(Difference(ControlTypes(), ModelTypeSet(NIGORI)), ready_types); 322 EXPECT_EQ(Difference(ControlTypes(), ModelTypeSet(NIGORI)), ready_types);
323 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().HasAll( 323 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().HasAll(
324 Difference(enabled_types_, ControlTypes()))); 324 Difference(enabled_types_, ControlTypes())));
325 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes()); 325 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes());
326 EXPECT_EQ(enabled_types_, fake_manager_->GetAndResetEnabledTypes());
326 EXPECT_TRUE( 327 EXPECT_TRUE(
327 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_) 328 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_)
328 .Empty()); 329 .Empty());
329 } 330 }
330 331
331 // Test the restart after setting up sync scenario. No enabled types should be 332 // Test the restart after setting up sync scenario. No enabled types should be
332 // downloaded or cleaned. 333 // downloaded or cleaned.
333 TEST_F(SyncEngineTest, Restart) { 334 TEST_F(SyncEngineTest, Restart) {
334 sync_prefs_->SetFirstSetupComplete(); 335 sync_prefs_->SetFirstSetupComplete();
335 ModelTypeSet all_but_nigori = enabled_types_; 336 ModelTypeSet all_but_nigori = enabled_types_;
336 fake_manager_factory_->set_progress_marker_types(enabled_types_); 337 fake_manager_factory_->set_progress_marker_types(enabled_types_);
337 fake_manager_factory_->set_initial_sync_ended_types(enabled_types_); 338 fake_manager_factory_->set_initial_sync_ended_types(enabled_types_);
338 InitializeBackend(true); 339 InitializeBackend(true);
339 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty()); 340 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty());
340 EXPECT_TRUE( 341 EXPECT_TRUE(
341 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_) 342 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_)
342 .Empty()); 343 .Empty());
343 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes()); 344 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes());
344 EXPECT_TRUE( 345 EXPECT_TRUE(
345 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_) 346 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_)
346 .Empty()); 347 .Empty());
347 348
348 ModelTypeSet ready_types = ConfigureDataTypes(); 349 ModelTypeSet ready_types = ConfigureDataTypes();
349 EXPECT_EQ(enabled_types_, ready_types); 350 EXPECT_EQ(enabled_types_, ready_types);
350 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty()); 351 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty());
351 EXPECT_TRUE( 352 EXPECT_TRUE(
352 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_) 353 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_)
353 .Empty()); 354 .Empty());
354 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes()); 355 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes());
356 EXPECT_EQ(enabled_types_, fake_manager_->GetAndResetEnabledTypes());
355 EXPECT_TRUE( 357 EXPECT_TRUE(
356 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_) 358 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_)
357 .Empty()); 359 .Empty());
358 } 360 }
359 361
360 // Test a sync restart scenario where some types had never finished configuring. 362 // Test a sync restart scenario where some types had never finished configuring.
361 // The partial types should be purged, then reconfigured properly. 363 // The partial types should be purged, then reconfigured properly.
362 TEST_F(SyncEngineTest, PartialTypes) { 364 TEST_F(SyncEngineTest, PartialTypes) {
363 sync_prefs_->SetFirstSetupComplete(); 365 sync_prefs_->SetFirstSetupComplete();
364 // Set sync manager behavior before passing it down. All types have progress 366 // Set sync manager behavior before passing it down. All types have progress
(...skipping 15 matching lines...) Expand all
380 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_)); 382 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_));
381 383
382 // Now do the actual configuration, which should download and apply bookmarks. 384 // Now do the actual configuration, which should download and apply bookmarks.
383 ModelTypeSet ready_types = ConfigureDataTypes(); 385 ModelTypeSet ready_types = ConfigureDataTypes();
384 EXPECT_EQ(full_types, ready_types); 386 EXPECT_EQ(full_types, ready_types);
385 EXPECT_TRUE( 387 EXPECT_TRUE(
386 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_) 388 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_)
387 .Empty()); 389 .Empty());
388 EXPECT_EQ(partial_types, fake_manager_->GetAndResetDownloadedTypes()); 390 EXPECT_EQ(partial_types, fake_manager_->GetAndResetDownloadedTypes());
389 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes()); 391 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes());
392 EXPECT_EQ(enabled_types_, fake_manager_->GetAndResetEnabledTypes());
390 EXPECT_TRUE( 393 EXPECT_TRUE(
391 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_) 394 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_)
392 .Empty()); 395 .Empty());
393 } 396 }
394 397
395 // Test the behavior when we lose the sync db. Although we already have types 398 // Test the behavior when we lose the sync db. Although we already have types
396 // enabled, we should re-download all of them because we lost their data. 399 // enabled, we should re-download all of them because we lost their data.
397 TEST_F(SyncEngineTest, LostDB) { 400 TEST_F(SyncEngineTest, LostDB) {
398 sync_prefs_->SetFirstSetupComplete(); 401 sync_prefs_->SetFirstSetupComplete();
399 // Initialization should fetch the Nigori node. Everything else should be 402 // Initialization should fetch the Nigori node. Everything else should be
(...skipping 14 matching lines...) Expand all
414 // The actual configuration should redownload and apply all the enabled types. 417 // The actual configuration should redownload and apply all the enabled types.
415 ModelTypeSet ready_types = ConfigureDataTypes(); 418 ModelTypeSet ready_types = ConfigureDataTypes();
416 // Nigori is always downloaded so won't be ready. 419 // Nigori is always downloaded so won't be ready.
417 EXPECT_EQ(Difference(ControlTypes(), ModelTypeSet(NIGORI)), ready_types); 420 EXPECT_EQ(Difference(ControlTypes(), ModelTypeSet(NIGORI)), ready_types);
418 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().HasAll( 421 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().HasAll(
419 Difference(enabled_types_, ControlTypes()))); 422 Difference(enabled_types_, ControlTypes())));
420 EXPECT_TRUE( 423 EXPECT_TRUE(
421 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_) 424 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_)
422 .Empty()); 425 .Empty());
423 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes()); 426 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes());
427 EXPECT_EQ(enabled_types_, fake_manager_->GetAndResetEnabledTypes());
424 EXPECT_TRUE( 428 EXPECT_TRUE(
425 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_) 429 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_)
426 .Empty()); 430 .Empty());
427 } 431 }
428 432
429 TEST_F(SyncEngineTest, DisableTypes) { 433 TEST_F(SyncEngineTest, DisableTypes) {
430 // Simulate first time sync. 434 // Simulate first time sync.
431 InitializeBackend(true); 435 InitializeBackend(true);
432 fake_manager_->GetAndResetPurgedTypes(); 436 fake_manager_->GetAndResetPurgedTypes();
433 ModelTypeSet ready_types = ConfigureDataTypes(); 437 ModelTypeSet ready_types = ConfigureDataTypes();
(...skipping 14 matching lines...) Expand all
448 enabled_types_.RemoveAll(disabled_types); 452 enabled_types_.RemoveAll(disabled_types);
449 ready_types = ConfigureDataTypes(); 453 ready_types = ConfigureDataTypes();
450 454
451 // Only those datatypes disabled should be cleaned. Nothing should be 455 // Only those datatypes disabled should be cleaned. Nothing should be
452 // downloaded. 456 // downloaded.
453 EXPECT_EQ(enabled_types_, ready_types); 457 EXPECT_EQ(enabled_types_, ready_types);
454 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty()); 458 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty());
455 EXPECT_EQ(disabled_types, 459 EXPECT_EQ(disabled_types,
456 Intersection(fake_manager_->GetAndResetPurgedTypes(), old_types)); 460 Intersection(fake_manager_->GetAndResetPurgedTypes(), old_types));
457 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes()); 461 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes());
462 EXPECT_EQ(enabled_types_, fake_manager_->GetAndResetEnabledTypes());
458 EXPECT_TRUE( 463 EXPECT_TRUE(
459 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_) 464 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_)
460 .Empty()); 465 .Empty());
461 } 466 }
462 467
463 TEST_F(SyncEngineTest, AddTypes) { 468 TEST_F(SyncEngineTest, AddTypes) {
464 // Simulate first time sync. 469 // Simulate first time sync.
465 InitializeBackend(true); 470 InitializeBackend(true);
466 fake_manager_->GetAndResetPurgedTypes(); 471 fake_manager_->GetAndResetPurgedTypes();
467 ModelTypeSet ready_types = ConfigureDataTypes(); 472 ModelTypeSet ready_types = ConfigureDataTypes();
(...skipping 15 matching lines...) Expand all
483 488
484 // Only those datatypes added should be downloaded (plus nigori). Nothing 489 // Only those datatypes added should be downloaded (plus nigori). Nothing
485 // should be cleaned aside from the disabled types. 490 // should be cleaned aside from the disabled types.
486 new_types.Put(NIGORI); 491 new_types.Put(NIGORI);
487 EXPECT_EQ(Difference(enabled_types_, new_types), ready_types); 492 EXPECT_EQ(Difference(enabled_types_, new_types), ready_types);
488 EXPECT_EQ(new_types, fake_manager_->GetAndResetDownloadedTypes()); 493 EXPECT_EQ(new_types, fake_manager_->GetAndResetDownloadedTypes());
489 EXPECT_TRUE( 494 EXPECT_TRUE(
490 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_) 495 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_)
491 .Empty()); 496 .Empty());
492 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes()); 497 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes());
498 EXPECT_EQ(enabled_types_, fake_manager_->GetAndResetEnabledTypes());
493 EXPECT_TRUE( 499 EXPECT_TRUE(
494 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_) 500 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_)
495 .Empty()); 501 .Empty());
496 } 502 }
497 503
498 // And and disable in the same configuration. 504 // And and disable in the same configuration.
499 TEST_F(SyncEngineTest, AddDisableTypes) { 505 TEST_F(SyncEngineTest, AddDisableTypes) {
500 // Simulate first time sync. 506 // Simulate first time sync.
501 InitializeBackend(true); 507 InitializeBackend(true);
502 fake_manager_->GetAndResetPurgedTypes(); 508 fake_manager_->GetAndResetPurgedTypes();
(...skipping 18 matching lines...) Expand all
521 ready_types = ConfigureDataTypes(); 527 ready_types = ConfigureDataTypes();
522 528
523 // Only those datatypes added should be downloaded (plus nigori). Nothing 529 // Only those datatypes added should be downloaded (plus nigori). Nothing
524 // should be cleaned aside from the disabled types. 530 // should be cleaned aside from the disabled types.
525 new_types.Put(NIGORI); 531 new_types.Put(NIGORI);
526 EXPECT_EQ(Difference(enabled_types_, new_types), ready_types); 532 EXPECT_EQ(Difference(enabled_types_, new_types), ready_types);
527 EXPECT_EQ(new_types, fake_manager_->GetAndResetDownloadedTypes()); 533 EXPECT_EQ(new_types, fake_manager_->GetAndResetDownloadedTypes());
528 EXPECT_EQ(disabled_types, 534 EXPECT_EQ(disabled_types,
529 Intersection(fake_manager_->GetAndResetPurgedTypes(), old_types)); 535 Intersection(fake_manager_->GetAndResetPurgedTypes(), old_types));
530 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes()); 536 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes());
537 EXPECT_EQ(enabled_types_, fake_manager_->GetAndResetEnabledTypes());
531 EXPECT_EQ(disabled_types, 538 EXPECT_EQ(disabled_types,
532 fake_manager_->GetTypesWithEmptyProgressMarkerToken(old_types)); 539 fake_manager_->GetTypesWithEmptyProgressMarkerToken(old_types));
533 } 540 }
534 541
535 // Test restarting the browser to newly supported datatypes. The new datatypes 542 // Test restarting the browser to newly supported datatypes. The new datatypes
536 // should be downloaded on the configuration after backend initialization. 543 // should be downloaded on the configuration after backend initialization.
537 TEST_F(SyncEngineTest, NewlySupportedTypes) { 544 TEST_F(SyncEngineTest, NewlySupportedTypes) {
538 sync_prefs_->SetFirstSetupComplete(); 545 sync_prefs_->SetFirstSetupComplete();
539 // Set sync manager behavior before passing it down. All types have progress 546 // Set sync manager behavior before passing it down. All types have progress
540 // markers and initial sync ended except the new types. 547 // markers and initial sync ended except the new types.
(...skipping 15 matching lines...) Expand all
556 // Downloads and applies the new types (plus nigori). 563 // Downloads and applies the new types (plus nigori).
557 ModelTypeSet ready_types = ConfigureDataTypes(); 564 ModelTypeSet ready_types = ConfigureDataTypes();
558 565
559 new_types.Put(NIGORI); 566 new_types.Put(NIGORI);
560 EXPECT_EQ(Difference(old_types, ModelTypeSet(NIGORI)), ready_types); 567 EXPECT_EQ(Difference(old_types, ModelTypeSet(NIGORI)), ready_types);
561 EXPECT_EQ(new_types, fake_manager_->GetAndResetDownloadedTypes()); 568 EXPECT_EQ(new_types, fake_manager_->GetAndResetDownloadedTypes());
562 EXPECT_TRUE( 569 EXPECT_TRUE(
563 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_) 570 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_)
564 .Empty()); 571 .Empty());
565 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes()); 572 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes());
573 EXPECT_EQ(enabled_types_, fake_manager_->GetAndResetEnabledTypes());
566 EXPECT_TRUE( 574 EXPECT_TRUE(
567 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_) 575 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_)
568 .Empty()); 576 .Empty());
569 } 577 }
570 578
571 // Test the newly supported types scenario, but with the presence of partial 579 // Test the newly supported types scenario, but with the presence of partial
572 // types as well. Both partial and newly supported types should be downloaded 580 // types as well. Both partial and newly supported types should be downloaded
573 // the configuration. 581 // the configuration.
574 TEST_F(SyncEngineTest, NewlySupportedTypesWithPartialTypes) { 582 TEST_F(SyncEngineTest, NewlySupportedTypesWithPartialTypes) {
575 sync_prefs_->SetFirstSetupComplete(); 583 sync_prefs_->SetFirstSetupComplete();
(...skipping 21 matching lines...) Expand all
597 // Downloads and applies the new types and partial types (which includes 605 // Downloads and applies the new types and partial types (which includes
598 // nigori anyways). 606 // nigori anyways).
599 ModelTypeSet ready_types = ConfigureDataTypes(); 607 ModelTypeSet ready_types = ConfigureDataTypes();
600 EXPECT_EQ(full_types, ready_types); 608 EXPECT_EQ(full_types, ready_types);
601 EXPECT_EQ(Union(new_types, partial_types), 609 EXPECT_EQ(Union(new_types, partial_types),
602 fake_manager_->GetAndResetDownloadedTypes()); 610 fake_manager_->GetAndResetDownloadedTypes());
603 EXPECT_TRUE( 611 EXPECT_TRUE(
604 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_) 612 Intersection(fake_manager_->GetAndResetPurgedTypes(), enabled_types_)
605 .Empty()); 613 .Empty());
606 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes()); 614 EXPECT_EQ(enabled_types_, fake_manager_->InitialSyncEndedTypes());
615 EXPECT_EQ(enabled_types_, fake_manager_->GetAndResetEnabledTypes());
607 EXPECT_TRUE( 616 EXPECT_TRUE(
608 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_) 617 fake_manager_->GetTypesWithEmptyProgressMarkerToken(enabled_types_)
609 .Empty()); 618 .Empty());
610 } 619 }
611 620
612 // Verify that downloading control types only downloads those types that do 621 // Verify that downloading control types only downloads those types that do
613 // not have initial sync ended set. 622 // not have initial sync ended set.
614 TEST_F(SyncEngineTest, DownloadControlTypes) { 623 TEST_F(SyncEngineTest, DownloadControlTypes) {
615 sync_prefs_->SetFirstSetupComplete(); 624 sync_prefs_->SetFirstSetupComplete();
616 // Set sync manager behavior before passing it down. Experiments and device 625 // Set sync manager behavior before passing it down. Experiments and device
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 backend_->StopSyncingForShutdown(); 809 backend_->StopSyncingForShutdown();
801 // Verify that call to DeactivateNonBlockingDataType doesn't assert. 810 // Verify that call to DeactivateNonBlockingDataType doesn't assert.
802 backend_->DeactivateNonBlockingDataType(AUTOFILL); 811 backend_->DeactivateNonBlockingDataType(AUTOFILL);
803 backend_->Shutdown(STOP_SYNC); 812 backend_->Shutdown(STOP_SYNC);
804 backend_.reset(); 813 backend_.reset();
805 } 814 }
806 815
807 } // namespace 816 } // namespace
808 817
809 } // namespace syncer 818 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/glue/sync_backend_host_impl.cc ('k') | components/sync/driver/model_association_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698