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

Unified Diff: components/sync_driver/device_info_service_unittest.cc

Issue 1763953002: [USS] Change the place where SharedModelTypeProcessor got created (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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 side-by-side diff with in-line comments
Download patch
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 ccaa6929e6bec267881efdf69079a0d42e8a4b52..21ca76ff7bf0742cde5da6c100c20c3946a1aa99 100644
--- a/components/sync_driver/device_info_service_unittest.cc
+++ b/components/sync_driver/device_info_service_unittest.cc
@@ -18,6 +18,7 @@
#include "sync/api/data_batch.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"
@@ -101,10 +102,13 @@ void AssertExpectedFromDataBatch(
// 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,
@@ -135,6 +139,28 @@ class FakeModelTypeChangeProcessor : public ModelTypeChangeProcessor {
} // namespace
+class FakeDeviceInfoService : public DeviceInfoService {
+ public:
+ FakeDeviceInfoService(
+ sync_driver::LocalDeviceInfoProvider* local_device_info_provider,
+ const StoreFactoryFunction& callback)
+ : DeviceInfoService(local_device_info_provider, callback){};
+ ~FakeDeviceInfoService() override{};
+
+ void set_processor(FakeSharedModelTypeProcessor* processor) {
+ processor_ = processor;
+ }
+
+ protected:
+ scoped_ptr<syncer_v2::SharedModelTypeProcessor>
+ CreateSharedModelTypeProcessor(syncer::ModelType type) override {
+ return make_scoped_ptr(processor_);
+ }
+
+ private:
+ FakeSharedModelTypeProcessor* processor_ = nullptr;
+};
+
class DeviceInfoServiceTest : public testing::Test,
public DeviceInfoTracker::Observer {
protected:
@@ -165,7 +191,7 @@ 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_))));
@@ -183,8 +209,10 @@ 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() {
skym 2016/03/04 22:12:28 I don't think we need this method anymore. Origina
Gang Wu 2016/03/08 20:35:24 Will update where to trigger initial processor in
- processor_ = new FakeModelTypeChangeProcessor();
- service()->set_change_processor(make_scoped_ptr(processor_));
+ processor_ =
+ new FakeSharedModelTypeProcessor(syncer::DEVICE_INFO, service());
+ service()->set_processor(processor_);
+ service()->InitializeProcessor(syncer::DEVICE_INFO);
base::RunLoop().RunUntilIdle();
}
@@ -243,12 +271,12 @@ class DeviceInfoServiceTest : public testing::Test,
LocalDeviceInfoProviderMock* local_device() { return local_device_.get(); }
// Allows access to the service after InitializeService() is called.
- DeviceInfoService* service() {
+ FakeDeviceInfoService* service() {
EXPECT_TRUE(service_);
return service_.get();
}
- FakeModelTypeChangeProcessor* processor() {
+ FakeSharedModelTypeProcessor* processor() {
EXPECT_TRUE(processor_);
return processor_;
}
@@ -279,11 +307,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.

Powered by Google App Engine
This is Rietveld 408576698