@Test
public void takeLastTimedDelayCompletion() {

    TestScheduler scheduler = new TestScheduler();
    PublishSubject<Object> source = PublishSubject.create();
    Observable<Object> result = source.takeLast(1, TimeUnit.SECONDS, scheduler);
    Observer<Object> o = mock(Observer.class);
    InOrder inOrder = inOrder(o);
    result.subscribe(o);
    source.onNext(1); // T: 0ms
    scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS);
    source.onNext(2); // T: 250ms
    scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS);
    source.onNext(3); // T: 500ms
    scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS);
    source.onNext(4); // T: 750ms
    scheduler.advanceTimeBy(250, TimeUnit.MILLISECONDS);
    source.onNext(5); // T: 1000ms
    scheduler.advanceTimeBy(1250, TimeUnit.MILLISECONDS);
    source.onCompleted(); // T: 2250ms
    inOrder.verify(o, times(1)).onCompleted();
    verify(o, never()).onNext(any());
    verify(o, never()).onError(any(Throwable.class));
}