| OLD | NEW |
| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 add_awakable_call_count_(0), | 208 add_awakable_call_count_(0), |
| 209 remove_awakable_call_count_(0), | 209 remove_awakable_call_count_(0), |
| 210 cancel_all_awakables_call_count_(0), | 210 cancel_all_awakables_call_count_(0), |
| 211 add_awakable_allowed_(false) { | 211 add_awakable_allowed_(false) { |
| 212 } | 212 } |
| 213 | 213 |
| 214 CoreTestBase_MockHandleInfo::~CoreTestBase_MockHandleInfo() { | 214 CoreTestBase_MockHandleInfo::~CoreTestBase_MockHandleInfo() { |
| 215 } | 215 } |
| 216 | 216 |
| 217 unsigned CoreTestBase_MockHandleInfo::GetCtorCallCount() const { | 217 unsigned CoreTestBase_MockHandleInfo::GetCtorCallCount() const { |
| 218 base::AutoLock locker(lock_); | 218 MutexLocker locker(&mutex_); |
| 219 return ctor_call_count_; | 219 return ctor_call_count_; |
| 220 } | 220 } |
| 221 | 221 |
| 222 unsigned CoreTestBase_MockHandleInfo::GetDtorCallCount() const { | 222 unsigned CoreTestBase_MockHandleInfo::GetDtorCallCount() const { |
| 223 base::AutoLock locker(lock_); | 223 MutexLocker locker(&mutex_); |
| 224 return dtor_call_count_; | 224 return dtor_call_count_; |
| 225 } | 225 } |
| 226 | 226 |
| 227 unsigned CoreTestBase_MockHandleInfo::GetCloseCallCount() const { | 227 unsigned CoreTestBase_MockHandleInfo::GetCloseCallCount() const { |
| 228 base::AutoLock locker(lock_); | 228 MutexLocker locker(&mutex_); |
| 229 return close_call_count_; | 229 return close_call_count_; |
| 230 } | 230 } |
| 231 | 231 |
| 232 unsigned CoreTestBase_MockHandleInfo::GetWriteMessageCallCount() const { | 232 unsigned CoreTestBase_MockHandleInfo::GetWriteMessageCallCount() const { |
| 233 base::AutoLock locker(lock_); | 233 MutexLocker locker(&mutex_); |
| 234 return write_message_call_count_; | 234 return write_message_call_count_; |
| 235 } | 235 } |
| 236 | 236 |
| 237 unsigned CoreTestBase_MockHandleInfo::GetReadMessageCallCount() const { | 237 unsigned CoreTestBase_MockHandleInfo::GetReadMessageCallCount() const { |
| 238 base::AutoLock locker(lock_); | 238 MutexLocker locker(&mutex_); |
| 239 return read_message_call_count_; | 239 return read_message_call_count_; |
| 240 } | 240 } |
| 241 | 241 |
| 242 unsigned CoreTestBase_MockHandleInfo::GetWriteDataCallCount() const { | 242 unsigned CoreTestBase_MockHandleInfo::GetWriteDataCallCount() const { |
| 243 base::AutoLock locker(lock_); | 243 MutexLocker locker(&mutex_); |
| 244 return write_data_call_count_; | 244 return write_data_call_count_; |
| 245 } | 245 } |
| 246 | 246 |
| 247 unsigned CoreTestBase_MockHandleInfo::GetBeginWriteDataCallCount() const { | 247 unsigned CoreTestBase_MockHandleInfo::GetBeginWriteDataCallCount() const { |
| 248 base::AutoLock locker(lock_); | 248 MutexLocker locker(&mutex_); |
| 249 return begin_write_data_call_count_; | 249 return begin_write_data_call_count_; |
| 250 } | 250 } |
| 251 | 251 |
| 252 unsigned CoreTestBase_MockHandleInfo::GetEndWriteDataCallCount() const { | 252 unsigned CoreTestBase_MockHandleInfo::GetEndWriteDataCallCount() const { |
| 253 base::AutoLock locker(lock_); | 253 MutexLocker locker(&mutex_); |
| 254 return end_write_data_call_count_; | 254 return end_write_data_call_count_; |
| 255 } | 255 } |
| 256 | 256 |
| 257 unsigned CoreTestBase_MockHandleInfo::GetReadDataCallCount() const { | 257 unsigned CoreTestBase_MockHandleInfo::GetReadDataCallCount() const { |
| 258 base::AutoLock locker(lock_); | 258 MutexLocker locker(&mutex_); |
| 259 return read_data_call_count_; | 259 return read_data_call_count_; |
| 260 } | 260 } |
| 261 | 261 |
| 262 unsigned CoreTestBase_MockHandleInfo::GetBeginReadDataCallCount() const { | 262 unsigned CoreTestBase_MockHandleInfo::GetBeginReadDataCallCount() const { |
| 263 base::AutoLock locker(lock_); | 263 MutexLocker locker(&mutex_); |
| 264 return begin_read_data_call_count_; | 264 return begin_read_data_call_count_; |
| 265 } | 265 } |
| 266 | 266 |
| 267 unsigned CoreTestBase_MockHandleInfo::GetEndReadDataCallCount() const { | 267 unsigned CoreTestBase_MockHandleInfo::GetEndReadDataCallCount() const { |
| 268 base::AutoLock locker(lock_); | 268 MutexLocker locker(&mutex_); |
| 269 return end_read_data_call_count_; | 269 return end_read_data_call_count_; |
| 270 } | 270 } |
| 271 | 271 |
| 272 unsigned CoreTestBase_MockHandleInfo::GetAddAwakableCallCount() const { | 272 unsigned CoreTestBase_MockHandleInfo::GetAddAwakableCallCount() const { |
| 273 base::AutoLock locker(lock_); | 273 MutexLocker locker(&mutex_); |
| 274 return add_awakable_call_count_; | 274 return add_awakable_call_count_; |
| 275 } | 275 } |
| 276 | 276 |
| 277 unsigned CoreTestBase_MockHandleInfo::GetRemoveAwakableCallCount() const { | 277 unsigned CoreTestBase_MockHandleInfo::GetRemoveAwakableCallCount() const { |
| 278 base::AutoLock locker(lock_); | 278 MutexLocker locker(&mutex_); |
| 279 return remove_awakable_call_count_; | 279 return remove_awakable_call_count_; |
| 280 } | 280 } |
| 281 | 281 |
| 282 unsigned CoreTestBase_MockHandleInfo::GetCancelAllAwakablesCallCount() const { | 282 unsigned CoreTestBase_MockHandleInfo::GetCancelAllAwakablesCallCount() const { |
| 283 base::AutoLock locker(lock_); | 283 MutexLocker locker(&mutex_); |
| 284 return cancel_all_awakables_call_count_; | 284 return cancel_all_awakables_call_count_; |
| 285 } | 285 } |
| 286 | 286 |
| 287 size_t CoreTestBase_MockHandleInfo::GetAddedAwakableSize() const { | 287 size_t CoreTestBase_MockHandleInfo::GetAddedAwakableSize() const { |
| 288 base::AutoLock locker(lock_); | 288 MutexLocker locker(&mutex_); |
| 289 return added_awakables_.size(); | 289 return added_awakables_.size(); |
| 290 } | 290 } |
| 291 | 291 |
| 292 Awakable* CoreTestBase_MockHandleInfo::GetAddedAwakableAt(unsigned i) const { | 292 Awakable* CoreTestBase_MockHandleInfo::GetAddedAwakableAt(unsigned i) const { |
| 293 base::AutoLock locker(lock_); | 293 MutexLocker locker(&mutex_); |
| 294 return added_awakables_[i]; | 294 return added_awakables_[i]; |
| 295 } | 295 } |
| 296 | 296 |
| 297 void CoreTestBase_MockHandleInfo::IncrementCtorCallCount() { | 297 void CoreTestBase_MockHandleInfo::IncrementCtorCallCount() { |
| 298 base::AutoLock locker(lock_); | 298 MutexLocker locker(&mutex_); |
| 299 ctor_call_count_++; | 299 ctor_call_count_++; |
| 300 } | 300 } |
| 301 | 301 |
| 302 void CoreTestBase_MockHandleInfo::IncrementDtorCallCount() { | 302 void CoreTestBase_MockHandleInfo::IncrementDtorCallCount() { |
| 303 base::AutoLock locker(lock_); | 303 MutexLocker locker(&mutex_); |
| 304 dtor_call_count_++; | 304 dtor_call_count_++; |
| 305 } | 305 } |
| 306 | 306 |
| 307 void CoreTestBase_MockHandleInfo::IncrementCloseCallCount() { | 307 void CoreTestBase_MockHandleInfo::IncrementCloseCallCount() { |
| 308 base::AutoLock locker(lock_); | 308 MutexLocker locker(&mutex_); |
| 309 close_call_count_++; | 309 close_call_count_++; |
| 310 } | 310 } |
| 311 | 311 |
| 312 void CoreTestBase_MockHandleInfo::IncrementWriteMessageCallCount() { | 312 void CoreTestBase_MockHandleInfo::IncrementWriteMessageCallCount() { |
| 313 base::AutoLock locker(lock_); | 313 MutexLocker locker(&mutex_); |
| 314 write_message_call_count_++; | 314 write_message_call_count_++; |
| 315 } | 315 } |
| 316 | 316 |
| 317 void CoreTestBase_MockHandleInfo::IncrementReadMessageCallCount() { | 317 void CoreTestBase_MockHandleInfo::IncrementReadMessageCallCount() { |
| 318 base::AutoLock locker(lock_); | 318 MutexLocker locker(&mutex_); |
| 319 read_message_call_count_++; | 319 read_message_call_count_++; |
| 320 } | 320 } |
| 321 | 321 |
| 322 void CoreTestBase_MockHandleInfo::IncrementWriteDataCallCount() { | 322 void CoreTestBase_MockHandleInfo::IncrementWriteDataCallCount() { |
| 323 base::AutoLock locker(lock_); | 323 MutexLocker locker(&mutex_); |
| 324 write_data_call_count_++; | 324 write_data_call_count_++; |
| 325 } | 325 } |
| 326 | 326 |
| 327 void CoreTestBase_MockHandleInfo::IncrementBeginWriteDataCallCount() { | 327 void CoreTestBase_MockHandleInfo::IncrementBeginWriteDataCallCount() { |
| 328 base::AutoLock locker(lock_); | 328 MutexLocker locker(&mutex_); |
| 329 begin_write_data_call_count_++; | 329 begin_write_data_call_count_++; |
| 330 } | 330 } |
| 331 | 331 |
| 332 void CoreTestBase_MockHandleInfo::IncrementEndWriteDataCallCount() { | 332 void CoreTestBase_MockHandleInfo::IncrementEndWriteDataCallCount() { |
| 333 base::AutoLock locker(lock_); | 333 MutexLocker locker(&mutex_); |
| 334 end_write_data_call_count_++; | 334 end_write_data_call_count_++; |
| 335 } | 335 } |
| 336 | 336 |
| 337 void CoreTestBase_MockHandleInfo::IncrementReadDataCallCount() { | 337 void CoreTestBase_MockHandleInfo::IncrementReadDataCallCount() { |
| 338 base::AutoLock locker(lock_); | 338 MutexLocker locker(&mutex_); |
| 339 read_data_call_count_++; | 339 read_data_call_count_++; |
| 340 } | 340 } |
| 341 | 341 |
| 342 void CoreTestBase_MockHandleInfo::IncrementBeginReadDataCallCount() { | 342 void CoreTestBase_MockHandleInfo::IncrementBeginReadDataCallCount() { |
| 343 base::AutoLock locker(lock_); | 343 MutexLocker locker(&mutex_); |
| 344 begin_read_data_call_count_++; | 344 begin_read_data_call_count_++; |
| 345 } | 345 } |
| 346 | 346 |
| 347 void CoreTestBase_MockHandleInfo::IncrementEndReadDataCallCount() { | 347 void CoreTestBase_MockHandleInfo::IncrementEndReadDataCallCount() { |
| 348 base::AutoLock locker(lock_); | 348 MutexLocker locker(&mutex_); |
| 349 end_read_data_call_count_++; | 349 end_read_data_call_count_++; |
| 350 } | 350 } |
| 351 | 351 |
| 352 void CoreTestBase_MockHandleInfo::IncrementAddAwakableCallCount() { | 352 void CoreTestBase_MockHandleInfo::IncrementAddAwakableCallCount() { |
| 353 base::AutoLock locker(lock_); | 353 MutexLocker locker(&mutex_); |
| 354 add_awakable_call_count_++; | 354 add_awakable_call_count_++; |
| 355 } | 355 } |
| 356 | 356 |
| 357 void CoreTestBase_MockHandleInfo::IncrementRemoveAwakableCallCount() { | 357 void CoreTestBase_MockHandleInfo::IncrementRemoveAwakableCallCount() { |
| 358 base::AutoLock locker(lock_); | 358 MutexLocker locker(&mutex_); |
| 359 remove_awakable_call_count_++; | 359 remove_awakable_call_count_++; |
| 360 } | 360 } |
| 361 | 361 |
| 362 void CoreTestBase_MockHandleInfo::IncrementCancelAllAwakablesCallCount() { | 362 void CoreTestBase_MockHandleInfo::IncrementCancelAllAwakablesCallCount() { |
| 363 base::AutoLock locker(lock_); | 363 MutexLocker locker(&mutex_); |
| 364 cancel_all_awakables_call_count_++; | 364 cancel_all_awakables_call_count_++; |
| 365 } | 365 } |
| 366 | 366 |
| 367 void CoreTestBase_MockHandleInfo::AllowAddAwakable(bool alllow) { | 367 void CoreTestBase_MockHandleInfo::AllowAddAwakable(bool alllow) { |
| 368 base::AutoLock locker(lock_); | 368 MutexLocker locker(&mutex_); |
| 369 add_awakable_allowed_ = alllow; | 369 add_awakable_allowed_ = alllow; |
| 370 } | 370 } |
| 371 | 371 |
| 372 bool CoreTestBase_MockHandleInfo::IsAddAwakableAllowed() const { | 372 bool CoreTestBase_MockHandleInfo::IsAddAwakableAllowed() const { |
| 373 base::AutoLock locker(lock_); | 373 MutexLocker locker(&mutex_); |
| 374 return add_awakable_allowed_; | 374 return add_awakable_allowed_; |
| 375 } | 375 } |
| 376 | 376 |
| 377 void CoreTestBase_MockHandleInfo::AwakableWasAdded(Awakable* awakable) { | 377 void CoreTestBase_MockHandleInfo::AwakableWasAdded(Awakable* awakable) { |
| 378 base::AutoLock locker(lock_); | 378 MutexLocker locker(&mutex_); |
| 379 added_awakables_.push_back(awakable); | 379 added_awakables_.push_back(awakable); |
| 380 } | 380 } |
| 381 | 381 |
| 382 } // namespace test | 382 } // namespace test |
| 383 } // namespace system | 383 } // namespace system |
| 384 } // namespace mojo | 384 } // namespace mojo |
| OLD | NEW |