Search in sources :

Example 1 with ViewScrollChangeEvent

use of com.jakewharton.rxbinding2.view.ViewScrollChangeEvent in project RxBinding by JakeWharton.

the class RxNestedScrollViewTest method scrollChangeEvents.

@Test
@UiThreadTest
public void scrollChangeEvents() {
    RecordingObserver<ViewScrollChangeEvent> o = new RecordingObserver<>();
    RxNestedScrollView.scrollChangeEvents(view).subscribe(o);
    o.assertNoMoreEvents();
    view.scrollTo(1000, 0);
    ViewScrollChangeEvent event = o.takeNext();
    assertSame(view, event.view());
    assertEquals(1000, event.scrollX());
    assertEquals(0, event.scrollY());
    assertEquals(0, event.oldScrollX());
    assertEquals(0, event.oldScrollY());
    o.dispose();
    view.scrollTo(2000, 0);
    o.assertNoMoreEvents();
}
Also used : ViewScrollChangeEvent(com.jakewharton.rxbinding2.view.ViewScrollChangeEvent) RecordingObserver(com.jakewharton.rxbinding2.RecordingObserver) UiThreadTest(android.support.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(android.support.test.annotation.UiThreadTest)

Aggregations

UiThreadTest (android.support.test.annotation.UiThreadTest)1 RecordingObserver (com.jakewharton.rxbinding2.RecordingObserver)1 ViewScrollChangeEvent (com.jakewharton.rxbinding2.view.ViewScrollChangeEvent)1 Test (org.junit.Test)1