Index: components/sync_driver/generic_change_processor_unittest.cc |
diff --git a/components/sync_driver/generic_change_processor_unittest.cc b/components/sync_driver/generic_change_processor_unittest.cc |
index cb0a4fc93c8662fae2dfd6256bab45be4509c832..8d305001c2edbd28a27456cb83770e826c3734b0 100644 |
--- a/components/sync_driver/generic_change_processor_unittest.cc |
+++ b/components/sync_driver/generic_change_processor_unittest.cc |
@@ -37,8 +37,7 @@ namespace { |
// A mock that keeps track of attachments passed to UploadAttachments. |
class MockAttachmentService : public syncer::AttachmentServiceImpl { |
public: |
- MockAttachmentService( |
- const scoped_refptr<syncer::AttachmentStore>& attachment_store); |
+ MockAttachmentService(scoped_ptr<syncer::AttachmentStore> attachment_store); |
~MockAttachmentService() override; |
void UploadAttachments( |
const syncer::AttachmentIdSet& attachment_ids) override; |
@@ -49,8 +48,8 @@ class MockAttachmentService : public syncer::AttachmentServiceImpl { |
}; |
MockAttachmentService::MockAttachmentService( |
- const scoped_refptr<syncer::AttachmentStore>& attachment_store) |
- : AttachmentServiceImpl(attachment_store, |
+ scoped_ptr<syncer::AttachmentStore> attachment_store) |
+ : AttachmentServiceImpl(attachment_store.Pass(), |
scoped_ptr<syncer::AttachmentUploader>( |
new syncer::FakeAttachmentUploader), |
scoped_ptr<syncer::AttachmentDownloader>( |
@@ -78,9 +77,7 @@ MockAttachmentService::attachment_id_sets() { |
// pass MockAttachmentService to it. |
class MockSyncApiComponentFactory : public SyncApiComponentFactory { |
public: |
- MockSyncApiComponentFactory( |
- scoped_ptr<syncer::AttachmentService> attachment_service) |
- : attachment_service_(attachment_service.Pass()) {} |
+ MockSyncApiComponentFactory() {} |
base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( |
syncer::ModelType type) override { |
@@ -90,17 +87,27 @@ class MockSyncApiComponentFactory : public SyncApiComponentFactory { |
} |
scoped_ptr<syncer::AttachmentService> CreateAttachmentService( |
- const scoped_refptr<syncer::AttachmentStore>& attachment_store, |
+ scoped_ptr<syncer::AttachmentStore> attachment_store, |
const syncer::UserShare& user_share, |
const std::string& store_birthday, |
syncer::ModelType model_type, |
syncer::AttachmentService::Delegate* delegate) override { |
- EXPECT_TRUE(attachment_service_ != NULL); |
- return attachment_service_.Pass(); |
+ scoped_ptr<MockAttachmentService> attachment_service( |
+ new MockAttachmentService(attachment_store.Pass())); |
+ // GenericChangeProcessor takes ownership of the AttachmentService, but we |
+ // need to have a pointer to it so we can see that it was used properly. |
+ // Take a pointer and trust that GenericChangeProcessor does not prematurely |
+ // destroy it. |
+ mock_attachment_service_ = attachment_service.get(); |
+ return attachment_service.Pass(); |
+ } |
+ |
+ MockAttachmentService* GetMockAttachmentService() { |
+ return mock_attachment_service_; |
} |
private: |
- scoped_ptr<syncer::AttachmentService> attachment_service_; |
+ MockAttachmentService* mock_attachment_service_; |
}; |
class SyncGenericChangeProcessorTest : public testing::Test { |
@@ -149,25 +156,15 @@ class SyncGenericChangeProcessorTest : public testing::Test { |
} |
void ConstructGenericChangeProcessor(syncer::ModelType type) { |
- scoped_refptr<syncer::AttachmentStore> attachment_store = |
+ MockSyncApiComponentFactory sync_factory; |
+ scoped_ptr<syncer::AttachmentStore> attachment_store = |
syncer::AttachmentStore::CreateInMemoryStore(); |
- scoped_ptr<MockAttachmentService> mock_attachment_service( |
- new MockAttachmentService(attachment_store)); |
- // GenericChangeProcessor takes ownership of the AttachmentService, but we |
- // need to have a pointer to it so we can see that it was used properly. |
- // Take a pointer and trust that GenericChangeProcessor does not prematurely |
- // destroy it. |
- mock_attachment_service_ = mock_attachment_service.get(); |
- sync_factory_.reset( |
- new MockSyncApiComponentFactory(mock_attachment_service.Pass())); |
- change_processor_.reset( |
- new GenericChangeProcessor(type, |
- &data_type_error_handler_, |
- syncable_service_ptr_factory_.GetWeakPtr(), |
- merge_result_ptr_factory_->GetWeakPtr(), |
- test_user_share_->user_share(), |
- sync_factory_.get(), |
- attachment_store)); |
+ change_processor_.reset(new GenericChangeProcessor( |
+ type, &data_type_error_handler_, |
+ syncable_service_ptr_factory_.GetWeakPtr(), |
+ merge_result_ptr_factory_->GetWeakPtr(), test_user_share_->user_share(), |
+ &sync_factory, attachment_store.Pass())); |
+ mock_attachment_service_ = sync_factory.GetMockAttachmentService(); |
} |
void BuildChildNodes(syncer::ModelType type, int n) { |
@@ -211,7 +208,6 @@ class SyncGenericChangeProcessorTest : public testing::Test { |
DataTypeErrorHandlerMock data_type_error_handler_; |
scoped_ptr<syncer::TestUserShare> test_user_share_; |
MockAttachmentService* mock_attachment_service_; |
- scoped_ptr<SyncApiComponentFactory> sync_factory_; |
scoped_ptr<GenericChangeProcessor> change_processor_; |
}; |