RACTestScheduler.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // RACTestScheduler.h
  3. // ReactiveCocoa
  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. /// A special kind of scheduler that steps through virtualized time.
  10. ///
  11. /// This scheduler class can be used in unit tests to verify asynchronous
  12. /// behaviors without spending significant time waiting.
  13. ///
  14. /// This class can be used from multiple threads, but only one thread can `step`
  15. /// through the enqueued actions at a time. Other threads will wait while the
  16. /// scheduled blocks are being executed.
  17. @interface RACTestScheduler : RACScheduler
  18. /// Initializes a new test scheduler.
  19. - (instancetype)init;
  20. /// Executes the next scheduled block, if any.
  21. ///
  22. /// This method will block until the scheduled action has completed.
  23. - (void)step;
  24. /// Executes up to the next `ticks` scheduled blocks.
  25. ///
  26. /// This method will block until the scheduled actions have completed.
  27. ///
  28. /// ticks - The number of scheduled blocks to execute. If there aren't this many
  29. /// blocks enqueued, all scheduled blocks are executed.
  30. - (void)step:(NSUInteger)ticks;
  31. /// Executes all of the scheduled blocks on the receiver.
  32. ///
  33. /// This method will block until the scheduled actions have completed.
  34. - (void)stepAll;
  35. @end