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

Side by Side Diff: components/sync/device_info/device_info_service_unittest.cc

Issue 2451793003: [Sync] Avoid sending the processor metadata again on re-enabling sync. (Closed)
Patch Set: Update for Max. Created 4 years, 1 month 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
« no previous file with comments | « components/sync/device_info/device_info_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 local_device()->Initialize(CreateDeviceInfo()); 331 local_device()->Initialize(CreateDeviceInfo());
332 base::RunLoop().RunUntilIdle(); 332 base::RunLoop().RunUntilIdle();
333 333
334 DeviceInfoList devices = service()->GetAllDeviceInfo(); 334 DeviceInfoList devices = service()->GetAllDeviceInfo();
335 ASSERT_EQ(1u, devices.size()); 335 ASSERT_EQ(1u, devices.size());
336 ASSERT_TRUE(local_device()->GetLocalDeviceInfo()->Equals(*devices[0])); 336 ASSERT_TRUE(local_device()->GetLocalDeviceInfo()->Equals(*devices[0]));
337 } 337 }
338 338
339 // Metadata shouldn't be loaded before the provider is initialized. 339 // Metadata shouldn't be loaded before the provider is initialized.
340 TEST_F(DeviceInfoServiceTest, LocalProviderInitRace) { 340 TEST_F(DeviceInfoServiceTest, LocalProviderInitRace) {
341 set_local_device(base::WrapUnique(new LocalDeviceInfoProviderMock())); 341 set_local_device(base::MakeUnique<LocalDeviceInfoProviderMock>());
342 InitializeAndPump(); 342 InitializeAndPump();
343 EXPECT_FALSE(processor()->metadata()); 343 EXPECT_FALSE(processor()->metadata());
344 344
345 ASSERT_EQ(0u, service()->GetAllDeviceInfo().size()); 345 ASSERT_EQ(0u, service()->GetAllDeviceInfo().size());
346 local_device()->Initialize(CreateDeviceInfo()); 346 local_device()->Initialize(CreateDeviceInfo());
347 base::RunLoop().RunUntilIdle(); 347 base::RunLoop().RunUntilIdle();
348 348
349 DeviceInfoList devices = service()->GetAllDeviceInfo(); 349 DeviceInfoList devices = service()->GetAllDeviceInfo();
350 ASSERT_EQ(1u, devices.size()); 350 ASSERT_EQ(1u, devices.size());
351 ASSERT_TRUE(local_device()->GetLocalDeviceInfo()->Equals(*devices[0])); 351 ASSERT_TRUE(local_device()->GetLocalDeviceInfo()->Equals(*devices[0]));
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 EXPECT_EQ(1, service()->CountActiveDevices()); 724 EXPECT_EQ(1, service()->CountActiveDevices());
725 725
726 change_list.clear(); 726 change_list.clear();
727 specifics.set_cache_guid("non-local"); 727 specifics.set_cache_guid("non-local");
728 PushBackEntityChangeAdd(specifics, &change_list); 728 PushBackEntityChangeAdd(specifics, &change_list);
729 service()->ApplySyncChanges(service()->CreateMetadataChangeList(), 729 service()->ApplySyncChanges(service()->CreateMetadataChangeList(),
730 change_list); 730 change_list);
731 EXPECT_EQ(2, service()->CountActiveDevices()); 731 EXPECT_EQ(2, service()->CountActiveDevices());
732 } 732 }
733 733
734 TEST_F(DeviceInfoServiceTest, MultipleOnProviderInitialized) {
735 set_local_device(base::MakeUnique<LocalDeviceInfoProviderMock>());
736 InitializeAndPump();
737 EXPECT_EQ(nullptr, processor()->metadata());
738
739 // Verify the processor was given metadata.
740 local_device()->Initialize(CreateDeviceInfo());
741 base::RunLoop().RunUntilIdle();
742 const MetadataBatch* metadata = processor()->metadata();
743 EXPECT_NE(nullptr, metadata);
744
745 // Pointer address of metadata should remain constant because the processor
746 // should not have been given new metadata.
747 local_device()->Initialize(CreateDeviceInfo());
748 base::RunLoop().RunUntilIdle();
749 EXPECT_EQ(metadata, processor()->metadata());
750 }
751
734 } // namespace 752 } // namespace
735 753
736 } // namespace syncer 754 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/device_info/device_info_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698