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

Side by Side Diff: mojo/edk/system/core_test_base.cc

Issue 2744943002: Mojo: Move waiting APIs to public library (Closed)
Patch Set: . Created 3 years, 9 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
« no previous file with comments | « mojo/edk/system/core_test_base.h ('k') | mojo/edk/system/core_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/edk/system/core_test_base.h" 5 #include "mojo/edk/system/core_test_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 MojoReadDataFlags flags) override { 100 MojoReadDataFlags flags) override {
101 info_->IncrementBeginReadDataCallCount(); 101 info_->IncrementBeginReadDataCallCount();
102 return MOJO_RESULT_UNIMPLEMENTED; 102 return MOJO_RESULT_UNIMPLEMENTED;
103 } 103 }
104 104
105 MojoResult EndReadData(uint32_t num_bytes_read) override { 105 MojoResult EndReadData(uint32_t num_bytes_read) override {
106 info_->IncrementEndReadDataCallCount(); 106 info_->IncrementEndReadDataCallCount();
107 return MOJO_RESULT_UNIMPLEMENTED; 107 return MOJO_RESULT_UNIMPLEMENTED;
108 } 108 }
109 109
110 MojoResult AddAwakable(Awakable* awakable,
111 MojoHandleSignals /*signals*/,
112 uintptr_t /*context*/,
113 HandleSignalsState* signals_state) override {
114 info_->IncrementAddAwakableCallCount();
115 if (signals_state)
116 *signals_state = HandleSignalsState();
117 if (info_->IsAddAwakableAllowed()) {
118 info_->AwakableWasAdded(awakable);
119 return MOJO_RESULT_OK;
120 }
121
122 return MOJO_RESULT_FAILED_PRECONDITION;
123 }
124
125 void RemoveAwakable(Awakable* /*awakable*/,
126 HandleSignalsState* signals_state) override {
127 info_->IncrementRemoveAwakableCallCount();
128 if (signals_state)
129 *signals_state = HandleSignalsState();
130 }
131
132 private: 110 private:
133 explicit MockDispatcher(CoreTestBase::MockHandleInfo* info) : info_(info) { 111 explicit MockDispatcher(CoreTestBase::MockHandleInfo* info) : info_(info) {
134 CHECK(info_); 112 CHECK(info_);
135 info_->IncrementCtorCallCount(); 113 info_->IncrementCtorCallCount();
136 } 114 }
137 115
138 ~MockDispatcher() override { info_->IncrementDtorCallCount(); } 116 ~MockDispatcher() override { info_->IncrementDtorCallCount(); }
139 117
140 CoreTestBase::MockHandleInfo* const info_; 118 CoreTestBase::MockHandleInfo* const info_;
141 119
(...skipping 25 matching lines...) Expand all
167 : ctor_call_count_(0), 145 : ctor_call_count_(0),
168 dtor_call_count_(0), 146 dtor_call_count_(0),
169 close_call_count_(0), 147 close_call_count_(0),
170 write_message_call_count_(0), 148 write_message_call_count_(0),
171 read_message_call_count_(0), 149 read_message_call_count_(0),
172 write_data_call_count_(0), 150 write_data_call_count_(0),
173 begin_write_data_call_count_(0), 151 begin_write_data_call_count_(0),
174 end_write_data_call_count_(0), 152 end_write_data_call_count_(0),
175 read_data_call_count_(0), 153 read_data_call_count_(0),
176 begin_read_data_call_count_(0), 154 begin_read_data_call_count_(0),
177 end_read_data_call_count_(0), 155 end_read_data_call_count_(0) {}
178 add_awakable_call_count_(0),
179 remove_awakable_call_count_(0),
180 add_awakable_allowed_(false) {
181 }
182 156
183 CoreTestBase_MockHandleInfo::~CoreTestBase_MockHandleInfo() { 157 CoreTestBase_MockHandleInfo::~CoreTestBase_MockHandleInfo() {
184 } 158 }
185 159
186 unsigned CoreTestBase_MockHandleInfo::GetCtorCallCount() const { 160 unsigned CoreTestBase_MockHandleInfo::GetCtorCallCount() const {
187 base::AutoLock locker(lock_); 161 base::AutoLock locker(lock_);
188 return ctor_call_count_; 162 return ctor_call_count_;
189 } 163 }
190 164
191 unsigned CoreTestBase_MockHandleInfo::GetDtorCallCount() const { 165 unsigned CoreTestBase_MockHandleInfo::GetDtorCallCount() const {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 unsigned CoreTestBase_MockHandleInfo::GetBeginReadDataCallCount() const { 205 unsigned CoreTestBase_MockHandleInfo::GetBeginReadDataCallCount() const {
232 base::AutoLock locker(lock_); 206 base::AutoLock locker(lock_);
233 return begin_read_data_call_count_; 207 return begin_read_data_call_count_;
234 } 208 }
235 209
236 unsigned CoreTestBase_MockHandleInfo::GetEndReadDataCallCount() const { 210 unsigned CoreTestBase_MockHandleInfo::GetEndReadDataCallCount() const {
237 base::AutoLock locker(lock_); 211 base::AutoLock locker(lock_);
238 return end_read_data_call_count_; 212 return end_read_data_call_count_;
239 } 213 }
240 214
241 unsigned CoreTestBase_MockHandleInfo::GetAddAwakableCallCount() const {
242 base::AutoLock locker(lock_);
243 return add_awakable_call_count_;
244 }
245
246 unsigned CoreTestBase_MockHandleInfo::GetRemoveAwakableCallCount() const {
247 base::AutoLock locker(lock_);
248 return remove_awakable_call_count_;
249 }
250
251 size_t CoreTestBase_MockHandleInfo::GetAddedAwakableSize() const {
252 base::AutoLock locker(lock_);
253 return added_awakables_.size();
254 }
255
256 Awakable* CoreTestBase_MockHandleInfo::GetAddedAwakableAt(unsigned i) const {
257 base::AutoLock locker(lock_);
258 return added_awakables_[i];
259 }
260
261 void CoreTestBase_MockHandleInfo::IncrementCtorCallCount() { 215 void CoreTestBase_MockHandleInfo::IncrementCtorCallCount() {
262 base::AutoLock locker(lock_); 216 base::AutoLock locker(lock_);
263 ctor_call_count_++; 217 ctor_call_count_++;
264 } 218 }
265 219
266 void CoreTestBase_MockHandleInfo::IncrementDtorCallCount() { 220 void CoreTestBase_MockHandleInfo::IncrementDtorCallCount() {
267 base::AutoLock locker(lock_); 221 base::AutoLock locker(lock_);
268 dtor_call_count_++; 222 dtor_call_count_++;
269 } 223 }
270 224
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 void CoreTestBase_MockHandleInfo::IncrementBeginReadDataCallCount() { 260 void CoreTestBase_MockHandleInfo::IncrementBeginReadDataCallCount() {
307 base::AutoLock locker(lock_); 261 base::AutoLock locker(lock_);
308 begin_read_data_call_count_++; 262 begin_read_data_call_count_++;
309 } 263 }
310 264
311 void CoreTestBase_MockHandleInfo::IncrementEndReadDataCallCount() { 265 void CoreTestBase_MockHandleInfo::IncrementEndReadDataCallCount() {
312 base::AutoLock locker(lock_); 266 base::AutoLock locker(lock_);
313 end_read_data_call_count_++; 267 end_read_data_call_count_++;
314 } 268 }
315 269
316 void CoreTestBase_MockHandleInfo::IncrementAddAwakableCallCount() {
317 base::AutoLock locker(lock_);
318 add_awakable_call_count_++;
319 }
320
321 void CoreTestBase_MockHandleInfo::IncrementRemoveAwakableCallCount() {
322 base::AutoLock locker(lock_);
323 remove_awakable_call_count_++;
324 }
325
326 void CoreTestBase_MockHandleInfo::AllowAddAwakable(bool alllow) {
327 base::AutoLock locker(lock_);
328 add_awakable_allowed_ = alllow;
329 }
330
331 bool CoreTestBase_MockHandleInfo::IsAddAwakableAllowed() const {
332 base::AutoLock locker(lock_);
333 return add_awakable_allowed_;
334 }
335
336 void CoreTestBase_MockHandleInfo::AwakableWasAdded(Awakable* awakable) {
337 base::AutoLock locker(lock_);
338 added_awakables_.push_back(awakable);
339 }
340
341 } // namespace test 270 } // namespace test
342 } // namespace edk 271 } // namespace edk
343 } // namespace mojo 272 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/core_test_base.h ('k') | mojo/edk/system/core_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698