| Index: components/sync/device_info/device_info_sync_bridge_unittest.cc
|
| diff --git a/components/sync/device_info/device_info_sync_bridge_unittest.cc b/components/sync/device_info/device_info_sync_bridge_unittest.cc
|
| index bac124139cd114a9d005e69a2ad892549d9237bf..aa1d2936113262dc5864a8965fecda5670c02678 100644
|
| --- a/components/sync/device_info/device_info_sync_bridge_unittest.cc
|
| +++ b/components/sync/device_info/device_info_sync_bridge_unittest.cc
|
| @@ -193,14 +193,6 @@ class DeviceInfoSyncBridgeTest : public testing::Test,
|
|
|
| void OnDeviceInfoChange() override { change_count_++; }
|
|
|
| - std::unique_ptr<ModelTypeChangeProcessor> CreateModelTypeChangeProcessor(
|
| - ModelType type,
|
| - ModelTypeSyncBridge* bridge) {
|
| - auto processor = base::MakeUnique<RecordingModelTypeChangeProcessor>();
|
| - processor_ = processor.get();
|
| - return std::move(processor);
|
| - }
|
| -
|
| // Initialized the bridge based on the current local device and store. Can
|
| // only be called once per run, as it passes |store_|.
|
| void InitializeBridge() {
|
| @@ -209,8 +201,7 @@ class DeviceInfoSyncBridgeTest : public testing::Test,
|
| provider_.get(),
|
| base::Bind(&ModelTypeStoreTestUtil::MoveStoreToCallback,
|
| base::Passed(&store_)),
|
| - base::Bind(&DeviceInfoSyncBridgeTest::CreateModelTypeChangeProcessor,
|
| - base::Unretained(this)));
|
| + RecordingModelTypeChangeProcessor::FactoryForBridgeTest(&processor_));
|
| bridge_->AddObserver(this);
|
| }
|
|
|
| @@ -244,10 +235,7 @@ class DeviceInfoSyncBridgeTest : public testing::Test,
|
| return bridge_.get();
|
| }
|
|
|
| - RecordingModelTypeChangeProcessor* processor() {
|
| - EXPECT_TRUE(processor_);
|
| - return processor_;
|
| - }
|
| + const RecordingModelTypeChangeProcessor& processor() { return *processor_; }
|
|
|
| const OneShotTimer& pulse_timer() { return bridge()->pulse_timer_; }
|
|
|
| @@ -349,7 +337,7 @@ TEST_F(DeviceInfoSyncBridgeTest, LocalProviderSubscription) {
|
| TEST_F(DeviceInfoSyncBridgeTest, LocalProviderInitRace) {
|
| set_provider(base::MakeUnique<LocalDeviceInfoProviderMock>());
|
| InitializeAndPump();
|
| - EXPECT_FALSE(processor()->metadata());
|
| + EXPECT_FALSE(processor().metadata());
|
|
|
| EXPECT_EQ(0u, bridge()->GetAllDeviceInfo().size());
|
| local_device()->Initialize(CreateModel(1));
|
| @@ -359,7 +347,7 @@ TEST_F(DeviceInfoSyncBridgeTest, LocalProviderInitRace) {
|
| ASSERT_EQ(1u, devices.size());
|
| EXPECT_TRUE(local_device()->GetLocalDeviceInfo()->Equals(*devices[0]));
|
|
|
| - EXPECT_TRUE(processor()->metadata());
|
| + EXPECT_TRUE(processor().metadata());
|
| }
|
|
|
| // Simulate shutting down sync during the ModelTypeStore callbacks. The pulse
|
| @@ -408,7 +396,7 @@ TEST_F(DeviceInfoSyncBridgeTest, TestWithLocalMetadata) {
|
| const DeviceInfoList devices = bridge()->GetAllDeviceInfo();
|
| ASSERT_EQ(1u, devices.size());
|
| EXPECT_TRUE(local_device()->GetLocalDeviceInfo()->Equals(*devices[0]));
|
| - EXPECT_EQ(1u, processor()->put_multimap().size());
|
| + EXPECT_EQ(1u, processor().put_multimap().size());
|
| }
|
|
|
| TEST_F(DeviceInfoSyncBridgeTest, TestWithLocalDataAndMetadata) {
|
| @@ -420,9 +408,9 @@ TEST_F(DeviceInfoSyncBridgeTest, TestWithLocalDataAndMetadata) {
|
| ASSERT_EQ(2u, bridge()->GetAllDeviceInfo().size());
|
| VerifyEqual(specifics,
|
| *bridge()->GetDeviceInfo(specifics.cache_guid()).get());
|
| - EXPECT_TRUE(processor()->metadata());
|
| + EXPECT_TRUE(processor().metadata());
|
| EXPECT_EQ(state.encryption_key_name(),
|
| - processor()->metadata()->GetModelTypeState().encryption_key_name());
|
| + processor().metadata()->GetModelTypeState().encryption_key_name());
|
| }
|
|
|
| TEST_F(DeviceInfoSyncBridgeTest, GetData) {
|
| @@ -514,9 +502,9 @@ TEST_F(DeviceInfoSyncBridgeTest, ApplySyncChangesStore) {
|
| ASSERT_TRUE(info);
|
| VerifyEqual(specifics, *info.get());
|
|
|
| - EXPECT_TRUE(processor()->metadata());
|
| + EXPECT_TRUE(processor().metadata());
|
| EXPECT_EQ(state.encryption_key_name(),
|
| - processor()->metadata()->GetModelTypeState().encryption_key_name());
|
| + processor().metadata()->GetModelTypeState().encryption_key_name());
|
| }
|
|
|
| TEST_F(DeviceInfoSyncBridgeTest, ApplySyncChangesWithLocalGuid) {
|
| @@ -532,7 +520,7 @@ TEST_F(DeviceInfoSyncBridgeTest, ApplySyncChangesWithLocalGuid) {
|
| EXPECT_EQ(1, change_count());
|
| // Ensure |last_updated| is about now, plus or minus a little bit.
|
| const Time last_updated(ProtoTimeToTime(processor()
|
| - ->put_multimap()
|
| + .put_multimap()
|
| .begin()
|
| ->second->specifics.device_info()
|
| .last_updated_timestamp()));
|
| @@ -590,10 +578,10 @@ TEST_F(DeviceInfoSyncBridgeTest, MergeEmpty) {
|
| // TODO(skym): Stop sending local twice. The first of the two puts will
|
| // probably happen before the processor is tracking metadata yet, and so there
|
| // should not be much overhead.
|
| - EXPECT_EQ(2u, processor()->put_multimap().size());
|
| - EXPECT_EQ(2u, processor()->put_multimap().count(
|
| + EXPECT_EQ(2u, processor().put_multimap().size());
|
| + EXPECT_EQ(2u, processor().put_multimap().count(
|
| local_device()->GetLocalDeviceInfo()->guid()));
|
| - EXPECT_EQ(0u, processor()->delete_set().size());
|
| + EXPECT_EQ(0u, processor().delete_set().size());
|
| }
|
|
|
| TEST_F(DeviceInfoSyncBridgeTest, MergeWithData) {
|
| @@ -630,16 +618,16 @@ TEST_F(DeviceInfoSyncBridgeTest, MergeWithData) {
|
| VerifyEqual(conflict_remote, *bridge()->GetDeviceInfo(conflict_guid).get());
|
|
|
| // bridge should have told the processor about the existance of unique_local.
|
| - EXPECT_TRUE(processor()->delete_set().empty());
|
| - EXPECT_EQ(3u, processor()->put_multimap().size());
|
| - EXPECT_EQ(1u, processor()->put_multimap().count(unique_local.cache_guid()));
|
| - const auto& it = processor()->put_multimap().find(unique_local.cache_guid());
|
| - ASSERT_NE(processor()->put_multimap().end(), it);
|
| + EXPECT_TRUE(processor().delete_set().empty());
|
| + EXPECT_EQ(3u, processor().put_multimap().size());
|
| + EXPECT_EQ(1u, processor().put_multimap().count(unique_local.cache_guid()));
|
| + const auto& it = processor().put_multimap().find(unique_local.cache_guid());
|
| + ASSERT_NE(processor().put_multimap().end(), it);
|
| VerifyEqual(unique_local, it->second->specifics.device_info());
|
|
|
| RestartBridge();
|
| EXPECT_EQ(state.encryption_key_name(),
|
| - processor()->metadata()->GetModelTypeState().encryption_key_name());
|
| + processor().metadata()->GetModelTypeState().encryption_key_name());
|
| }
|
|
|
| TEST_F(DeviceInfoSyncBridgeTest, MergeLocalGuid) {
|
| @@ -655,8 +643,8 @@ TEST_F(DeviceInfoSyncBridgeTest, MergeLocalGuid) {
|
| EXPECT_FALSE(error);
|
| EXPECT_EQ(0, change_count());
|
| EXPECT_EQ(1u, bridge()->GetAllDeviceInfo().size());
|
| - EXPECT_TRUE(processor()->delete_set().empty());
|
| - EXPECT_TRUE(processor()->put_multimap().empty());
|
| + EXPECT_TRUE(processor().delete_set().empty());
|
| + EXPECT_TRUE(processor().put_multimap().empty());
|
| }
|
|
|
| TEST_F(DeviceInfoSyncBridgeTest, MergeLocalGuidBeforeReconcile) {
|
| @@ -723,36 +711,36 @@ TEST_F(DeviceInfoSyncBridgeTest, CountActiveDevices) {
|
| TEST_F(DeviceInfoSyncBridgeTest, MultipleOnProviderInitialized) {
|
| set_provider(base::MakeUnique<LocalDeviceInfoProviderMock>());
|
| InitializeAndPump();
|
| - EXPECT_EQ(nullptr, processor()->metadata());
|
| + EXPECT_EQ(nullptr, processor().metadata());
|
|
|
| // Verify the processor was given metadata.
|
| local_device()->Initialize(CreateModel(0));
|
| base::RunLoop().RunUntilIdle();
|
| - const MetadataBatch* metadata = processor()->metadata();
|
| + const MetadataBatch* metadata = processor().metadata();
|
| EXPECT_NE(nullptr, metadata);
|
|
|
| // Pointer address of metadata should remain constant because the processor
|
| // should not have been given new metadata.
|
| local_device()->Initialize(CreateModel(0));
|
| base::RunLoop().RunUntilIdle();
|
| - EXPECT_EQ(metadata, processor()->metadata());
|
| + EXPECT_EQ(metadata, processor().metadata());
|
| }
|
|
|
| TEST_F(DeviceInfoSyncBridgeTest, SendLocalData) {
|
| InitializeAndPump();
|
| EXPECT_EQ(1, change_count());
|
| - EXPECT_EQ(1u, processor()->put_multimap().size());
|
| + EXPECT_EQ(1u, processor().put_multimap().size());
|
|
|
| ForcePulse();
|
| EXPECT_EQ(2, change_count());
|
| - EXPECT_EQ(2u, processor()->put_multimap().size());
|
| + EXPECT_EQ(2u, processor().put_multimap().size());
|
|
|
| // After clearing, pulsing should no-op and not result in a processor put or
|
| // a notification to observers.
|
| local_device()->Clear();
|
| ForcePulse();
|
| EXPECT_EQ(2, change_count());
|
| - EXPECT_EQ(2u, processor()->put_multimap().size());
|
| + EXPECT_EQ(2u, processor().put_multimap().size());
|
| }
|
|
|
| TEST_F(DeviceInfoSyncBridgeTest, DisableSync) {
|
|
|