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 "sync/internal_api/public/attachments/attachment_store_frontend.h" | 5 #include <utility> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
14 #include "sync/api/attachments/attachment.h" | 14 #include "sync/api/attachments/attachment.h" |
15 #include "sync/api/attachments/attachment_id.h" | 15 #include "sync/api/attachments/attachment_id.h" |
16 #include "sync/api/attachments/attachment_store_backend.h" | 16 #include "sync/api/attachments/attachment_store_backend.h" |
17 #include "sync/internal_api/public/attachments/attachment_store_frontend.h" | |
Nicolas Zea
2015/12/18 23:46:54
keep up top
| |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace syncer { | 20 namespace syncer { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 class MockAttachmentStore : public AttachmentStoreBackend { | 24 class MockAttachmentStore : public AttachmentStoreBackend { |
24 public: | 25 public: |
25 MockAttachmentStore(const base::Closure& init_called, | 26 MockAttachmentStore(const base::Closure& init_called, |
26 const base::Closure& read_called, | 27 const base::Closure& read_called, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 base::Unretained(this)), | 119 base::Unretained(this)), |
119 base::Bind(&AttachmentStoreFrontendTest::DropReferenceCalled, | 120 base::Bind(&AttachmentStoreFrontendTest::DropReferenceCalled, |
120 base::Unretained(this)), | 121 base::Unretained(this)), |
121 base::Bind(&AttachmentStoreFrontendTest::ReadMetadataByIdCalled, | 122 base::Bind(&AttachmentStoreFrontendTest::ReadMetadataByIdCalled, |
122 base::Unretained(this)), | 123 base::Unretained(this)), |
123 base::Bind(&AttachmentStoreFrontendTest::ReadMetadataCalled, | 124 base::Bind(&AttachmentStoreFrontendTest::ReadMetadataCalled, |
124 base::Unretained(this)), | 125 base::Unretained(this)), |
125 base::Bind(&AttachmentStoreFrontendTest::DtorCalled, | 126 base::Bind(&AttachmentStoreFrontendTest::DtorCalled, |
126 base::Unretained(this)))); | 127 base::Unretained(this)))); |
127 attachment_store_frontend_ = new AttachmentStoreFrontend( | 128 attachment_store_frontend_ = new AttachmentStoreFrontend( |
128 backend.Pass(), base::ThreadTaskRunnerHandle::Get()); | 129 std::move(backend), base::ThreadTaskRunnerHandle::Get()); |
129 } | 130 } |
130 | 131 |
131 static void DoneWithResult(const AttachmentStore::Result& result) { | 132 static void DoneWithResult(const AttachmentStore::Result& result) { |
132 NOTREACHED(); | 133 NOTREACHED(); |
133 } | 134 } |
134 | 135 |
135 static void ReadDone(const AttachmentStore::Result& result, | 136 static void ReadDone(const AttachmentStore::Result& result, |
136 scoped_ptr<AttachmentMap> attachments, | 137 scoped_ptr<AttachmentMap> attachments, |
137 scoped_ptr<AttachmentIdList> unavailable_attachments) { | 138 scoped_ptr<AttachmentIdList> unavailable_attachments) { |
138 NOTREACHED(); | 139 NOTREACHED(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 | 227 |
227 // Releasing referehce to AttachmentStoreFrontend should result in | 228 // Releasing referehce to AttachmentStoreFrontend should result in |
228 // MockAttachmentStore being deleted on backend loop. | 229 // MockAttachmentStore being deleted on backend loop. |
229 attachment_store_frontend_ = NULL; | 230 attachment_store_frontend_ = NULL; |
230 EXPECT_EQ(dtor_call_count_, 0); | 231 EXPECT_EQ(dtor_call_count_, 0); |
231 RunMessageLoop(); | 232 RunMessageLoop(); |
232 EXPECT_EQ(dtor_call_count_, 1); | 233 EXPECT_EQ(dtor_call_count_, 1); |
233 } | 234 } |
234 | 235 |
235 } // namespace syncer | 236 } // namespace syncer |
OLD | NEW |