public final class

TestScheduler

extends Scheduler
java.lang.Object
   ↳ io.reactivex.Scheduler
     ↳ io.reactivex.schedulers.TestScheduler

Class Overview

A special, non thread-safe scheduler for testing operators that require a scheduler without introducing real concurrency and allows manually advancing a virtual time.

Summary

Public Constructors
TestScheduler()
Public Methods
void advanceTimeBy(long delayTime, TimeUnit unit)
Moves the Scheduler's clock forward by a specified amount of time.
void advanceTimeTo(long delayTime, TimeUnit unit)
Moves the Scheduler's clock to a particular moment in time.
Scheduler.Worker createWorker()
Retrieves or creates a new Scheduler.Worker that represents serial execution of actions.
long now(TimeUnit unit)
Returns the 'current time' of the Scheduler in the specified time unit.
void triggerActions()
Triggers any actions that have not yet been triggered and that are scheduled to be triggered at or before this Scheduler's present time.
[Expand]
Inherited Methods
From class io.reactivex.Scheduler
From class java.lang.Object

Public Constructors

public TestScheduler ()

Public Methods

public void advanceTimeBy (long delayTime, TimeUnit unit)

Moves the Scheduler's clock forward by a specified amount of time.

Parameters
delayTime the amount of time to move the Scheduler's clock forward
unit the units of time that delayTime is expressed in

public void advanceTimeTo (long delayTime, TimeUnit unit)

Moves the Scheduler's clock to a particular moment in time.

Parameters
delayTime the point in time to move the Scheduler's clock to
unit the units of time that delayTime is expressed in

public Scheduler.Worker createWorker ()

Retrieves or creates a new Scheduler.Worker that represents serial execution of actions.

When work is completed it should be unsubscribed using dispose().

Work on a Scheduler.Worker is guaranteed to be sequential.

Returns
  • a Worker representing a serial queue of actions to be executed

public long now (TimeUnit unit)

Returns the 'current time' of the Scheduler in the specified time unit.

Parameters
unit the time unit
Returns
  • the 'current time'

public void triggerActions ()

Triggers any actions that have not yet been triggered and that are scheduled to be triggered at or before this Scheduler's present time.