use of com.jakewharton.rxbinding4.RecordingObserver in project RxBinding by JakeWharton.
the class RxTabLayoutTest method selectionEventsNoInitial.
@Test
@UiThreadTest
public void selectionEventsNoInitial() {
TabLayout empty = new TabLayout(context);
RecordingObserver<TabLayoutSelectionEvent> o = new RecordingObserver<>();
RxTabLayout.selectionEvents(empty).subscribe(o);
o.assertNoMoreEvents();
}
use of com.jakewharton.rxbinding4.RecordingObserver in project RxBinding by JakeWharton.
the class RxTabLayoutTest method selectionsNoInitial.
@Test
@UiThreadTest
public void selectionsNoInitial() {
TabLayout empty = new TabLayout(context);
RecordingObserver<TabLayout.Tab> o = new RecordingObserver<>();
RxTabLayout.selections(empty).subscribe(o);
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 keys.
@Test
@UiThreadTest
public void keys() {
RecordingObserver<KeyEvent> o = new RecordingObserver<>();
RxView.keys(view).subscribe(o);
o.assertNoMoreEvents();
view.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_R));
KeyEvent event1 = o.takeNext();
assertEquals(KeyEvent.ACTION_DOWN, event1.getAction());
view.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_H));
KeyEvent event2 = o.takeNext();
assertEquals(KeyEvent.KEYCODE_H, event2.getKeyCode());
o.dispose();
view.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_S));
o.assertNoMoreEvents();
}
use of com.jakewharton.rxbinding4.RecordingObserver in project RxBinding by JakeWharton.
the class RxViewTest method focusChanges.
@Test
@UiThreadTest
public void focusChanges() {
// We need a parent which can take focus from our view when it attempts to clear.
LinearLayout parent = new LinearLayout(context);
parent.setFocusable(true);
parent.addView(view);
view.setFocusable(true);
RecordingObserver<Boolean> o = new RecordingObserver<>();
RxView.focusChanges(view).subscribe(o);
assertFalse(o.takeNext());
view.requestFocus();
assertTrue(o.takeNext());
view.clearFocus();
assertFalse(o.takeNext());
o.dispose();
view.requestFocus();
o.assertNoMoreEvents();
}
Aggregations