OLD | NEW |
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/shared_change_processor.h" | 5 #include "components/sync/driver/shared_change_processor.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 : FakeSyncClient(&factory_), | 84 : FakeSyncClient(&factory_), |
85 model_thread_("dbthread"), | 85 model_thread_("dbthread"), |
86 did_connect_(false), | 86 did_connect_(false), |
87 has_attachment_service_(false) {} | 87 has_attachment_service_(false) {} |
88 | 88 |
89 ~SyncSharedChangeProcessorTest() override { | 89 ~SyncSharedChangeProcessorTest() override { |
90 EXPECT_FALSE(db_syncable_service_.get()); | 90 EXPECT_FALSE(db_syncable_service_.get()); |
91 } | 91 } |
92 | 92 |
93 // FakeSyncClient override. | 93 // FakeSyncClient override. |
94 base::WeakPtr<SyncableService> GetSyncableServiceForType( | 94 ServiceProvider GetSyncableServiceForType(ModelType type) override { |
95 ModelType type) override { | 95 return base::Bind(&SyncableService::AsWeakPtr, |
96 return db_syncable_service_->AsWeakPtr(); | 96 base::Unretained(db_syncable_service_.get())); |
97 } | 97 } |
98 | 98 |
99 protected: | 99 protected: |
100 void SetUp() override { | 100 void SetUp() override { |
101 test_user_share_.SetUp(); | 101 test_user_share_.SetUp(); |
102 shared_change_processor_ = new SharedChangeProcessor(AUTOFILL); | 102 shared_change_processor_ = new SharedChangeProcessor(AUTOFILL); |
103 ASSERT_TRUE(model_thread_.Start()); | 103 ASSERT_TRUE(model_thread_.Start()); |
104 ASSERT_TRUE(model_thread_.task_runner()->PostTask( | 104 ASSERT_TRUE(model_thread_.task_runner()->PostTask( |
105 FROM_HERE, | 105 FROM_HERE, |
106 base::Bind(&SyncSharedChangeProcessorTest::SetUpDBSyncableService, | 106 base::Bind(&SyncSharedChangeProcessorTest::SetUpDBSyncableService, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 AttachmentStore::CreateInMemoryStore()); | 178 AttachmentStore::CreateInMemoryStore()); |
179 } | 179 } |
180 | 180 |
181 // Used by Connect(). The SharedChangeProcessor is passed in | 181 // Used by Connect(). The SharedChangeProcessor is passed in |
182 // because we modify |shared_change_processor_| on the main thread | 182 // because we modify |shared_change_processor_| on the main thread |
183 // (in TearDown()). | 183 // (in TearDown()). |
184 void ConnectOnDBThread( | 184 void ConnectOnDBThread( |
185 const scoped_refptr<SharedChangeProcessor>& shared_change_processor) { | 185 const scoped_refptr<SharedChangeProcessor>& shared_change_processor) { |
186 DCHECK(model_thread_.task_runner()->BelongsToCurrentThread()); | 186 DCHECK(model_thread_.task_runner()->BelongsToCurrentThread()); |
187 EXPECT_TRUE(shared_change_processor->Connect( | 187 EXPECT_TRUE(shared_change_processor->Connect( |
188 this, &processor_factory_, test_user_share_.user_share(), | 188 GetSyncableServiceForType(AUTOFILL), &factory_, &processor_factory_, |
| 189 test_user_share_.user_share(), |
189 base::MakeUnique<DataTypeErrorHandlerMock>(), | 190 base::MakeUnique<DataTypeErrorHandlerMock>(), |
190 base::WeakPtr<SyncMergeResult>())); | 191 base::WeakPtr<SyncMergeResult>())); |
191 did_connect_ = true; | 192 did_connect_ = true; |
192 } | 193 } |
193 | 194 |
194 void CheckAttachmentServiceOnDBThread(base::WaitableEvent* event) { | 195 void CheckAttachmentServiceOnDBThread(base::WaitableEvent* event) { |
195 DCHECK(model_thread_.task_runner()->BelongsToCurrentThread()); | 196 DCHECK(model_thread_.task_runner()->BelongsToCurrentThread()); |
196 DCHECK(db_syncable_service_.get()); | 197 DCHECK(db_syncable_service_.get()); |
197 has_attachment_service_ = !!db_syncable_service_->attachment_service(); | 198 has_attachment_service_ = !!db_syncable_service_->attachment_service(); |
198 event->Signal(); | 199 event->Signal(); |
(...skipping 25 matching lines...) Expand all Loading... |
224 // creates AttachmentService and passes it back to the syncable service. | 225 // creates AttachmentService and passes it back to the syncable service. |
225 TEST_F(SyncSharedChangeProcessorTest, ConnectWithAttachmentStore) { | 226 TEST_F(SyncSharedChangeProcessorTest, ConnectWithAttachmentStore) { |
226 SetAttachmentStore(); | 227 SetAttachmentStore(); |
227 Connect(); | 228 Connect(); |
228 EXPECT_TRUE(HasAttachmentService()); | 229 EXPECT_TRUE(HasAttachmentService()); |
229 } | 230 } |
230 | 231 |
231 } // namespace | 232 } // namespace |
232 | 233 |
233 } // namespace syncer | 234 } // namespace syncer |
OLD | NEW |