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

Side by Side Diff: components/sync/driver/model_type_controller_unittest.cc

Issue 2422253002: [Sync] Rewriting ".reset(new" pattern to use "= base::MakeUnique" instead. (Closed)
Patch Set: Fixing compile. Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync/driver/model_type_controller.h" 5 #include "components/sync/driver/model_type_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } // namespace 118 } // namespace
119 119
120 class ModelTypeControllerTest : public testing::Test, public FakeSyncClient { 120 class ModelTypeControllerTest : public testing::Test, public FakeSyncClient {
121 public: 121 public:
122 ModelTypeControllerTest() 122 ModelTypeControllerTest()
123 : model_thread_("modelthread"), sync_prefs_(GetPrefService()) {} 123 : model_thread_("modelthread"), sync_prefs_(GetPrefService()) {}
124 124
125 void SetUp() override { 125 void SetUp() override {
126 model_thread_.Start(); 126 model_thread_.Start();
127 InitializeModelTypeService(); 127 InitializeModelTypeService();
128 controller_.reset(new ModelTypeController( 128 controller_ = base::MakeUnique<ModelTypeController>(
129 kTestModelType, base::Closure(), this, model_thread_.task_runner())); 129 kTestModelType, base::Closure(), this, model_thread_.task_runner());
130 } 130 }
131 131
132 void TearDown() override { 132 void TearDown() override {
133 ClearModelTypeService(); 133 ClearModelTypeService();
134 PumpUIThread(); 134 PumpUIThread();
135 } 135 }
136 136
137 base::WeakPtr<ModelTypeService> GetModelTypeServiceForType( 137 base::WeakPtr<ModelTypeService> GetModelTypeServiceForType(
138 ModelType type) override { 138 ModelType type) override {
139 return service_->AsWeakPtr(); 139 return service_->AsWeakPtr();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 ModelType type, 213 ModelType type,
214 ModelTypeService* service) { 214 ModelTypeService* service) {
215 std::unique_ptr<TestModelTypeProcessor> processor = 215 std::unique_ptr<TestModelTypeProcessor> processor =
216 base::MakeUnique<TestModelTypeProcessor>(&disable_sync_call_count_); 216 base::MakeUnique<TestModelTypeProcessor>(&disable_sync_call_count_);
217 processor_ = processor.get(); 217 processor_ = processor.get();
218 return std::move(processor); 218 return std::move(processor);
219 } 219 }
220 220
221 void InitializeModelTypeService() { 221 void InitializeModelTypeService() {
222 if (model_thread_.task_runner()->BelongsToCurrentThread()) { 222 if (model_thread_.task_runner()->BelongsToCurrentThread()) {
223 service_.reset(new StubModelTypeService(base::Bind( 223 service_ = base::MakeUnique<StubModelTypeService>(base::Bind(
224 &ModelTypeControllerTest::CreateProcessor, base::Unretained(this)))); 224 &ModelTypeControllerTest::CreateProcessor, base::Unretained(this)));
225 } else { 225 } else {
226 model_thread_.task_runner()->PostTask( 226 model_thread_.task_runner()->PostTask(
227 FROM_HERE, 227 FROM_HERE,
228 base::Bind(&ModelTypeControllerTest::InitializeModelTypeService, 228 base::Bind(&ModelTypeControllerTest::InitializeModelTypeService,
229 base::Unretained(this))); 229 base::Unretained(this)));
230 PumpModelThread(); 230 PumpModelThread();
231 } 231 }
232 } 232 }
233 233
234 void ClearModelTypeService() { 234 void ClearModelTypeService() {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 372
373 // Clearing preferences emulates signing out. 373 // Clearing preferences emulates signing out.
374 sync_prefs()->ClearPreferences(); 374 sync_prefs()->ClearPreferences();
375 controller()->Stop(); 375 controller()->Stop();
376 EXPECT_EQ(DataTypeController::NOT_RUNNING, controller()->state()); 376 EXPECT_EQ(DataTypeController::NOT_RUNNING, controller()->state());
377 // Ensure that DisableSync is not called. 377 // Ensure that DisableSync is not called.
378 EXPECT_EQ(0, disable_sync_call_count()); 378 EXPECT_EQ(0, disable_sync_call_count());
379 } 379 }
380 380
381 } // namespace syncer 381 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698