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

Unified Diff: components/sync_driver/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/ui_model_type_controller_unittest.cc
diff --git a/components/sync_driver/ui_model_type_controller_unittest.cc b/components/sync_driver/ui_model_type_controller_unittest.cc
index 5a9878ba6c5d7acb7e569fc02baa3caf6b4f6b6a..e0c9508511cc2345a3d9cbb363df7a42038a8939 100644
--- a/components/sync_driver/ui_model_type_controller_unittest.cc
+++ b/components/sync_driver/ui_model_type_controller_unittest.cc
@@ -39,8 +39,6 @@ class TestUIModelTypeController : public UIModelTypeController {
model_type,
sync_client) {}
- void InitializeProcessorInTest() { InitializeProcessor(); }
-
private:
~TestUIModelTypeController() override {}
};
@@ -130,6 +128,30 @@ class MockBackendDataTypeConfigurer
} // namespace
+class FakeUIModelTypeService : public syncer_v2::FakeModelTypeService {
skym 2016/03/24 16:08:52 You wouldn't need this class if you used an overlo
Gang Wu 2016/03/24 22:18:11 This test uses direct access to processor for load
+ public:
+ FakeUIModelTypeService() : test_processor_(nullptr){};
+ ~FakeUIModelTypeService() 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 UIModelTypeControllerTest : public testing::Test,
public sync_driver::FakeSyncClient {
public:
@@ -145,10 +167,9 @@ class UIModelTypeControllerTest : public testing::Test,
void SetUp() override {
controller_ = new TestUIModelTypeController(
ui_loop_.task_runner(), base::Closure(), syncer::DEVICE_INFO, this);
- controller_->InitializeProcessorInTest();
type_processor_ =
- ((syncer_v2::SharedModelTypeProcessor*)service_.change_processor())
- ->AsWeakPtrForUI();
+ service_.SetUpProcessor(new syncer_v2::SharedModelTypeProcessor(
+ syncer::DEVICE_INFO, &service_));
}
void TearDown() override {
@@ -248,7 +269,7 @@ class UIModelTypeControllerTest : public testing::Test,
scoped_refptr<base::TestSimpleTaskRunner> sync_thread_runner_;
MockSyncBackend backend_;
MockBackendDataTypeConfigurer configurer_;
- syncer_v2::FakeModelTypeService service_;
+ FakeUIModelTypeService service_;
};
TEST_F(UIModelTypeControllerTest, InitialState) {

Powered by Google App Engine
This is Rietveld 408576698