use of com.jakewharton.rxbinding2.RecordingObserver 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();
}
use of com.jakewharton.rxbinding2.RecordingObserver in project RxBinding by JakeWharton.
the class RxSlidingPaneLayoutTest method slides.
@Test
public void slides() {
RecordingObserver<Float> o1 = new RecordingObserver<>();
RxSlidingPaneLayout.panelSlides(view).subscribeOn(AndroidSchedulers.mainThread()).subscribe(o1);
o1.assertNoMoreEvents();
instrumentation.runOnMainSync(new Runnable() {
@Override
public void run() {
view.openPane();
}
});
instrumentation.waitForIdleSync();
assertTrue(o1.takeNext() > 0f);
o1.dispose();
o1.assertNoMoreEvents();
RecordingObserver<Float> o2 = new RecordingObserver<>();
RxSlidingPaneLayout.panelSlides(view).subscribeOn(AndroidSchedulers.mainThread()).subscribe(o2);
o2.assertNoMoreEvents();
instrumentation.runOnMainSync(new Runnable() {
@Override
public void run() {
view.closePane();
}
});
instrumentation.waitForIdleSync();
assertTrue(o2.takeNext() < 1f);
o2.dispose();
o2.assertNoMoreEvents();
}
use of com.jakewharton.rxbinding2.RecordingObserver in project RxBinding by JakeWharton.
the class RxViewTest method touches.
@Test
@UiThreadTest
public void touches() {
RecordingObserver<MotionEvent> o = new RecordingObserver<>();
RxView.touches(view).subscribe(o);
o.assertNoMoreEvents();
view.dispatchTouchEvent(motionEventAtPosition(view, ACTION_DOWN, 0, 50));
MotionEvent event1 = o.takeNext();
assertEquals(ACTION_DOWN, event1.getAction());
view.dispatchTouchEvent(motionEventAtPosition(view, ACTION_MOVE, 1, 50));
MotionEvent event2 = o.takeNext();
assertEquals(ACTION_MOVE, event2.getAction());
o.dispose();
view.dispatchTouchEvent(motionEventAtPosition(view, ACTION_UP, 1, 50));
o.assertNoMoreEvents();
}
use of com.jakewharton.rxbinding2.RecordingObserver in project RxBinding by JakeWharton.
the class RxViewTest method hovers.
@Test
@UiThreadTest
public void hovers() {
RecordingObserver<MotionEvent> o = new RecordingObserver<>();
RxView.hovers(view).subscribe(o);
o.assertNoMoreEvents();
view.dispatchGenericMotionEvent(hoverMotionEventAtPosition(view, ACTION_HOVER_ENTER, 0, 50));
MotionEvent event1 = o.takeNext();
assertEquals(ACTION_HOVER_ENTER, event1.getAction());
view.dispatchGenericMotionEvent(hoverMotionEventAtPosition(view, ACTION_HOVER_MOVE, 1, 50));
MotionEvent event2 = o.takeNext();
assertEquals(ACTION_HOVER_MOVE, event2.getAction());
o.dispose();
view.dispatchGenericMotionEvent(hoverMotionEventAtPosition(view, ACTION_HOVER_EXIT, 1, 50));
o.assertNoMoreEvents();
}
use of com.jakewharton.rxbinding2.RecordingObserver in project RxBinding by JakeWharton.
the class RxAdapterViewTest method itemClicks.
@Test
public void itemClicks() {
RecordingObserver<Integer> o = new RecordingObserver<>();
RxAdapterView.itemClicks(listView).subscribeOn(AndroidSchedulers.mainThread()).subscribe(o);
o.assertNoMoreEvents();
instrumentation.runOnMainSync(new Runnable() {
@Override
public void run() {
listView.performItemClick(listView.getChildAt(2), 2, 2);
}
});
assertEquals(2, o.takeNext().intValue());
instrumentation.runOnMainSync(new Runnable() {
@Override
public void run() {
listView.performItemClick(listView.getChildAt(0), 0, 0);
}
});
assertEquals(0, o.takeNext().intValue());
o.dispose();
instrumentation.runOnMainSync(new Runnable() {
@Override
public void run() {
listView.performItemClick(listView.getChildAt(1), 1, 1);
}
});
o.assertNoMoreEvents();
}
Aggregations