Search in sources :

Example 21 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.

the class OnItemLongClickTest method optionalIdAbsent.

@UiThreadTest
@Test
public void optionalIdAbsent() {
    View tree = ViewTree.create(TestSpinner.class, 2);
    TestSpinner spinner = tree.findViewById(2);
    OptionalId target = new OptionalId();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(-1, target.clickedPosition);
    spinner.performItemLongClick(0);
    assertEquals(-1, target.clickedPosition);
    unbinder.unbind();
    spinner.performItemLongClick(0);
    assertEquals(-1, target.clickedPosition);
}
Also used : Unbinder(butterknife.Unbinder) View(android.view.View) AdapterView(android.widget.AdapterView) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 22 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.

the class OnLongClickTest method optionalIdPresent.

@UiThreadTest
@Test
public void optionalIdPresent() {
    View tree = ViewTree.create(1);
    View view1 = tree.findViewById(1);
    OptionalId target = new OptionalId();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(0, target.clicks);
    view1.performLongClick();
    assertEquals(1, target.clicks);
    unbinder.unbind();
    view1.performLongClick();
    assertEquals(1, target.clicks);
}
Also used : Unbinder(butterknife.Unbinder) TextView(android.widget.TextView) View(android.view.View) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 23 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.

the class OnLongClickTest method returnVoid.

@UiThreadTest
@Test
public void returnVoid() {
    View tree = ViewTree.create(1);
    View view1 = tree.findViewById(1);
    ReturnVoid target = new ReturnVoid();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(0, target.clicks);
    assertTrue(view1.performLongClick());
    assertEquals(1, target.clicks);
    unbinder.unbind();
    view1.performLongClick();
    assertEquals(1, target.clicks);
}
Also used : Unbinder(butterknife.Unbinder) TextView(android.widget.TextView) View(android.view.View) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 24 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.

the class OnLongClickTest method visibilities.

@UiThreadTest
@Test
public void visibilities() {
    View tree = ViewTree.create(1, 2, 3);
    View view1 = tree.findViewById(1);
    View view2 = tree.findViewById(2);
    View view3 = tree.findViewById(3);
    Visibilities target = new Visibilities();
    ButterKnife.bind(target, tree);
    assertEquals(0, target.clicks);
    view1.performLongClick();
    assertEquals(1, target.clicks);
    view2.performLongClick();
    assertEquals(2, target.clicks);
    view3.performLongClick();
    assertEquals(3, target.clicks);
}
Also used : TextView(android.widget.TextView) View(android.view.View) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 25 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.

the class OnLongClickTest method argumentCast.

@UiThreadTest
@Test
public void argumentCast() {
    class MyView extends Button implements ArgumentCast.MyInterface {

        MyView(Context context) {
            super(context);
        }
    }
    View view1 = new MyView(InstrumentationRegistry.getContext());
    view1.setId(1);
    View view2 = new MyView(InstrumentationRegistry.getContext());
    view2.setId(2);
    View view3 = new MyView(InstrumentationRegistry.getContext());
    view3.setId(3);
    View view4 = new MyView(InstrumentationRegistry.getContext());
    view4.setId(4);
    ViewGroup tree = new FrameLayout(InstrumentationRegistry.getContext());
    tree.addView(view1);
    tree.addView(view2);
    tree.addView(view3);
    tree.addView(view4);
    ArgumentCast target = new ArgumentCast();
    ButterKnife.bind(target, tree);
    view1.performLongClick();
    assertSame(view1, target.last);
    view2.performLongClick();
    assertSame(view2, target.last);
    view3.performLongClick();
    assertSame(view3, target.last);
    view4.performLongClick();
    assertSame(view4, target.last);
}
Also used : Context(android.content.Context) Button(android.widget.Button) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) View(android.view.View) 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