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

Unified Diff: components/sync_driver/non_ui_model_type_controller_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: update base on Max and Sky's comment Created 4 years, 9 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/non_ui_model_type_controller_unittest.cc
diff --git a/components/sync_driver/non_ui_model_type_controller_unittest.cc b/components/sync_driver/non_ui_model_type_controller_unittest.cc
index a309c36a04f34b4ad6f19ab6b1e1b3928be3c6d8..629b719debcfad665518d0076cba3ea3b0c1c318 100644
--- a/components/sync_driver/non_ui_model_type_controller_unittest.cc
+++ b/components/sync_driver/non_ui_model_type_controller_unittest.cc
@@ -54,8 +54,6 @@ class TestNonUIModelTypeController : public NonUIModelTypeController {
return model_task_runner_->PostTask(from_here, task);
}
- void InitializeProcessorInTest() { InitializeProcessor(); }
-
private:
~TestNonUIModelTypeController() override {}
@@ -147,6 +145,30 @@ class MockBackendDataTypeConfigurer
} // namespace
+class FakeNonUIModelTypeService : public syncer_v2::FakeModelTypeService {
skym 2016/03/24 16:08:52 This is a lot of boilerplate copy/pasted from ui_m
Gang Wu 2016/03/24 22:18:11 move duplicate code into FakeModelTypeService
+ public:
+ FakeNonUIModelTypeService() : test_processor_(nullptr){};
+ ~FakeNonUIModelTypeService() override {}
+
+ base::WeakPtr<syncer_v2::SharedModelTypeProcessor> SetUpProcessor(
+ syncer_v2::ModelTypeChangeProcessor* processor) {
+ test_processor_ = processor;
+ return static_cast<syncer_v2::SharedModelTypeProcessor*>(
+ GetOrCreateChangeProcessor())
+ ->AsWeakPtrForUI();
+ }
+
+ protected:
+ syncer_v2::ModelTypeChangeProcessor* CreateProcessorForTest(
+ syncer::ModelType type,
+ ModelTypeService* service) override {
+ return test_processor_;
+ }
+
+ private:
+ syncer_v2::ModelTypeChangeProcessor* test_processor_;
+};
+
class NonUIModelTypeControllerTest : public testing::Test,
public sync_driver::FakeSyncClient {
public:
@@ -167,7 +189,6 @@ class NonUIModelTypeControllerTest : public testing::Test,
controller_ = new TestNonUIModelTypeController(
ui_loop_.task_runner(), model_thread_runner_, base::Closure(),
syncer::DICTIONARY, this);
- controller_->InitializeProcessorInTest();
InitializeTypeProcessor();
}
@@ -186,7 +207,9 @@ class NonUIModelTypeControllerTest : public testing::Test,
void InitializeTypeProcessor() {
if (!model_thread_runner_ ||
model_thread_runner_->BelongsToCurrentThread()) {
- type_processor_ = controller_->get_type_processor();
+ type_processor_ =
+ service_->SetUpProcessor(new syncer_v2::SharedModelTypeProcessor(
+ syncer::DICTIONARY, service_.get()));
} else {
model_thread_runner_->PostTask(
FROM_HERE,
@@ -199,7 +222,7 @@ class NonUIModelTypeControllerTest : public testing::Test,
void InitializeModelTypeService() {
if (!model_thread_runner_ ||
model_thread_runner_->BelongsToCurrentThread()) {
- service_.reset(new syncer_v2::FakeModelTypeService());
+ service_.reset(new FakeNonUIModelTypeService());
} else {
model_thread_runner_->PostTask(
FROM_HERE,
@@ -349,7 +372,7 @@ class NonUIModelTypeControllerTest : public testing::Test,
scoped_refptr<base::TestSimpleTaskRunner> sync_thread_runner_;
MockSyncBackend backend_;
MockBackendDataTypeConfigurer configurer_;
- scoped_ptr<syncer_v2::FakeModelTypeService> service_;
+ scoped_ptr<FakeNonUIModelTypeService> service_;
};
TEST_F(NonUIModelTypeControllerTest, InitialState) {

Powered by Google App Engine
This is Rietveld 408576698