Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: sync/internal_api/attachments/attachment_store_test_template.h

Issue 1866243002: Convert //sync from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory>
8 #include <utility> 9 #include <utility>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
12 #include "base/memory/ref_counted_memory.h" 13 #include "base/memory/ref_counted_memory.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/api/attachments/attachment_store.h"
18 #include "sync/internal_api/public/attachments/attachment_util.h" 18 #include "sync/internal_api/public/attachments/attachment_util.h"
19 #include "sync/protocol/sync.pb.h" 19 #include "sync/protocol/sync.pb.h"
20 #include "testing/gmock/include/gmock/gmock-matchers.h" 20 #include "testing/gmock/include/gmock/gmock-matchers.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 // AttachmentStoreTest defines tests for AttachmentStore. To instantiate these 23 // AttachmentStoreTest defines tests for AttachmentStore. To instantiate these
(...skipping 17 matching lines...) Expand all
41 namespace syncer { 41 namespace syncer {
42 42
43 const char kTestData1[] = "test data 1"; 43 const char kTestData1[] = "test data 1";
44 const char kTestData2[] = "test data 2"; 44 const char kTestData2[] = "test data 2";
45 45
46 template <typename AttachmentStoreFactory> 46 template <typename AttachmentStoreFactory>
47 class AttachmentStoreTest : public testing::Test { 47 class AttachmentStoreTest : public testing::Test {
48 protected: 48 protected:
49 AttachmentStoreFactory attachment_store_factory; 49 AttachmentStoreFactory attachment_store_factory;
50 base::MessageLoop message_loop; 50 base::MessageLoop message_loop;
51 scoped_ptr<AttachmentStore> store; 51 std::unique_ptr<AttachmentStore> store;
52 scoped_ptr<AttachmentStoreForSync> store_for_sync; 52 std::unique_ptr<AttachmentStoreForSync> store_for_sync;
53 AttachmentStore::Result result; 53 AttachmentStore::Result result;
54 scoped_ptr<AttachmentMap> attachments; 54 std::unique_ptr<AttachmentMap> attachments;
55 scoped_ptr<AttachmentIdList> failed_attachment_ids; 55 std::unique_ptr<AttachmentIdList> failed_attachment_ids;
56 scoped_ptr<AttachmentMetadataList> attachment_metadata; 56 std::unique_ptr<AttachmentMetadataList> attachment_metadata;
57 57
58 AttachmentStore::ReadCallback read_callback; 58 AttachmentStore::ReadCallback read_callback;
59 AttachmentStore::WriteCallback write_callback; 59 AttachmentStore::WriteCallback write_callback;
60 AttachmentStore::DropCallback drop_callback; 60 AttachmentStore::DropCallback drop_callback;
61 AttachmentStore::ReadMetadataCallback read_metadata_callback; 61 AttachmentStore::ReadMetadataCallback read_metadata_callback;
62 62
63 scoped_refptr<base::RefCountedString> some_data1; 63 scoped_refptr<base::RefCountedString> some_data1;
64 scoped_refptr<base::RefCountedString> some_data2; 64 scoped_refptr<base::RefCountedString> some_data2;
65 65
66 AttachmentStoreTest() {} 66 AttachmentStoreTest() {}
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 attachment_metadata.reset(); 102 attachment_metadata.reset();
103 } 103 }
104 104
105 void CopyResult(AttachmentStore::Result* destination_result, 105 void CopyResult(AttachmentStore::Result* destination_result,
106 const AttachmentStore::Result& source_result) { 106 const AttachmentStore::Result& source_result) {
107 *destination_result = source_result; 107 *destination_result = source_result;
108 } 108 }
109 109
110 void CopyResultAttachments( 110 void CopyResultAttachments(
111 AttachmentStore::Result* destination_result, 111 AttachmentStore::Result* destination_result,
112 scoped_ptr<AttachmentMap>* destination_attachments, 112 std::unique_ptr<AttachmentMap>* destination_attachments,
113 scoped_ptr<AttachmentIdList>* destination_failed_attachment_ids, 113 std::unique_ptr<AttachmentIdList>* destination_failed_attachment_ids,
114 const AttachmentStore::Result& source_result, 114 const AttachmentStore::Result& source_result,
115 scoped_ptr<AttachmentMap> source_attachments, 115 std::unique_ptr<AttachmentMap> source_attachments,
116 scoped_ptr<AttachmentIdList> source_failed_attachment_ids) { 116 std::unique_ptr<AttachmentIdList> source_failed_attachment_ids) {
117 CopyResult(destination_result, source_result); 117 CopyResult(destination_result, source_result);
118 *destination_attachments = std::move(source_attachments); 118 *destination_attachments = std::move(source_attachments);
119 *destination_failed_attachment_ids = 119 *destination_failed_attachment_ids =
120 std::move(source_failed_attachment_ids); 120 std::move(source_failed_attachment_ids);
121 } 121 }
122 122
123 void CopyResultMetadata( 123 void CopyResultMetadata(
124 AttachmentStore::Result* destination_result, 124 AttachmentStore::Result* destination_result,
125 scoped_ptr<AttachmentMetadataList>* destination_metadata, 125 std::unique_ptr<AttachmentMetadataList>* destination_metadata,
126 const AttachmentStore::Result& source_result, 126 const AttachmentStore::Result& source_result,
127 scoped_ptr<AttachmentMetadataList> source_metadata) { 127 std::unique_ptr<AttachmentMetadataList> source_metadata) {
128 CopyResult(destination_result, source_result); 128 CopyResult(destination_result, source_result);
129 *destination_metadata = std::move(source_metadata); 129 *destination_metadata = std::move(source_metadata);
130 } 130 }
131 }; 131 };
132 132
133 TYPED_TEST_CASE_P(AttachmentStoreTest); 133 TYPED_TEST_CASE_P(AttachmentStoreTest);
134 134
135 // Verify that CreateAttachmentStoreForSync() creates valid object. 135 // Verify that CreateAttachmentStoreForSync() creates valid object.
136 TYPED_TEST_P(AttachmentStoreTest, CreateAttachmentStoreForSync) { 136 TYPED_TEST_P(AttachmentStoreTest, CreateAttachmentStoreForSync) {
137 scoped_ptr<AttachmentStoreForSync> attachment_store_for_sync = 137 std::unique_ptr<AttachmentStoreForSync> attachment_store_for_sync =
138 this->store->CreateAttachmentStoreForSync(); 138 this->store->CreateAttachmentStoreForSync();
139 EXPECT_NE(nullptr, attachment_store_for_sync); 139 EXPECT_NE(nullptr, attachment_store_for_sync);
140 } 140 }
141 141
142 // Verify that we do not overwrite existing attachments and that we do not treat 142 // Verify that we do not overwrite existing attachments and that we do not treat
143 // it as an error. 143 // it as an error.
144 TYPED_TEST_P(AttachmentStoreTest, Write_NoOverwriteNoError) { 144 TYPED_TEST_P(AttachmentStoreTest, Write_NoOverwriteNoError) {
145 // Create two attachments with the same id but different data. 145 // Create two attachments with the same id but different data.
146 Attachment attachment1 = Attachment::Create(this->some_data1); 146 Attachment attachment1 = Attachment::Create(this->some_data1);
147 Attachment attachment2 = 147 Attachment attachment2 =
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 Read_OneNotFound, 515 Read_OneNotFound,
516 Drop_DropTwoButOnlyOneExists, 516 Drop_DropTwoButOnlyOneExists,
517 Drop_DoesNotExist, 517 Drop_DoesNotExist,
518 ReadMetadataById, 518 ReadMetadataById,
519 ReadMetadata, 519 ReadMetadata,
520 SetSyncReference_DropSyncReference); 520 SetSyncReference_DropSyncReference);
521 521
522 } // namespace syncer 522 } // namespace syncer
523 523
524 #endif // SYNC_INTERNAL_API_ATTACHMENTS_ATTACHMENT_STORE_TEST_TEMPLATE_H_ 524 #endif // SYNC_INTERNAL_API_ATTACHMENTS_ATTACHMENT_STORE_TEST_TEMPLATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698