use of com.jakewharton.rxbinding4.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.rxbinding4.RecordingObserver in project RxBinding by JakeWharton.
the class RxActionMenuViewTest method itemClicks.
@Test
@UiThreadTest
public void itemClicks() {
Menu menu = view.getMenu();
MenuItem item1 = menu.add(0, 1, 0, "Hi");
MenuItem item2 = menu.add(0, 2, 0, "Hey");
RecordingObserver<MenuItem> o = new RecordingObserver<>();
RxActionMenuView.itemClicks(view).subscribe(o);
o.assertNoMoreEvents();
menu.performIdentifierAction(2, 0);
assertSame(item2, o.takeNext());
menu.performIdentifierAction(1, 0);
assertSame(item1, o.takeNext());
o.dispose();
menu.performIdentifierAction(2, 0);
o.assertNoMoreEvents();
}
use of com.jakewharton.rxbinding4.RecordingObserver in project RxBinding by JakeWharton.
the class RxPopupMenuTest method itemClicks.
@Test
@UiThreadTest
public void itemClicks() {
Menu menu = view.getMenu();
MenuItem item1 = menu.add(0, 1, 0, "Hi");
MenuItem item2 = menu.add(0, 2, 0, "Hey");
RecordingObserver<MenuItem> o = new RecordingObserver<>();
RxPopupMenu.itemClicks(view).subscribe(o);
o.assertNoMoreEvents();
menu.performIdentifierAction(2, 0);
assertSame(item2, o.takeNext());
menu.performIdentifierAction(1, 0);
assertSame(item1, o.takeNext());
o.dispose();
menu.performIdentifierAction(2, 0);
o.assertNoMoreEvents();
}
use of com.jakewharton.rxbinding4.RecordingObserver in project RxBinding by JakeWharton.
the class RxSlidingPaneLayoutTest method paneOpen.
@Test
public void paneOpen() {
RecordingObserver<Boolean> o = new RecordingObserver<>();
RxSlidingPaneLayout.panelOpens(view).subscribeOn(AndroidSchedulers.mainThread()).subscribe(o);
assertFalse(o.takeNext());
instrumentation.runOnMainSync(new Runnable() {
@Override
public void run() {
view.openPane();
}
});
assertTrue(o.takeNext());
instrumentation.runOnMainSync(new Runnable() {
@Override
public void run() {
view.closePane();
}
});
assertFalse(o.takeNext());
o.dispose();
instrumentation.runOnMainSync(new Runnable() {
@Override
public void run() {
view.openPane();
}
});
o.assertNoMoreEvents();
}
use of com.jakewharton.rxbinding4.RecordingObserver in project RxBinding by JakeWharton.
the class RxSwipeDismissBehaviorTest method dismisses.
@Test
public void dismisses() {
((CoordinatorLayout.LayoutParams) view.getLayoutParams()).setBehavior(new SwipeDismissBehavior());
RecordingObserver<View> o = new RecordingObserver<>();
RxSwipeDismissBehavior.dismisses(view).subscribeOn(AndroidSchedulers.mainThread()).subscribe(o);
// No initial value.
o.assertNoMoreEvents();
onView(withId(1)).perform(swipeRight());
assertEquals(view, o.takeNext());
o.dispose();
onView(withId(1)).perform(swipeRight());
o.assertNoMoreEvents();
}
Aggregations