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 #ifndef SYNC_INTERNAL_API_ATTACHMENTS_ATTACHMENT_STORE_TEST_TEMPLATE_H_ | 5 #ifndef SYNC_INTERNAL_API_ATTACHMENTS_ATTACHMENT_STORE_TEST_TEMPLATE_H_ |
6 #define SYNC_INTERNAL_API_ATTACHMENTS_ATTACHMENT_STORE_TEST_TEMPLATE_H_ | 6 #define SYNC_INTERNAL_API_ATTACHMENTS_ATTACHMENT_STORE_TEST_TEMPLATE_H_ |
7 | 7 |
8 #include "sync/api/attachments/attachment_store.h" | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
16 #include "sync/api/attachments/attachment.h" | 16 #include "sync/api/attachments/attachment.h" |
| 17 #include "sync/api/attachments/attachment_store.h" |
17 #include "sync/internal_api/public/attachments/attachment_util.h" | 18 #include "sync/internal_api/public/attachments/attachment_util.h" |
18 #include "sync/protocol/sync.pb.h" | 19 #include "sync/protocol/sync.pb.h" |
19 #include "testing/gmock/include/gmock/gmock-matchers.h" | 20 #include "testing/gmock/include/gmock/gmock-matchers.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 // AttachmentStoreTest defines tests for AttachmentStore. To instantiate these | 23 // AttachmentStoreTest defines tests for AttachmentStore. To instantiate these |
23 // tests for a particular implementation you need to: | 24 // tests for a particular implementation you need to: |
24 // - Include this file in test. | 25 // - Include this file in test. |
25 // - Create factory class for attachment store that implements factory method. | 26 // - Create factory class for attachment store that implements factory method. |
26 // - add INSTANTIATE_TYPED_TEST_CASE_P statement. | 27 // - add INSTANTIATE_TYPED_TEST_CASE_P statement. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 108 } |
108 | 109 |
109 void CopyResultAttachments( | 110 void CopyResultAttachments( |
110 AttachmentStore::Result* destination_result, | 111 AttachmentStore::Result* destination_result, |
111 scoped_ptr<AttachmentMap>* destination_attachments, | 112 scoped_ptr<AttachmentMap>* destination_attachments, |
112 scoped_ptr<AttachmentIdList>* destination_failed_attachment_ids, | 113 scoped_ptr<AttachmentIdList>* destination_failed_attachment_ids, |
113 const AttachmentStore::Result& source_result, | 114 const AttachmentStore::Result& source_result, |
114 scoped_ptr<AttachmentMap> source_attachments, | 115 scoped_ptr<AttachmentMap> source_attachments, |
115 scoped_ptr<AttachmentIdList> source_failed_attachment_ids) { | 116 scoped_ptr<AttachmentIdList> source_failed_attachment_ids) { |
116 CopyResult(destination_result, source_result); | 117 CopyResult(destination_result, source_result); |
117 *destination_attachments = source_attachments.Pass(); | 118 *destination_attachments = std::move(source_attachments); |
118 *destination_failed_attachment_ids = source_failed_attachment_ids.Pass(); | 119 *destination_failed_attachment_ids = |
| 120 std::move(source_failed_attachment_ids); |
119 } | 121 } |
120 | 122 |
121 void CopyResultMetadata( | 123 void CopyResultMetadata( |
122 AttachmentStore::Result* destination_result, | 124 AttachmentStore::Result* destination_result, |
123 scoped_ptr<AttachmentMetadataList>* destination_metadata, | 125 scoped_ptr<AttachmentMetadataList>* destination_metadata, |
124 const AttachmentStore::Result& source_result, | 126 const AttachmentStore::Result& source_result, |
125 scoped_ptr<AttachmentMetadataList> source_metadata) { | 127 scoped_ptr<AttachmentMetadataList> source_metadata) { |
126 CopyResult(destination_result, source_result); | 128 CopyResult(destination_result, source_result); |
127 *destination_metadata = source_metadata.Pass(); | 129 *destination_metadata = std::move(source_metadata); |
128 } | 130 } |
129 }; | 131 }; |
130 | 132 |
131 TYPED_TEST_CASE_P(AttachmentStoreTest); | 133 TYPED_TEST_CASE_P(AttachmentStoreTest); |
132 | 134 |
133 // Verify that CreateAttachmentStoreForSync() creates valid object. | 135 // Verify that CreateAttachmentStoreForSync() creates valid object. |
134 TYPED_TEST_P(AttachmentStoreTest, CreateAttachmentStoreForSync) { | 136 TYPED_TEST_P(AttachmentStoreTest, CreateAttachmentStoreForSync) { |
135 scoped_ptr<AttachmentStoreForSync> attachment_store_for_sync = | 137 scoped_ptr<AttachmentStoreForSync> attachment_store_for_sync = |
136 this->store->CreateAttachmentStoreForSync(); | 138 this->store->CreateAttachmentStoreForSync(); |
137 EXPECT_NE(nullptr, attachment_store_for_sync); | 139 EXPECT_NE(nullptr, attachment_store_for_sync); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 Read_OneNotFound, | 515 Read_OneNotFound, |
514 Drop_DropTwoButOnlyOneExists, | 516 Drop_DropTwoButOnlyOneExists, |
515 Drop_DoesNotExist, | 517 Drop_DoesNotExist, |
516 ReadMetadataById, | 518 ReadMetadataById, |
517 ReadMetadata, | 519 ReadMetadata, |
518 SetSyncReference_DropSyncReference); | 520 SetSyncReference_DropSyncReference); |
519 | 521 |
520 } // namespace syncer | 522 } // namespace syncer |
521 | 523 |
522 #endif // SYNC_INTERNAL_API_ATTACHMENTS_ATTACHMENT_STORE_TEST_TEMPLATE_H_ | 524 #endif // SYNC_INTERNAL_API_ATTACHMENTS_ATTACHMENT_STORE_TEST_TEMPLATE_H_ |
OLD | NEW |