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

Side by Side Diff: components/sync/driver/generic_change_processor_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/generic_change_processor.h" 5 #include "components/sync/driver/generic_change_processor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/memory/ptr_util.h"
11 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 13 #include "base/run_loop.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "components/sync/base/model_type.h" 15 #include "components/sync/base/model_type.h"
15 #include "components/sync/device_info/local_device_info_provider.h" 16 #include "components/sync/device_info/local_device_info_provider.h"
16 #include "components/sync/driver/fake_sync_client.h" 17 #include "components/sync/driver/fake_sync_client.h"
17 #include "components/sync/driver/sync_api_component_factory.h" 18 #include "components/sync/driver/sync_api_component_factory.h"
18 #include "components/sync/engine/attachments/fake_attachment_downloader.h" 19 #include "components/sync/engine/attachments/fake_attachment_downloader.h"
19 #include "components/sync/engine/attachments/fake_attachment_uploader.h" 20 #include "components/sync/engine/attachments/fake_attachment_uploader.h"
20 #include "components/sync/engine/sync_encryption_handler.h" 21 #include "components/sync/engine/sync_encryption_handler.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 mock_attachment_service_ = NULL; 139 mock_attachment_service_ = NULL;
139 if (test_user_share_) { 140 if (test_user_share_) {
140 test_user_share_->TearDown(); 141 test_user_share_->TearDown();
141 } 142 }
142 } 143 }
143 144
144 // Initialize GenericChangeProcessor and related classes for testing with 145 // Initialize GenericChangeProcessor and related classes for testing with
145 // model type |type|. 146 // model type |type|.
146 void InitializeForType(ModelType type) { 147 void InitializeForType(ModelType type) {
147 TearDown(); 148 TearDown();
148 test_user_share_.reset(new TestUserShare); 149 test_user_share_ = base::MakeUnique<TestUserShare>();
149 test_user_share_->SetUp(); 150 test_user_share_->SetUp();
150 sync_merge_result_.reset(new SyncMergeResult(type)); 151 sync_merge_result_ = base::MakeUnique<SyncMergeResult>(type);
151 merge_result_ptr_factory_.reset( 152 merge_result_ptr_factory_ =
152 new base::WeakPtrFactory<SyncMergeResult>(sync_merge_result_.get())); 153 base::MakeUnique<base::WeakPtrFactory<SyncMergeResult>>(
154 sync_merge_result_.get());
153 155
154 ModelTypeSet types = ProtocolTypes(); 156 ModelTypeSet types = ProtocolTypes();
155 for (ModelTypeSet::Iterator iter = types.First(); iter.Good(); iter.Inc()) { 157 for (ModelTypeSet::Iterator iter = types.First(); iter.Good(); iter.Inc()) {
156 TestUserShare::CreateRoot(iter.Get(), test_user_share_->user_share()); 158 TestUserShare::CreateRoot(iter.Get(), test_user_share_->user_share());
157 } 159 }
158 test_user_share_->encryption_handler()->Init(); 160 test_user_share_->encryption_handler()->Init();
159 ConstructGenericChangeProcessor(type); 161 ConstructGenericChangeProcessor(type);
160 } 162 }
161 163
162 void ConstructGenericChangeProcessor(ModelType type) { 164 void ConstructGenericChangeProcessor(ModelType type) {
163 std::unique_ptr<AttachmentStore> attachment_store = 165 std::unique_ptr<AttachmentStore> attachment_store =
164 AttachmentStore::CreateInMemoryStore(); 166 AttachmentStore::CreateInMemoryStore();
165 change_processor_.reset(new GenericChangeProcessor( 167 change_processor_ = base::MakeUnique<GenericChangeProcessor>(
166 type, base::MakeUnique<DataTypeErrorHandlerMock>(), 168 type, base::MakeUnique<DataTypeErrorHandlerMock>(),
167 syncable_service_ptr_factory_.GetWeakPtr(), 169 syncable_service_ptr_factory_.GetWeakPtr(),
168 merge_result_ptr_factory_->GetWeakPtr(), test_user_share_->user_share(), 170 merge_result_ptr_factory_->GetWeakPtr(), test_user_share_->user_share(),
169 &sync_client_, attachment_store->CreateAttachmentStoreForSync())); 171 &sync_client_, attachment_store->CreateAttachmentStoreForSync());
170 mock_attachment_service_ = sync_factory_.GetMockAttachmentService(); 172 mock_attachment_service_ = sync_factory_.GetMockAttachmentService();
171 } 173 }
172 174
173 void BuildChildNodes(ModelType type, int n) { 175 void BuildChildNodes(ModelType type, int n) {
174 WriteTransaction trans(FROM_HERE, user_share()); 176 WriteTransaction trans(FROM_HERE, user_share());
175 for (int i = 0; i < n; ++i) { 177 for (int i = 0; i < n; ++i) {
176 WriteNode node(&trans); 178 WriteNode node(&trans);
177 node.InitUniqueByCreation(type, base::StringPrintf("node%05d", i)); 179 node.InitUniqueByCreation(type, base::StringPrintf("node%05d", i));
178 } 180 }
179 } 181 }
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 SyncDataList sync_data = change_processor()->GetAllSyncData(SESSIONS); 502 SyncDataList sync_data = change_processor()->GetAllSyncData(SESSIONS);
501 ASSERT_EQ(sync_data.size(), 1U); 503 ASSERT_EQ(sync_data.size(), 1U);
502 ASSERT_EQ("session tag 2", 504 ASSERT_EQ("session tag 2",
503 sync_data[0].GetSpecifics().session().session_tag()); 505 sync_data[0].GetSpecifics().session().session_tag());
504 EXPECT_FALSE(SyncDataRemote(sync_data[0]).GetClientTagHash().empty()); 506 EXPECT_FALSE(SyncDataRemote(sync_data[0]).GetClientTagHash().empty());
505 } 507 }
506 508
507 } // namespace 509 } // namespace
508 510
509 } // namespace syncer 511 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/generic_change_processor.cc ('k') | components/sync/driver/glue/sync_backend_host_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698