use of com.jakewharton.rxbinding4.RecordingObserver in project RxBinding by JakeWharton.
the class RxSearchEditTextTest method keyboardDismisses.
@Test
@UiThreadTest
public void keyboardDismisses() {
RecordingObserver<Object> o = new RecordingObserver<>();
RxSearchEditText.keyboardDismisses(view).subscribe(o);
o.assertNoMoreEvents();
KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
view.onKeyPreIme(KeyEvent.KEYCODE_BACK, event);
assertNotNull(o.takeNext());
o.dispose();
view.onKeyPreIme(KeyEvent.KEYCODE_BACK, event);
o.assertNoMoreEvents();
}
use of com.jakewharton.rxbinding4.RecordingObserver in project RxBinding by JakeWharton.
the class RxSnackbarTest method dismisses.
@Test
public void dismisses() {
final Snackbar view = Snackbar.make(parent, "Hey", LENGTH_SHORT);
RecordingObserver<Integer> o = new RecordingObserver<>();
RxSnackbar.dismisses(view).subscribeOn(AndroidSchedulers.mainThread()).subscribe(o);
o.assertNoMoreEvents();
instrumentation.runOnMainSync(() -> view.show());
instrumentation.runOnMainSync(() -> view.dismiss());
assertEquals(DISMISS_EVENT_MANUAL, o.takeNext().intValue());
instrumentation.runOnMainSync(() -> view.show());
o.dispose();
instrumentation.runOnMainSync(() -> view.dismiss());
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 RxToolbarTest 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<>();
RxToolbar.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 RxViewTest method longClicks.
@Test
@UiThreadTest
public void longClicks() {
// We need a parent because long presses delegate to the parent.
LinearLayout parent = new LinearLayout(context) {
@Override
public boolean showContextMenuForChild(View originalView) {
return true;
}
};
parent.addView(view);
RecordingObserver<Object> o = new RecordingObserver<>();
RxView.longClicks(view).subscribe(o);
// No initial value.
o.assertNoMoreEvents();
view.performLongClick();
assertNotNull(o.takeNext());
view.performLongClick();
assertNotNull(o.takeNext());
o.dispose();
view.performLongClick();
o.assertNoMoreEvents();
}
Aggregations