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/generic_change_processor.h" | 5 #include "components/sync_driver/generic_change_processor.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "components/sync_driver/data_type_error_handler_mock.h" | 12 #include "components/sync_driver/data_type_error_handler_mock.h" |
13 #include "components/sync_driver/sync_api_component_factory.h" | 13 #include "components/sync_driver/sync_api_component_factory.h" |
14 #include "sync/api/attachments/attachment_id.h" | 14 #include "sync/api/attachments/attachment_id.h" |
15 #include "sync/api/attachments/fake_attachment_store.h" | 15 #include "sync/api/attachments/attachment_store.h" |
16 #include "sync/api/fake_syncable_service.h" | 16 #include "sync/api/fake_syncable_service.h" |
17 #include "sync/api/sync_change.h" | 17 #include "sync/api/sync_change.h" |
18 #include "sync/api/sync_merge_result.h" | 18 #include "sync/api/sync_merge_result.h" |
19 #include "sync/internal_api/public/attachments/attachment_service_impl.h" | 19 #include "sync/internal_api/public/attachments/attachment_service_impl.h" |
20 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" | 20 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" |
21 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" | 21 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" |
22 #include "sync/internal_api/public/base/model_type.h" | 22 #include "sync/internal_api/public/base/model_type.h" |
23 #include "sync/internal_api/public/read_node.h" | 23 #include "sync/internal_api/public/read_node.h" |
24 #include "sync/internal_api/public/read_transaction.h" | 24 #include "sync/internal_api/public/read_transaction.h" |
25 #include "sync/internal_api/public/sync_encryption_handler.h" | 25 #include "sync/internal_api/public/sync_encryption_handler.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 for (syncer::ModelTypeSet::Iterator iter = types.First(); iter.Good(); | 140 for (syncer::ModelTypeSet::Iterator iter = types.First(); iter.Good(); |
141 iter.Inc()) { | 141 iter.Inc()) { |
142 syncer::TestUserShare::CreateRoot(iter.Get(), | 142 syncer::TestUserShare::CreateRoot(iter.Get(), |
143 test_user_share_->user_share()); | 143 test_user_share_->user_share()); |
144 } | 144 } |
145 test_user_share_->encryption_handler()->Init(); | 145 test_user_share_->encryption_handler()->Init(); |
146 ConstructGenericChangeProcessor(type); | 146 ConstructGenericChangeProcessor(type); |
147 } | 147 } |
148 | 148 |
149 void ConstructGenericChangeProcessor(syncer::ModelType type) { | 149 void ConstructGenericChangeProcessor(syncer::ModelType type) { |
150 scoped_refptr<syncer::AttachmentStore> attachment_store( | 150 scoped_refptr<syncer::AttachmentStore> attachment_store = |
151 new syncer::FakeAttachmentStore(base::MessageLoopProxy::current())); | 151 syncer::AttachmentStore::CreateInMemoryStore(); |
152 scoped_ptr<MockAttachmentService> mock_attachment_service( | 152 scoped_ptr<MockAttachmentService> mock_attachment_service( |
153 new MockAttachmentService(attachment_store)); | 153 new MockAttachmentService(attachment_store)); |
154 // GenericChangeProcessor takes ownership of the AttachmentService, but we | 154 // GenericChangeProcessor takes ownership of the AttachmentService, but we |
155 // need to have a pointer to it so we can see that it was used properly. | 155 // need to have a pointer to it so we can see that it was used properly. |
156 // Take a pointer and trust that GenericChangeProcessor does not prematurely | 156 // Take a pointer and trust that GenericChangeProcessor does not prematurely |
157 // destroy it. | 157 // destroy it. |
158 mock_attachment_service_ = mock_attachment_service.get(); | 158 mock_attachment_service_ = mock_attachment_service.get(); |
159 sync_factory_.reset(new MockSyncApiComponentFactory( | 159 sync_factory_.reset(new MockSyncApiComponentFactory( |
160 mock_attachment_service.PassAs<syncer::AttachmentService>())); | 160 mock_attachment_service.PassAs<syncer::AttachmentService>())); |
161 change_processor_.reset( | 161 change_processor_.reset( |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 // AttachmentService to upload id1 only. | 476 // AttachmentService to upload id1 only. |
477 ConstructGenericChangeProcessor(kType); | 477 ConstructGenericChangeProcessor(kType); |
478 ASSERT_EQ(1U, mock_attachment_service()->attachment_id_sets()->size()); | 478 ASSERT_EQ(1U, mock_attachment_service()->attachment_id_sets()->size()); |
479 ASSERT_THAT(mock_attachment_service()->attachment_id_sets()->front(), | 479 ASSERT_THAT(mock_attachment_service()->attachment_id_sets()->front(), |
480 testing::UnorderedElementsAre(id1)); | 480 testing::UnorderedElementsAre(id1)); |
481 } | 481 } |
482 | 482 |
483 } // namespace | 483 } // namespace |
484 | 484 |
485 } // namespace sync_driver | 485 } // namespace sync_driver |
OLD | NEW |