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 "sync/api/attachments/attachment_store.h" |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 scoped_ptr<AttachmentMetadataList>* destination_metadata, | 121 scoped_ptr<AttachmentMetadataList>* destination_metadata, |
122 const AttachmentStore::Result& source_result, | 122 const AttachmentStore::Result& source_result, |
123 scoped_ptr<AttachmentMetadataList> source_metadata) { | 123 scoped_ptr<AttachmentMetadataList> source_metadata) { |
124 CopyResult(destination_result, source_result); | 124 CopyResult(destination_result, source_result); |
125 *destination_metadata = source_metadata.Pass(); | 125 *destination_metadata = source_metadata.Pass(); |
126 } | 126 } |
127 }; | 127 }; |
128 | 128 |
129 TYPED_TEST_CASE_P(AttachmentStoreTest); | 129 TYPED_TEST_CASE_P(AttachmentStoreTest); |
130 | 130 |
| 131 // Verify that CreateAttachmentStoreForSync() creates valid object. |
| 132 TYPED_TEST_P(AttachmentStoreTest, CreateAttachmentStoreForSync) { |
| 133 scoped_ptr<AttachmentStoreForSync> attachment_store_for_sync = |
| 134 this->store->CreateAttachmentStoreForSync(); |
| 135 EXPECT_NE(nullptr, attachment_store_for_sync); |
| 136 } |
| 137 |
131 // Verify that we do not overwrite existing attachments and that we do not treat | 138 // Verify that we do not overwrite existing attachments and that we do not treat |
132 // it as an error. | 139 // it as an error. |
133 TYPED_TEST_P(AttachmentStoreTest, Write_NoOverwriteNoError) { | 140 TYPED_TEST_P(AttachmentStoreTest, Write_NoOverwriteNoError) { |
134 // Create two attachments with the same id but different data. | 141 // Create two attachments with the same id but different data. |
135 Attachment attachment1 = Attachment::Create(this->some_data1); | 142 Attachment attachment1 = Attachment::Create(this->some_data1); |
136 Attachment attachment2 = | 143 Attachment attachment2 = |
137 Attachment::CreateFromParts(attachment1.GetId(), this->some_data2); | 144 Attachment::CreateFromParts(attachment1.GetId(), this->some_data2); |
138 | 145 |
139 // Write the first one. | 146 // Write the first one. |
140 AttachmentList some_attachments; | 147 AttachmentList some_attachments; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 const AttachmentMetadataList::const_iterator end = | 386 const AttachmentMetadataList::const_iterator end = |
380 this->attachment_metadata->end(); | 387 this->attachment_metadata->end(); |
381 for (; iter != end; ++iter) { | 388 for (; iter != end; ++iter) { |
382 EXPECT_THAT(ids, testing::Contains(iter->GetId())); | 389 EXPECT_THAT(ids, testing::Contains(iter->GetId())); |
383 ids.erase(iter->GetId()); | 390 ids.erase(iter->GetId()); |
384 } | 391 } |
385 EXPECT_TRUE(ids.empty()); | 392 EXPECT_TRUE(ids.empty()); |
386 } | 393 } |
387 | 394 |
388 REGISTER_TYPED_TEST_CASE_P(AttachmentStoreTest, | 395 REGISTER_TYPED_TEST_CASE_P(AttachmentStoreTest, |
| 396 CreateAttachmentStoreForSync, |
389 Write_NoOverwriteNoError, | 397 Write_NoOverwriteNoError, |
390 Write_RoundTrip, | 398 Write_RoundTrip, |
391 Read_OneNotFound, | 399 Read_OneNotFound, |
392 Drop_DropTwoButOnlyOneExists, | 400 Drop_DropTwoButOnlyOneExists, |
393 Drop_DoesNotExist, | 401 Drop_DoesNotExist, |
394 ReadMetadata, | 402 ReadMetadata, |
395 ReadAllMetadata); | 403 ReadAllMetadata); |
396 | 404 |
397 } // namespace syncer | 405 } // namespace syncer |
398 | 406 |
399 #endif // SYNC_INTERNAL_API_ATTACHMENTS_ATTACHMENT_STORE_TEST_TEMPLATE_H_ | 407 #endif // SYNC_INTERNAL_API_ATTACHMENTS_ATTACHMENT_STORE_TEST_TEMPLATE_H_ |
OLD | NEW |