Index: components/sync_driver/device_info_service_unittest.cc |
diff --git a/components/sync_driver/device_info_service_unittest.cc b/components/sync_driver/device_info_service_unittest.cc |
index 4cd69c6e6db3d95cbd604986e490496148032718..3561ff8c3ea4ffe4d5220f98cfd0fddf763bfa61 100644 |
--- a/components/sync_driver/device_info_service_unittest.cc |
+++ b/components/sync_driver/device_info_service_unittest.cc |
@@ -19,6 +19,7 @@ |
#include "sync/api/entity_data.h" |
#include "sync/api/metadata_batch.h" |
#include "sync/api/model_type_store.h" |
+#include "sync/internal_api/public/shared_model_type_processor.h" |
#include "sync/internal_api/public/test/model_type_store_test_util.h" |
#include "sync/protocol/data_type_state.pb.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -115,10 +116,13 @@ EntityDataPtr SpecificsToEntity(const DeviceInfoSpecifics& specifics) { |
// in members that can then be accessed. TODO(skym): If this ends up being |
// useful for other model type unittests it should be moved out to a shared |
// location. |
-class FakeModelTypeChangeProcessor : public ModelTypeChangeProcessor { |
+class FakeSharedModelTypeProcessor |
+ : public syncer_v2::SharedModelTypeProcessor { |
public: |
- FakeModelTypeChangeProcessor() {} |
- ~FakeModelTypeChangeProcessor() override {} |
+ FakeSharedModelTypeProcessor(syncer::ModelType type, |
+ ModelTypeService* service) |
+ : SharedModelTypeProcessor(type, service) {} |
+ ~FakeSharedModelTypeProcessor() override {} |
void Put(const std::string& client_tag, |
scoped_ptr<EntityData> entity_data, |
@@ -149,6 +153,21 @@ class FakeModelTypeChangeProcessor : public ModelTypeChangeProcessor { |
} // namespace |
+class FakeDeviceInfoService : public DeviceInfoService { |
+ public: |
+ FakeDeviceInfoService( |
+ sync_driver::LocalDeviceInfoProvider* local_device_info_provider, |
+ const StoreFactoryFunction& callback, |
+ const SharedProcessorFactory& shared_processor_factory) |
+ : DeviceInfoService(local_device_info_provider, |
+ callback, |
+ shared_processor_factory) {} |
+ ~FakeDeviceInfoService() override{}; |
+ ModelTypeChangeProcessor* CreateProcessorForTest() { |
+ return create_change_processor(); |
+ } |
+}; |
+ |
class DeviceInfoServiceTest : public testing::Test, |
public DeviceInfoTracker::Observer { |
protected: |
@@ -163,7 +182,13 @@ class DeviceInfoServiceTest : public testing::Test, |
void OnDeviceInfoChange() override { change_count_++; } |
- protected: |
+ scoped_ptr<ModelTypeChangeProcessor> CreateSharedModelTypeProcessor( |
+ syncer::ModelType type, |
+ ModelTypeService* service) { |
+ processor_ = new FakeSharedModelTypeProcessor(syncer::DEVICE_INFO, service); |
+ return make_scoped_ptr(processor_); |
+ } |
+ |
DeviceInfoServiceTest() |
: change_count_(0), |
store_(ModelTypeStoreTestUtil::CreateInMemoryStoreForTest()), |
@@ -179,10 +204,12 @@ class DeviceInfoServiceTest : public testing::Test, |
// only be called once per run, as it passes |store_|. |
void InitializeService() { |
ASSERT_TRUE(store_); |
- service_.reset(new DeviceInfoService( |
+ service_.reset(new FakeDeviceInfoService( |
local_device_.get(), |
base::Bind(&ModelTypeStoreTestUtil::MoveStoreToCallback, |
- base::Passed(&store_)))); |
+ base::Passed(&store_)), |
+ base::Bind(&DeviceInfoServiceTest::CreateSharedModelTypeProcessor, |
+ base::Unretained(this)))); |
service_->AddObserver(this); |
} |
@@ -197,8 +224,8 @@ class DeviceInfoServiceTest : public testing::Test, |
// pump in this scenario because metadata is going to need to be loading from |
// the store and given to the processor, which is async. |
void SetProcessorAndPump() { |
- processor_ = new FakeModelTypeChangeProcessor(); |
- service()->set_change_processor(make_scoped_ptr(processor_)); |
+ EXPECT_EQ(processor_, service_->CreateProcessorForTest()); |
+ ASSERT_TRUE(processor_); |
base::RunLoop().RunUntilIdle(); |
} |
@@ -263,7 +290,7 @@ class DeviceInfoServiceTest : public testing::Test, |
return service_.get(); |
} |
- FakeModelTypeChangeProcessor* processor() { |
+ FakeSharedModelTypeProcessor* processor() { |
EXPECT_TRUE(processor_); |
return processor_; |
} |
@@ -294,11 +321,11 @@ class DeviceInfoServiceTest : public testing::Test, |
// Not initialized immediately (upon test's constructor). This allows each |
// test case to modify the dependencies the service will be constructed with. |
- scoped_ptr<DeviceInfoService> service_; |
+ scoped_ptr<FakeDeviceInfoService> service_; |
// A non-owning pointer to the processor given to the service. Will be nullptr |
// before being given to the service, to make ownership easier. |
- FakeModelTypeChangeProcessor* processor_ = nullptr; |
+ FakeSharedModelTypeProcessor* processor_ = nullptr; |
// A monotonically increasing label for generated specifics objects with data |
// that is slightly different from eachother. |