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 ServiceProvider GetSyncableServiceForType(ModelType type) override { | 94 base::WeakPtr<SyncableService> GetSyncableServiceForType( |
95 return base::Bind(&SyncableService::AsWeakPtr, | 95 ModelType type) override { |
96 base::Unretained(db_syncable_service_.get())); | 96 return db_syncable_service_->AsWeakPtr(); |
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 GetSyncableServiceForType(AUTOFILL), &factory_, &processor_factory_, | 188 this, &processor_factory_, test_user_share_.user_share(), |
189 test_user_share_.user_share(), | |
190 base::MakeUnique<DataTypeErrorHandlerMock>(), | 189 base::MakeUnique<DataTypeErrorHandlerMock>(), |
191 base::WeakPtr<SyncMergeResult>())); | 190 base::WeakPtr<SyncMergeResult>())); |
192 did_connect_ = true; | 191 did_connect_ = true; |
193 } | 192 } |
194 | 193 |
195 void CheckAttachmentServiceOnDBThread(base::WaitableEvent* event) { | 194 void CheckAttachmentServiceOnDBThread(base::WaitableEvent* event) { |
196 DCHECK(model_thread_.task_runner()->BelongsToCurrentThread()); | 195 DCHECK(model_thread_.task_runner()->BelongsToCurrentThread()); |
197 DCHECK(db_syncable_service_.get()); | 196 DCHECK(db_syncable_service_.get()); |
198 has_attachment_service_ = !!db_syncable_service_->attachment_service(); | 197 has_attachment_service_ = !!db_syncable_service_->attachment_service(); |
199 event->Signal(); | 198 event->Signal(); |
(...skipping 25 matching lines...) Expand all Loading... |
225 // creates AttachmentService and passes it back to the syncable service. | 224 // creates AttachmentService and passes it back to the syncable service. |
226 TEST_F(SyncSharedChangeProcessorTest, ConnectWithAttachmentStore) { | 225 TEST_F(SyncSharedChangeProcessorTest, ConnectWithAttachmentStore) { |
227 SetAttachmentStore(); | 226 SetAttachmentStore(); |
228 Connect(); | 227 Connect(); |
229 EXPECT_TRUE(HasAttachmentService()); | 228 EXPECT_TRUE(HasAttachmentService()); |
230 } | 229 } |
231 | 230 |
232 } // namespace | 231 } // namespace |
233 | 232 |
234 } // namespace syncer | 233 } // namespace syncer |
OLD | NEW |