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_service.h" | 5 #include "components/sync/device_info/device_info_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 | 753 |
| 754 // Pointer address of metadata should remain constant because the processor | 754 // Pointer address of metadata should remain constant because the processor |
| 755 // should not have been given new metadata. | 755 // should not have been given new metadata. |
| 756 local_device()->Initialize(CreateDeviceInfo()); | 756 local_device()->Initialize(CreateDeviceInfo()); |
| 757 base::RunLoop().RunUntilIdle(); | 757 base::RunLoop().RunUntilIdle(); |
| 758 EXPECT_EQ(metadata, processor()->metadata()); | 758 EXPECT_EQ(metadata, processor()->metadata()); |
| 759 } | 759 } |
| 760 | 760 |
| 761 TEST_F(DeviceInfoServiceTest, SendLocalData) { | 761 TEST_F(DeviceInfoServiceTest, SendLocalData) { |
| 762 InitializeAndPump(); | 762 InitializeAndPump(); |
| 763 EXPECT_EQ(1, service()->CountActiveDevices()); | |
| 764 EXPECT_EQ(1, change_count()); | 763 EXPECT_EQ(1, change_count()); |
| 765 EXPECT_EQ(1u, processor()->put_multimap().size()); | 764 EXPECT_EQ(1u, processor()->put_multimap().size()); |
| 766 | 765 |
| 767 ForcePulse(); | 766 ForcePulse(); |
| 768 EXPECT_EQ(1, service()->CountActiveDevices()); | |
| 769 EXPECT_EQ(2, change_count()); | 767 EXPECT_EQ(2, change_count()); |
| 770 EXPECT_EQ(2u, processor()->put_multimap().size()); | 768 EXPECT_EQ(2u, processor()->put_multimap().size()); |
| 771 | 769 |
| 770 // After clearing, pulsing should no-op and not result in a processor put or | |
| 771 // a notification to observers. | |
| 772 local_device()->Clear(); | 772 local_device()->Clear(); |
| 773 ForcePulse(); | 773 ForcePulse(); |
| 774 EXPECT_EQ(1, service()->CountActiveDevices()); | |
| 775 EXPECT_EQ(2, change_count()); | 774 EXPECT_EQ(2, change_count()); |
| 776 EXPECT_EQ(2u, processor()->put_multimap().size()); | 775 EXPECT_EQ(2u, processor()->put_multimap().size()); |
| 777 } | 776 } |
| 778 | 777 |
| 778 TEST_F(DeviceInfoServiceTest, DisableSync) { | |
| 779 InitializeAndPump(); | |
| 780 EXPECT_EQ(1u, service()->GetAllDeviceInfo().size()); | |
| 781 EXPECT_EQ(1, change_count()); | |
| 782 | |
| 783 DeviceInfoSpecifics specifics = GenerateTestSpecifics(); | |
| 784 EntityChangeList add_changes; | |
| 785 PushBackEntityChangeAdd(specifics, &add_changes); | |
| 786 EXPECT_FALSE( | |
| 787 service() | |
|
maxbogue
2016/10/26 18:18:30
nit: pull the error out onto a separate line to ma
skym
2016/10/26 18:24:35
Done.
| |
| 788 ->ApplySyncChanges(service()->CreateMetadataChangeList(), add_changes) | |
| 789 .IsSet()); | |
| 790 EXPECT_EQ(2u, service()->GetAllDeviceInfo().size()); | |
| 791 EXPECT_EQ(2, change_count()); | |
| 792 | |
| 793 // Should clear out all local data and notify observers. | |
| 794 service()->DisableSync(); | |
| 795 EXPECT_EQ(0u, service()->GetAllDeviceInfo().size()); | |
| 796 EXPECT_EQ(3, change_count()); | |
| 797 | |
| 798 // Reloading from storage shouldn't contain remote data. | |
| 799 RestartService(); | |
| 800 EXPECT_EQ(1u, service()->GetAllDeviceInfo().size()); | |
| 801 EXPECT_EQ(4, change_count()); | |
| 802 } | |
| 803 | |
| 779 } // namespace | 804 } // namespace |
| 780 | 805 |
| 781 } // namespace syncer | 806 } // namespace syncer |
| OLD | NEW |