| 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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 | 656 |
| 657 const SyncError error = bridge()->MergeSyncData( | 657 const SyncError error = bridge()->MergeSyncData( |
| 658 bridge()->CreateMetadataChangeList(), remote_input); | 658 bridge()->CreateMetadataChangeList(), remote_input); |
| 659 EXPECT_FALSE(error.IsSet()); | 659 EXPECT_FALSE(error.IsSet()); |
| 660 EXPECT_EQ(0, change_count()); | 660 EXPECT_EQ(0, change_count()); |
| 661 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); | 661 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); |
| 662 EXPECT_TRUE(processor()->delete_set().empty()); | 662 EXPECT_TRUE(processor()->delete_set().empty()); |
| 663 EXPECT_TRUE(processor()->put_multimap().empty()); | 663 EXPECT_TRUE(processor()->put_multimap().empty()); |
| 664 } | 664 } |
| 665 | 665 |
| 666 TEST_F(DeviceInfoSyncBridgeTest, MergeLocalGuidBeforeReconcile) { |
| 667 InitializeBridge(); |
| 668 const DeviceInfoSpecifics specifics = CreateSpecifics(kDefaultLocalSuffix); |
| 669 |
| 670 // The message loop is never pumped, which means local data/metadata is never |
| 671 // loaded, and thus reconcile is never called. The bridge should ignore this |
| 672 // EntityData because its cache guid is the same the local device's. |
| 673 const SyncError error = bridge()->MergeSyncData( |
| 674 bridge()->CreateMetadataChangeList(), |
| 675 {{specifics.cache_guid(), SpecificsToEntity(specifics)}}); |
| 676 EXPECT_FALSE(error.IsSet()); |
| 677 EXPECT_EQ(0, change_count()); |
| 678 EXPECT_EQ(0u, bridge()->GetAllDeviceInfo().size()); |
| 679 } |
| 680 |
| 666 TEST_F(DeviceInfoSyncBridgeTest, CountActiveDevices) { | 681 TEST_F(DeviceInfoSyncBridgeTest, CountActiveDevices) { |
| 667 InitializeAndPump(); | 682 InitializeAndPump(); |
| 668 EXPECT_EQ(1, bridge()->CountActiveDevices()); | 683 EXPECT_EQ(1, bridge()->CountActiveDevices()); |
| 669 | 684 |
| 670 DeviceInfoSpecifics specifics = CreateSpecifics(0); | 685 DeviceInfoSpecifics specifics = CreateSpecifics(0); |
| 671 bridge()->ApplySyncChanges(bridge()->CreateMetadataChangeList(), | 686 bridge()->ApplySyncChanges(bridge()->CreateMetadataChangeList(), |
| 672 EntityAddList({specifics})); | 687 EntityAddList({specifics})); |
| 673 EXPECT_EQ(1, bridge()->CountActiveDevices()); | 688 EXPECT_EQ(1, bridge()->CountActiveDevices()); |
| 674 | 689 |
| 675 specifics.set_last_updated_timestamp(TimeToProtoTime(Time::Now())); | 690 specifics.set_last_updated_timestamp(TimeToProtoTime(Time::Now())); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 | 759 |
| 745 // Reloading from storage shouldn't contain remote data. | 760 // Reloading from storage shouldn't contain remote data. |
| 746 RestartBridge(); | 761 RestartBridge(); |
| 747 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); | 762 EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size()); |
| 748 EXPECT_EQ(4, change_count()); | 763 EXPECT_EQ(4, change_count()); |
| 749 } | 764 } |
| 750 | 765 |
| 751 } // namespace | 766 } // namespace |
| 752 | 767 |
| 753 } // namespace syncer | 768 } // namespace syncer |
| OLD | NEW |