Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/device_info/device_info_sync_bridge.h" | 5 #include "components/sync/device_info/device_info_sync_bridge.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 const std::map<std::string, DeviceInfoSpecifics> expected{ | 491 const std::map<std::string, DeviceInfoSpecifics> expected{ |
| 492 {specifics1.cache_guid(), specifics1}, | 492 {specifics1.cache_guid(), specifics1}, |
| 493 {specifics2.cache_guid(), specifics2}}; | 493 {specifics2.cache_guid(), specifics2}}; |
| 494 bridge()->GetData({specifics1.cache_guid(), specifics2.cache_guid()}, | 494 bridge()->GetData({specifics1.cache_guid(), specifics2.cache_guid()}, |
| 495 base::Bind(&VerifyDataBatch, expected)); | 495 base::Bind(&VerifyDataBatch, expected)); |
| 496 } | 496 } |
| 497 | 497 |
| 498 TEST_F(DeviceInfoSyncBridgeTest, ApplySyncChangesEmpty) { | 498 TEST_F(DeviceInfoSyncBridgeTest, ApplySyncChangesEmpty) { |
| 499 InitializeAndPump(); | 499 InitializeAndPump(); |
| 500 EXPECT_EQ(1, change_count()); | 500 EXPECT_EQ(1, change_count()); |
| 501 const ModelError error = bridge()->ApplySyncChanges( | 501 auto error = bridge()->ApplySyncChanges(bridge()->CreateMetadataChangeList(), |
| 502 bridge()->CreateMetadataChangeList(), EntityChangeList()); | 502 EntityChangeList()); |
| 503 EXPECT_FALSE(error.IsSet()); | 503 EXPECT_FALSE(error); |
| 504 EXPECT_EQ(1, change_count()); | 504 EXPECT_EQ(1, change_count()); |
| 505 } | 505 } |
| 506 | 506 |
| 507 TEST_F(DeviceInfoSyncBridgeTest, ApplySyncChangesInMemory) { | 507 TEST_F(DeviceInfoSyncBridgeTest, ApplySyncChangesInMemory) { |
| 508 InitializeAndPump(); | 508 InitializeAndPump(); |
| 509 EXPECT_EQ(1, change_count()); | 509 EXPECT_EQ(1, change_count()); |
| 510 | 510 |
| 511 const DeviceInfoSpecifics specifics = CreateSpecifics(1); | 511 const DeviceInfoSpecifics specifics = CreateSpecifics(1); |
| 512 const ModelError error_on_add = bridge()->ApplySyncChanges( | 512 auto error_on_add = bridge()->ApplySyncChanges( |
| 513 bridge()->CreateMetadataChangeList(), EntityAddList({specifics})); | 513 bridge()->CreateMetadataChangeList(), EntityAddList({specifics})); |
| 514 | 514 |
| 515 EXPECT_FALSE(error_on_add.IsSet()); | 515 EXPECT_FALSE(error_on_add); |
| 516 std::unique_ptr<DeviceInfo> info = | 516 std::unique_ptr<DeviceInfo> info = |
| 517 bridge()->GetDeviceInfo(specifics.cache_guid()); | 517 bridge()->GetDeviceInfo(specifics.cache_guid()); |
| 518 ASSERT_TRUE(info); | 518 ASSERT_TRUE(info); |
| 519 VerifyEqual(specifics, *info.get()); | 519 VerifyEqual(specifics, *info.get()); |
| 520 EXPECT_EQ(2, change_count()); | 520 EXPECT_EQ(2, change_count()); |
| 521 | 521 |
| 522 const ModelError error_on_delete = bridge()->ApplySyncChanges( | 522 auto error_on_delete = bridge()->ApplySyncChanges( |
| 523 bridge()->CreateMetadataChangeList(), | 523 bridge()->CreateMetadataChangeList(), |
| 524 {EntityChange::CreateDelete(specifics.cache_guid())}); | 524 {EntityChange::CreateDelete(specifics.cache_guid())}); |
| 525 | 525 |
| 526 EXPECT_FALSE(error_on_delete.IsSet()); | 526 EXPECT_FALSE(error_on_delete); |
| 527 EXPECT_FALSE(bridge()->GetDeviceInfo(specifics.cache_guid())); | 527 EXPECT_FALSE(bridge()->GetDeviceInfo(specifics.cache_guid())); |
| 528 EXPECT_EQ(3, change_count()); | 528 EXPECT_EQ(3, change_count()); |
| 529 } | 529 } |
| 530 | 530 |
| 531 TEST_F(DeviceInfoSyncBridgeTest, ApplySyncChangesStore) { | 531 TEST_F(DeviceInfoSyncBridgeTest, ApplySyncChangesStore) { |
| 532 InitializeAndPump(); | 532 InitializeAndPump(); |
| 533 EXPECT_EQ(1, change_count()); | 533 EXPECT_EQ(1, change_count()); |
| 534 | 534 |
| 535 const DeviceInfoSpecifics specifics = CreateSpecifics(1); | 535 const DeviceInfoSpecifics specifics = CreateSpecifics(1); |
| 536 ModelTypeState state = StateWithEncryption("ekn"); | 536 ModelTypeState state = StateWithEncryption("ekn"); |
| 537 std::unique_ptr<MetadataChangeList> metadata_changes = | 537 std::unique_ptr<MetadataChangeList> metadata_changes = |
| 538 bridge()->CreateMetadataChangeList(); | 538 bridge()->CreateMetadataChangeList(); |
| 539 metadata_changes->UpdateModelTypeState(state); | 539 metadata_changes->UpdateModelTypeState(state); |
| 540 | 540 |
| 541 const ModelError error = bridge()->ApplySyncChanges( | 541 auto error = bridge()->ApplySyncChanges(std::move(metadata_changes), |
| 542 std::move(metadata_changes), EntityAddList({specifics})); | 542 EntityAddList({specifics})); |
| 543 EXPECT_FALSE(error.IsSet()); | 543 EXPECT_FALSE(error); |
| 544 EXPECT_EQ(2, change_count()); | 544 EXPECT_EQ(2, change_count()); |
| 545 | 545 |
| 546 RestartBridge(); | 546 RestartBridge(); |
| 547 | 547 |
| 548 std::unique_ptr<DeviceInfo> info = | 548 std::unique_ptr<DeviceInfo> info = |
| 549 bridge()->GetDeviceInfo(specifics.cache_guid()); | 549 bridge()->GetDeviceInfo(specifics.cache_guid()); |
| 550 ASSERT_TRUE(info); | 550 ASSERT_TRUE(info); |
| 551 VerifyEqual(specifics, *info.get()); | 551 VerifyEqual(specifics, *info.get()); |
| 552 | 552 |
| 553 EXPECT_TRUE(processor()->metadata()); | 553 EXPECT_TRUE(processor()->metadata()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 568 EXPECT_EQ(1, change_count()); | 568 EXPECT_EQ(1, change_count()); |
| 569 // Ensure |last_updated| is about now, plus or minus a little bit. | 569 // Ensure |last_updated| is about now, plus or minus a little bit. |
| 570 const Time last_updated(ProtoTimeToTime(processor() | 570 const Time last_updated(ProtoTimeToTime(processor() |
| 571 ->put_multimap() | 571 ->put_multimap() |
| 572 .begin() | 572 .begin() |
| 573 ->second->specifics.device_info() | 573 ->second->specifics.device_info() |
| 574 .last_updated_timestamp())); | 574 .last_updated_timestamp())); |
| 575 EXPECT_LT(Time::Now() - TimeDelta::FromMinutes(1), last_updated); | 575 EXPECT_LT(Time::Now() - TimeDelta::FromMinutes(1), last_updated); |
| 576 EXPECT_GT(Time::Now() + TimeDelta::FromMinutes(1), last_updated); | 576 EXPECT_GT(Time::Now() + TimeDelta::FromMinutes(1), last_updated); |
| 577 | 577 |
| 578 const ModelError error_on_add = bridge()->ApplySyncChanges( | 578 auto error_on_add = bridge()->ApplySyncChanges( |
| 579 bridge()->CreateMetadataChangeList(), EntityAddList({specifics})); | 579 bridge()->CreateMetadataChangeList(), EntityAddList({specifics})); |
| 580 EXPECT_FALSE(error_on_add.IsSet()); | 580 EXPECT_FALSE(error_on_add); |
| 581 EXPECT_EQ(1, change_count()); | 581 EXPECT_EQ(1, change_count()); |
| 582 | 582 |
| 583 const ModelError error_on_delete = bridge()->ApplySyncChanges( | 583 auto error_on_delete = bridge()->ApplySyncChanges( |
| 584 bridge()->CreateMetadataChangeList(), | 584 bridge()->CreateMetadataChangeList(), |
| 585 {EntityChange::CreateDelete(specifics.cache_guid())}); | 585 {EntityChange::CreateDelete(specifics.cache_guid())}); |
| 586 EXPECT_FALSE(error_on_delete.IsSet()); | 586 EXPECT_FALSE(error_on_delete); |
| 587 EXPECT_EQ(1, change_count()); | 587 EXPECT_EQ(1, change_count()); |
| 588 } | 588 } |
| 589 | 589 |
| 590 TEST_F(DeviceInfoSyncBridgeTest, ApplyDeleteNonexistent) { | 590 TEST_F(DeviceInfoSyncBridgeTest, ApplyDeleteNonexistent) { |
| 591 InitializeAndPump(); | 591 InitializeAndPump(); |
| 592 EXPECT_EQ(1, change_count()); | 592 EXPECT_EQ(1, change_count()); |
| 593 const ModelError error = | 593 auto error = bridge()->ApplySyncChanges(bridge()->CreateMetadataChangeList(), |
| 594 bridge()->ApplySyncChanges(bridge()->CreateMetadataChangeList(), | 594 {EntityChange::CreateDelete("guid")}); |
| 595 {EntityChange::CreateDelete("guid")}); | 595 EXPECT_FALSE(error); |
| 596 EXPECT_FALSE(error.IsSet()); | |
| 597 EXPECT_EQ(1, change_count()); | 596 EXPECT_EQ(1, change_count()); |
| 598 } | 597 } |
| 599 | 598 |
| 600 TEST_F(DeviceInfoSyncBridgeTest, ClearProviderAndApply) { | 599 TEST_F(DeviceInfoSyncBridgeTest, ClearProviderAndApply) { |
| 601 // This will initialize the provider a first time. | 600 // This will initialize the provider a first time. |
| 602 InitializeAndPump(); | 601 InitializeAndPump(); |
| 603 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); | 602 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); |
| 604 | 603 |
| 605 const DeviceInfoSpecifics specifics = CreateSpecifics(1, Time::Now()); | 604 const DeviceInfoSpecifics specifics = CreateSpecifics(1, Time::Now()); |
| 606 | 605 |
| 607 local_device()->Clear(); | 606 local_device()->Clear(); |
| 608 ModelError error = bridge()->ApplySyncChanges( | 607 auto error1 = bridge()->ApplySyncChanges(bridge()->CreateMetadataChangeList(), |
| 609 bridge()->CreateMetadataChangeList(), EntityAddList({specifics})); | 608 EntityAddList({specifics})); |
| 610 EXPECT_FALSE(error.IsSet()); | 609 EXPECT_FALSE(error1); |
| 611 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); | 610 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); |
| 612 | 611 |
| 613 local_device()->Initialize(CreateModel(kDefaultLocalSuffix)); | 612 local_device()->Initialize(CreateModel(kDefaultLocalSuffix)); |
| 614 error = bridge()->ApplySyncChanges(bridge()->CreateMetadataChangeList(), | 613 auto error2 = bridge()->ApplySyncChanges(bridge()->CreateMetadataChangeList(), |
| 615 EntityAddList({specifics})); | 614 EntityAddList({specifics})); |
| 615 EXPECT_FALSE(error2); | |
| 616 EXPECT_EQ(2u, bridge()->GetAllDeviceInfo().size()); | 616 EXPECT_EQ(2u, bridge()->GetAllDeviceInfo().size()); |
| 617 } | 617 } |
| 618 | 618 |
| 619 TEST_F(DeviceInfoSyncBridgeTest, MergeEmpty) { | 619 TEST_F(DeviceInfoSyncBridgeTest, MergeEmpty) { |
| 620 InitializeAndPump(); | 620 InitializeAndPump(); |
| 621 EXPECT_EQ(1, change_count()); | 621 EXPECT_EQ(1, change_count()); |
| 622 const ModelError error = bridge()->MergeSyncData( | 622 auto error = bridge()->MergeSyncData(bridge()->CreateMetadataChangeList(), |
|
skym
2017/01/10 16:24:42
Does it make sense to now do things like:
EXPECT_
maxbogue
2017/01/10 17:53:50
Generally if things are returning a boolean, false
| |
| 623 bridge()->CreateMetadataChangeList(), EntityDataMap()); | 623 EntityDataMap()); |
| 624 EXPECT_FALSE(error.IsSet()); | 624 EXPECT_FALSE(error); |
| 625 EXPECT_EQ(1, change_count()); | 625 EXPECT_EQ(1, change_count()); |
| 626 // TODO(skym): Stop sending local twice. The first of the two puts will | 626 // TODO(skym): Stop sending local twice. The first of the two puts will |
| 627 // probably happen before the processor is tracking metadata yet, and so there | 627 // probably happen before the processor is tracking metadata yet, and so there |
| 628 // should not be much overhead. | 628 // should not be much overhead. |
| 629 EXPECT_EQ(2u, processor()->put_multimap().size()); | 629 EXPECT_EQ(2u, processor()->put_multimap().size()); |
| 630 EXPECT_EQ(2u, processor()->put_multimap().count( | 630 EXPECT_EQ(2u, processor()->put_multimap().count( |
| 631 local_device()->GetLocalDeviceInfo()->guid())); | 631 local_device()->GetLocalDeviceInfo()->guid())); |
| 632 EXPECT_EQ(0u, processor()->delete_set().size()); | 632 EXPECT_EQ(0u, processor()->delete_set().size()); |
| 633 } | 633 } |
| 634 | 634 |
| 635 TEST_F(DeviceInfoSyncBridgeTest, MergeWithData) { | 635 TEST_F(DeviceInfoSyncBridgeTest, MergeWithData) { |
| 636 const DeviceInfoSpecifics unique_local = CreateSpecifics(1); | 636 const DeviceInfoSpecifics unique_local = CreateSpecifics(1); |
| 637 DeviceInfoSpecifics conflict_local = CreateSpecifics(2); | 637 DeviceInfoSpecifics conflict_local = CreateSpecifics(2); |
| 638 DeviceInfoSpecifics conflict_remote = CreateSpecifics(3); | 638 DeviceInfoSpecifics conflict_remote = CreateSpecifics(3); |
| 639 const DeviceInfoSpecifics unique_remote = CreateSpecifics(4); | 639 const DeviceInfoSpecifics unique_remote = CreateSpecifics(4); |
| 640 | 640 |
| 641 const std::string conflict_guid = "conflict_guid"; | 641 const std::string conflict_guid = "conflict_guid"; |
| 642 conflict_local.set_cache_guid(conflict_guid); | 642 conflict_local.set_cache_guid(conflict_guid); |
| 643 conflict_remote.set_cache_guid(conflict_guid); | 643 conflict_remote.set_cache_guid(conflict_guid); |
| 644 | 644 |
| 645 WriteToStore({unique_local, conflict_local}); | 645 WriteToStore({unique_local, conflict_local}); |
| 646 InitializeAndPump(); | 646 InitializeAndPump(); |
| 647 EXPECT_EQ(1, change_count()); | 647 EXPECT_EQ(1, change_count()); |
| 648 | 648 |
| 649 ModelTypeState state = StateWithEncryption("ekn"); | 649 ModelTypeState state = StateWithEncryption("ekn"); |
| 650 std::unique_ptr<MetadataChangeList> metadata_changes = | 650 std::unique_ptr<MetadataChangeList> metadata_changes = |
| 651 bridge()->CreateMetadataChangeList(); | 651 bridge()->CreateMetadataChangeList(); |
| 652 metadata_changes->UpdateModelTypeState(state); | 652 metadata_changes->UpdateModelTypeState(state); |
| 653 | 653 |
| 654 const ModelError error = bridge()->MergeSyncData( | 654 auto error = bridge()->MergeSyncData( |
| 655 std::move(metadata_changes), | 655 std::move(metadata_changes), |
| 656 InlineEntityDataMap({conflict_remote, unique_remote})); | 656 InlineEntityDataMap({conflict_remote, unique_remote})); |
| 657 EXPECT_FALSE(error.IsSet()); | 657 EXPECT_FALSE(error); |
| 658 EXPECT_EQ(2, change_count()); | 658 EXPECT_EQ(2, change_count()); |
| 659 | 659 |
| 660 // The remote should beat the local in conflict. | 660 // The remote should beat the local in conflict. |
| 661 EXPECT_EQ(4u, bridge()->GetAllDeviceInfo().size()); | 661 EXPECT_EQ(4u, bridge()->GetAllDeviceInfo().size()); |
| 662 VerifyEqual(unique_local, | 662 VerifyEqual(unique_local, |
| 663 *bridge()->GetDeviceInfo(unique_local.cache_guid()).get()); | 663 *bridge()->GetDeviceInfo(unique_local.cache_guid()).get()); |
| 664 VerifyEqual(unique_remote, | 664 VerifyEqual(unique_remote, |
| 665 *bridge()->GetDeviceInfo(unique_remote.cache_guid()).get()); | 665 *bridge()->GetDeviceInfo(unique_remote.cache_guid()).get()); |
| 666 VerifyEqual(conflict_remote, *bridge()->GetDeviceInfo(conflict_guid).get()); | 666 VerifyEqual(conflict_remote, *bridge()->GetDeviceInfo(conflict_guid).get()); |
| 667 | 667 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 679 } | 679 } |
| 680 | 680 |
| 681 TEST_F(DeviceInfoSyncBridgeTest, MergeLocalGuid) { | 681 TEST_F(DeviceInfoSyncBridgeTest, MergeLocalGuid) { |
| 682 // If not recent, then reconcile is going to try to send an updated version to | 682 // If not recent, then reconcile is going to try to send an updated version to |
| 683 // Sync, which makes interpreting change_count() more difficult. | 683 // Sync, which makes interpreting change_count() more difficult. |
| 684 const DeviceInfoSpecifics specifics = | 684 const DeviceInfoSpecifics specifics = |
| 685 CreateSpecifics(kDefaultLocalSuffix, Time::Now()); | 685 CreateSpecifics(kDefaultLocalSuffix, Time::Now()); |
| 686 WriteToStore({specifics}); | 686 WriteToStore({specifics}); |
| 687 InitializeAndPump(); | 687 InitializeAndPump(); |
| 688 | 688 |
| 689 const ModelError error = bridge()->MergeSyncData( | 689 auto error = bridge()->MergeSyncData(bridge()->CreateMetadataChangeList(), |
| 690 bridge()->CreateMetadataChangeList(), InlineEntityDataMap({specifics})); | 690 InlineEntityDataMap({specifics})); |
| 691 EXPECT_FALSE(error.IsSet()); | 691 EXPECT_FALSE(error); |
| 692 EXPECT_EQ(0, change_count()); | 692 EXPECT_EQ(0, change_count()); |
| 693 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); | 693 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); |
| 694 EXPECT_TRUE(processor()->delete_set().empty()); | 694 EXPECT_TRUE(processor()->delete_set().empty()); |
| 695 EXPECT_TRUE(processor()->put_multimap().empty()); | 695 EXPECT_TRUE(processor()->put_multimap().empty()); |
| 696 } | 696 } |
| 697 | 697 |
| 698 TEST_F(DeviceInfoSyncBridgeTest, MergeLocalGuidBeforeReconcile) { | 698 TEST_F(DeviceInfoSyncBridgeTest, MergeLocalGuidBeforeReconcile) { |
| 699 InitializeBridge(); | 699 InitializeBridge(); |
| 700 | 700 |
| 701 // The message loop is never pumped, which means local data/metadata is never | 701 // The message loop is never pumped, which means local data/metadata is never |
| 702 // loaded, and thus reconcile is never called. The bridge should ignore this | 702 // loaded, and thus reconcile is never called. The bridge should ignore this |
| 703 // EntityData because its cache guid is the same the local device's. | 703 // EntityData because its cache guid is the same the local device's. |
| 704 const ModelError error = bridge()->MergeSyncData( | 704 auto error = bridge()->MergeSyncData( |
| 705 bridge()->CreateMetadataChangeList(), | 705 bridge()->CreateMetadataChangeList(), |
| 706 InlineEntityDataMap({CreateSpecifics(kDefaultLocalSuffix)})); | 706 InlineEntityDataMap({CreateSpecifics(kDefaultLocalSuffix)})); |
| 707 EXPECT_FALSE(error.IsSet()); | 707 EXPECT_FALSE(error); |
| 708 EXPECT_EQ(0, change_count()); | 708 EXPECT_EQ(0, change_count()); |
| 709 EXPECT_EQ(0u, bridge()->GetAllDeviceInfo().size()); | 709 EXPECT_EQ(0u, bridge()->GetAllDeviceInfo().size()); |
| 710 } | 710 } |
| 711 | 711 |
| 712 TEST_F(DeviceInfoSyncBridgeTest, ClearProviderAndMerge) { | 712 TEST_F(DeviceInfoSyncBridgeTest, ClearProviderAndMerge) { |
| 713 // This will initialize the provider a first time. | 713 // This will initialize the provider a first time. |
| 714 InitializeAndPump(); | 714 InitializeAndPump(); |
| 715 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); | 715 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); |
| 716 | 716 |
| 717 const DeviceInfoSpecifics specifics = CreateSpecifics(1, Time::Now()); | 717 const DeviceInfoSpecifics specifics = CreateSpecifics(1, Time::Now()); |
| 718 | 718 |
| 719 local_device()->Clear(); | 719 local_device()->Clear(); |
| 720 ModelError error = bridge()->MergeSyncData( | 720 auto error1 = bridge()->MergeSyncData(bridge()->CreateMetadataChangeList(), |
| 721 bridge()->CreateMetadataChangeList(), InlineEntityDataMap({specifics})); | 721 InlineEntityDataMap({specifics})); |
| 722 EXPECT_FALSE(error.IsSet()); | 722 EXPECT_FALSE(error1); |
| 723 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); | 723 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); |
| 724 | |
| 724 local_device()->Initialize(CreateModel(kDefaultLocalSuffix)); | 725 local_device()->Initialize(CreateModel(kDefaultLocalSuffix)); |
| 725 error = bridge()->MergeSyncData(bridge()->CreateMetadataChangeList(), | 726 auto error2 = bridge()->MergeSyncData(bridge()->CreateMetadataChangeList(), |
| 726 InlineEntityDataMap({specifics})); | 727 InlineEntityDataMap({specifics})); |
| 728 EXPECT_FALSE(error2); | |
|
skym
2017/01/10 16:24:42
Good catch.
maxbogue
2017/01/10 17:53:50
Acknowledged.
| |
| 727 EXPECT_EQ(2u, bridge()->GetAllDeviceInfo().size()); | 729 EXPECT_EQ(2u, bridge()->GetAllDeviceInfo().size()); |
| 728 } | 730 } |
| 729 | 731 |
| 730 TEST_F(DeviceInfoSyncBridgeTest, CountActiveDevices) { | 732 TEST_F(DeviceInfoSyncBridgeTest, CountActiveDevices) { |
| 731 InitializeAndPump(); | 733 InitializeAndPump(); |
| 732 EXPECT_EQ(1, bridge()->CountActiveDevices()); | 734 EXPECT_EQ(1, bridge()->CountActiveDevices()); |
| 733 | 735 |
| 734 // Regardless of the time, these following two ApplySyncChanges(...) calls | 736 // Regardless of the time, these following two ApplySyncChanges(...) calls |
| 735 // have the same guid as the local device. | 737 // have the same guid as the local device. |
| 736 bridge()->ApplySyncChanges( | 738 bridge()->ApplySyncChanges( |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 788 EXPECT_EQ(2, change_count()); | 790 EXPECT_EQ(2, change_count()); |
| 789 EXPECT_EQ(2u, processor()->put_multimap().size()); | 791 EXPECT_EQ(2u, processor()->put_multimap().size()); |
| 790 } | 792 } |
| 791 | 793 |
| 792 TEST_F(DeviceInfoSyncBridgeTest, DisableSync) { | 794 TEST_F(DeviceInfoSyncBridgeTest, DisableSync) { |
| 793 InitializeAndPump(); | 795 InitializeAndPump(); |
| 794 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); | 796 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); |
| 795 EXPECT_EQ(1, change_count()); | 797 EXPECT_EQ(1, change_count()); |
| 796 | 798 |
| 797 const DeviceInfoSpecifics specifics = CreateSpecifics(1); | 799 const DeviceInfoSpecifics specifics = CreateSpecifics(1); |
| 798 const ModelError error = bridge()->ApplySyncChanges( | 800 auto error = bridge()->ApplySyncChanges(bridge()->CreateMetadataChangeList(), |
| 799 bridge()->CreateMetadataChangeList(), EntityAddList({specifics})); | 801 EntityAddList({specifics})); |
| 800 | 802 |
| 801 EXPECT_FALSE(error.IsSet()); | 803 EXPECT_FALSE(error); |
| 802 EXPECT_EQ(2u, bridge()->GetAllDeviceInfo().size()); | 804 EXPECT_EQ(2u, bridge()->GetAllDeviceInfo().size()); |
| 803 EXPECT_EQ(2, change_count()); | 805 EXPECT_EQ(2, change_count()); |
| 804 | 806 |
| 805 // Should clear out all local data and notify observers. | 807 // Should clear out all local data and notify observers. |
| 806 bridge()->DisableSync(); | 808 bridge()->DisableSync(); |
| 807 EXPECT_EQ(0u, bridge()->GetAllDeviceInfo().size()); | 809 EXPECT_EQ(0u, bridge()->GetAllDeviceInfo().size()); |
| 808 EXPECT_EQ(3, change_count()); | 810 EXPECT_EQ(3, change_count()); |
| 809 | 811 |
| 810 // Reloading from storage shouldn't contain remote data. | 812 // Reloading from storage shouldn't contain remote data. |
| 811 RestartBridge(); | 813 RestartBridge(); |
| 812 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); | 814 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); |
| 813 EXPECT_EQ(4, change_count()); | 815 EXPECT_EQ(4, change_count()); |
| 814 } | 816 } |
| 815 | 817 |
| 816 } // namespace | 818 } // namespace |
| 817 | 819 |
| 818 } // namespace syncer | 820 } // namespace syncer |
| OLD | NEW |