Packages

class TestScheduler extends Scheduler

Scheduler with artificial time, useful for testing.

For example, you could test the Observable.interval operation using a TestScheduler as follows:

@Test def testInterval() {
  import org.mockito.Matchers._
  import org.mockito.Mockito._
  import rx.lang.scala.JavaConversions._

  val scheduler = TestScheduler()
  val observer = mock(classOf[rx.Observer[Long]])

  val o = Observable.interval(1 second, scheduler)
  val sub = o.subscribe(toScalaObserver(new TestObserver(observer)))

  verify(observer, never).onNext(0L)
  verify(observer, never).onCompleted()
  verify(observer, never).onError(any(classOf[Throwable]))

  scheduler.advanceTimeTo(2 seconds)

  val inOrdr = inOrder(observer);
  inOrdr.verify(observer, times(1)).onNext(0L)
  inOrdr.verify(observer, times(1)).onNext(1L)
  inOrdr.verify(observer, never).onNext(2L)
  verify(observer, never).onCompleted()
  verify(observer, never).onError(any(classOf[Throwable]))

  sub.unsubscribe();
  scheduler.advanceTimeTo(4 seconds)
  verify(observer, never).onNext(2L)
  verify(observer, times(1)).onCompleted()
  verify(observer, never).onError(any(classOf[Throwable]))
}
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TestScheduler
  2. Scheduler
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def advanceTimeBy(time: Duration): Unit
  5. def advanceTimeTo(time: Duration): Unit
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. val asJavaScheduler: schedulers.TestScheduler
    Definition Classes
    TestSchedulerScheduler
  8. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  9. def createWorker: Worker

    Retrieve or create a new rx.lang.scala.Worker that represents serial execution of actions.

    Retrieve or create a new rx.lang.scala.Worker that represents serial execution of actions.

    When work is completed it should be unsubscribed using unsubscribe.

    Work on a rx.lang.scala.Worker is guaranteed to be sequential.

    returns

    Inner representing a serial queue of actions to be executed

    Definition Classes
    Scheduler
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. def now: Long

    returns

    the scheduler's notion of current absolute time in milliseconds.

    Definition Classes
    Scheduler
  20. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  21. def toString(): String
    Definition Classes
    AnyRef → Any
  22. def triggerActions(): Unit
  23. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from Scheduler

Inherited from AnyRef

Inherited from Any

Ungrouped