Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/main/java/io/reactivex/subscribers/TestSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

import org.reactivestreams.*;

import io.reactivex.annotations.Experimental;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.internal.fuseable.QueueSubscription;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import io.reactivex.internal.util.*;
import io.reactivex.internal.util.ExceptionHelper;
import io.reactivex.observers.BaseTestConsumer;

/**
Expand Down Expand Up @@ -403,6 +404,18 @@ public final TestSubscriber<T> assertOf(Consumer<? super TestSubscriber<T>> chec
return this;
}

/**
* Calls {@link #request(long)} and returns this.
* @param n the request amount
* @return this
* @since 2.0.1 - experimental
*/
@Experimental
public final TestSubscriber<T> requestMore(long n) {
request(n);
return this;
}

/**
* A subscriber that ignores all events and does not report errors.
*/
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/io/reactivex/subscribers/TestSubscriberTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1707,4 +1707,16 @@ public void assertValueAtInvalidIndex() {
}
});
}

@Test
public void requestMore() {
Flowable.range(1, 5)
.test(0)
.requestMore(1)
.assertValue(1)
.requestMore(2)
.assertValues(1, 2, 3)
.requestMore(3)
.assertResult(1, 2, 3, 4, 5);
}
}