Search in sources :

Example 1 with ViewScrollChangeEvent

use of com.jakewharton.rxbinding4.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)

Example 2 with ViewScrollChangeEvent

use of com.jakewharton.rxbinding4.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.getView());
    assertEquals(1000, event.getScrollX());
    assertEquals(0, event.getScrollY());
    assertEquals(0, event.getOldScrollX());
    assertEquals(0, event.getOldScrollY());
    o.dispose();
    view.scrollTo(2000, 0);
    o.assertNoMoreEvents();
}
Also used : ViewScrollChangeEvent(com.jakewharton.rxbinding4.view.ViewScrollChangeEvent) RecordingObserver(com.jakewharton.rxbinding4.RecordingObserver) UiThreadTest(androidx.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Aggregations

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