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_handle.h" | 5 #include "sync/internal_api/public/attachments/attachment_store_handle.h" |
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" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 base::Bind(&AttachmentStoreHandleTest::WriteCalled, | 72 base::Bind(&AttachmentStoreHandleTest::WriteCalled, |
73 base::Unretained(this)), | 73 base::Unretained(this)), |
74 base::Bind(&AttachmentStoreHandleTest::DropCalled, | 74 base::Bind(&AttachmentStoreHandleTest::DropCalled, |
75 base::Unretained(this)), | 75 base::Unretained(this)), |
76 base::Bind(&AttachmentStoreHandleTest::DtorCalled, | 76 base::Bind(&AttachmentStoreHandleTest::DtorCalled, |
77 base::Unretained(this)))); | 77 base::Unretained(this)))); |
78 attachment_store_handle_ = new AttachmentStoreHandle( | 78 attachment_store_handle_ = new AttachmentStoreHandle( |
79 backend.Pass(), base::ThreadTaskRunnerHandle::Get()); | 79 backend.Pass(), base::ThreadTaskRunnerHandle::Get()); |
80 } | 80 } |
81 | 81 |
| 82 static void DoneWithResult(const AttachmentStore::Result& result) { |
| 83 NOTREACHED(); |
| 84 } |
| 85 |
82 static void ReadDone(const AttachmentStore::Result& result, | 86 static void ReadDone(const AttachmentStore::Result& result, |
83 scoped_ptr<AttachmentMap> attachments, | 87 scoped_ptr<AttachmentMap> attachments, |
84 scoped_ptr<AttachmentIdList> unavailable_attachments) { | 88 scoped_ptr<AttachmentIdList> unavailable_attachments) { |
85 NOTREACHED(); | 89 NOTREACHED(); |
86 } | 90 } |
87 | 91 |
88 static void WriteDone(const AttachmentStore::Result& result) { | |
89 NOTREACHED(); | |
90 } | |
91 | |
92 static void DropDone(const AttachmentStore::Result& result) { | |
93 NOTREACHED(); | |
94 } | |
95 | |
96 void ReadCalled() { ++read_call_count_; } | 92 void ReadCalled() { ++read_call_count_; } |
97 | 93 |
98 void WriteCalled() { ++write_call_count_; } | 94 void WriteCalled() { ++write_call_count_; } |
99 | 95 |
100 void DropCalled() { ++drop_call_count_; } | 96 void DropCalled() { ++drop_call_count_; } |
101 | 97 |
102 void DtorCalled() { ++dtor_call_count_; } | 98 void DtorCalled() { ++dtor_call_count_; } |
103 | 99 |
104 void RunMessageLoop() { | 100 void RunMessageLoop() { |
105 base::RunLoop run_loop; | 101 base::RunLoop run_loop; |
(...skipping 13 matching lines...) Expand all Loading... |
119 AttachmentIdList ids; | 115 AttachmentIdList ids; |
120 AttachmentList attachments; | 116 AttachmentList attachments; |
121 | 117 |
122 attachment_store_handle_->Read( | 118 attachment_store_handle_->Read( |
123 ids, base::Bind(&AttachmentStoreHandleTest::ReadDone)); | 119 ids, base::Bind(&AttachmentStoreHandleTest::ReadDone)); |
124 EXPECT_EQ(read_call_count_, 0); | 120 EXPECT_EQ(read_call_count_, 0); |
125 RunMessageLoop(); | 121 RunMessageLoop(); |
126 EXPECT_EQ(read_call_count_, 1); | 122 EXPECT_EQ(read_call_count_, 1); |
127 | 123 |
128 attachment_store_handle_->Write( | 124 attachment_store_handle_->Write( |
129 attachments, base::Bind(&AttachmentStoreHandleTest::WriteDone)); | 125 attachments, base::Bind(&AttachmentStoreHandleTest::DoneWithResult)); |
130 EXPECT_EQ(write_call_count_, 0); | 126 EXPECT_EQ(write_call_count_, 0); |
131 RunMessageLoop(); | 127 RunMessageLoop(); |
132 EXPECT_EQ(write_call_count_, 1); | 128 EXPECT_EQ(write_call_count_, 1); |
133 | 129 |
134 attachment_store_handle_->Drop( | 130 attachment_store_handle_->Drop( |
135 ids, base::Bind(&AttachmentStoreHandleTest::DropDone)); | 131 ids, base::Bind(&AttachmentStoreHandleTest::DoneWithResult)); |
136 EXPECT_EQ(drop_call_count_, 0); | 132 EXPECT_EQ(drop_call_count_, 0); |
137 RunMessageLoop(); | 133 RunMessageLoop(); |
138 EXPECT_EQ(drop_call_count_, 1); | 134 EXPECT_EQ(drop_call_count_, 1); |
139 | 135 |
140 // Releasing referehce to AttachmentStoreHandle should result in | 136 // Releasing referehce to AttachmentStoreHandle should result in |
141 // MockAttachmentStore being deleted on backend loop. | 137 // MockAttachmentStore being deleted on backend loop. |
142 attachment_store_handle_ = NULL; | 138 attachment_store_handle_ = NULL; |
143 EXPECT_EQ(dtor_call_count_, 0); | 139 EXPECT_EQ(dtor_call_count_, 0); |
144 RunMessageLoop(); | 140 RunMessageLoop(); |
145 EXPECT_EQ(dtor_call_count_, 1); | 141 EXPECT_EQ(dtor_call_count_, 1); |
146 } | 142 } |
147 | 143 |
148 } // namespace syncer | 144 } // namespace syncer |
OLD | NEW |