use of android.support.test.annotation.UiThreadTest 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();
}
use of android.support.test.annotation.UiThreadTest 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();
}
Aggregations