Search in sources :

Example 56 with UiThreadTest

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();
}
Also used : RecordingObserver(com.jakewharton.rxbinding2.RecordingObserver) LinearLayout(android.widget.LinearLayout) UiThreadTest(android.support.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(android.support.test.annotation.UiThreadTest)

Example 57 with UiThreadTest

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();
}
Also used : MenuItem(android.view.MenuItem) RecordingObserver(com.jakewharton.rxbinding2.RecordingObserver) PopupMenu(android.widget.PopupMenu) Menu(android.view.Menu) Test(org.junit.Test) UiThreadTest(android.support.test.annotation.UiThreadTest) UiThreadTest(android.support.test.annotation.UiThreadTest)

Aggregations

UiThreadTest (android.support.test.annotation.UiThreadTest)57 Test (org.junit.Test)57 Action1 (rx.functions.Action1)17 RecordingObserver (com.jakewharton.rxbinding2.RecordingObserver)15 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)11 AllTypes (io.realm.entities.AllTypes)10 SmallTest (android.support.test.filters.SmallTest)8 Action0 (rx.functions.Action0)7 Activity (android.app.Activity)6 LayoutInflater (android.view.LayoutInflater)6 Menu (android.view.Menu)6 TextInputLayoutActivity (android.support.design.testapp.TextInputLayoutActivity)5 LargeTest (android.support.test.filters.LargeTest)5 MediumTest (android.support.test.filters.MediumTest)5 MenuItem (android.view.MenuItem)5 TabLayoutActions.selectTab (android.support.design.testutils.TabLayoutActions.selectTab)4 AllJavaTypes (io.realm.entities.AllJavaTypes)4 Bundle (android.os.Bundle)3 KeyEvent (android.view.KeyEvent)3 ColorDrawable (android.graphics.drawable.ColorDrawable)2