Search in sources :

Example 36 with UiThreadTest

use of androidx.test.annotation.UiThreadTest 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();
}
Also used : KeyEvent(android.view.KeyEvent) RecordingObserver(com.jakewharton.rxbinding4.RecordingObserver) UiThreadTest(androidx.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 37 with UiThreadTest

use of androidx.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.rxbinding4.RecordingObserver) PopupMenu(android.widget.PopupMenu) Menu(android.view.Menu) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 38 with UiThreadTest

use of androidx.test.annotation.UiThreadTest 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();
}
Also used : MenuItem(android.view.MenuItem) RecordingObserver(com.jakewharton.rxbinding4.RecordingObserver) Menu(android.view.Menu) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 39 with UiThreadTest

use of androidx.test.annotation.UiThreadTest 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();
}
Also used : RecordingObserver(com.jakewharton.rxbinding4.RecordingObserver) View(android.view.View) LinearLayout(android.widget.LinearLayout) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 40 with UiThreadTest

use of androidx.test.annotation.UiThreadTest 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();
}
Also used : RecordingObserver(com.jakewharton.rxbinding4.RecordingObserver) MotionEvent(android.view.MotionEvent) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Aggregations

UiThreadTest (androidx.test.annotation.UiThreadTest)136 Test (org.junit.Test)129 View (android.view.View)41 Unbinder (butterknife.Unbinder)31 Context (android.content.Context)23 AdapterView (android.widget.AdapterView)18 TextView (android.widget.TextView)15 RecordingObserver (com.jakewharton.rxbinding4.RecordingObserver)15 MediumTest (androidx.test.filters.MediumTest)14 Intent (android.content.Intent)10 SubscriptionInfo (android.telephony.SubscriptionInfo)10 CountDownLatch (java.util.concurrent.CountDownLatch)10 LocalPSMP (de.danoeh.antennapod.core.service.playback.LocalPSMP)9 PlaybackServiceMediaPlayer (de.danoeh.antennapod.playback.base.PlaybackServiceMediaPlayer)9 Slice (androidx.slice.Slice)8 Playable (de.danoeh.antennapod.model.playback.Playable)8 AssertionFailedError (junit.framework.AssertionFailedError)8 Before (org.junit.Before)7 ViewGroup (android.view.ViewGroup)6 FrameLayout (android.widget.FrameLayout)6