RACTestScheduler.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // RACTestScheduler.h
  3. // ReactiveObjC
  4. //
  5. // Created by Justin Spahr-Summers on 2013-07-06.
  6. // Copyright (c) 2013 GitHub, Inc. All rights reserved.
  7. //
  8. #import "RACScheduler.h"
  9. NS_ASSUME_NONNULL_BEGIN
  10. /// A special kind of scheduler that steps through virtualized time.
  11. ///
  12. /// This scheduler class can be used in unit tests to verify asynchronous
  13. /// behaviors without spending significant time waiting.
  14. ///
  15. /// This class can be used from multiple threads, but only one thread can `step`
  16. /// through the enqueued actions at a time. Other threads will wait while the
  17. /// scheduled blocks are being executed.
  18. @interface RACTestScheduler : RACScheduler
  19. /// Initializes a new test scheduler.
  20. - (instancetype)init;
  21. /// Executes the next scheduled block, if any.
  22. ///
  23. /// This method will block until the scheduled action has completed.
  24. - (void)step;
  25. /// Executes up to the next `ticks` scheduled blocks.
  26. ///
  27. /// This method will block until the scheduled actions have completed.
  28. ///
  29. /// ticks - The number of scheduled blocks to execute. If there aren't this many
  30. /// blocks enqueued, all scheduled blocks are executed.
  31. - (void)step:(NSUInteger)ticks;
  32. /// Executes all of the scheduled blocks on the receiver.
  33. ///
  34. /// This method will block until the scheduled actions have completed.
  35. - (void)stepAll;
  36. @end
  37. NS_ASSUME_NONNULL_END