Search in sources :

Example 11 with UiThreadTest

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

the class OnTouchTest method argumentCast.

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

        MyView(Context context) {
            super(context);
        }
    }
    Context context = InstrumentationRegistry.getContext();
    View view1 = new MyView(context);
    view1.setId(1);
    View view2 = new MyView(context);
    view2.setId(2);
    View view3 = new MyView(context);
    view3.setId(3);
    View view4 = new MyView(context);
    view4.setId(4);
    ViewGroup tree = new FrameLayout(context);
    tree.addView(view1);
    tree.addView(view2);
    tree.addView(view3);
    tree.addView(view4);
    ArgumentCast target = new ArgumentCast();
    ButterKnife.bind(target, tree);
    performTouch(view1);
    assertSame(view1, target.last);
    performTouch(view2);
    assertSame(view2, target.last);
    performTouch(view3);
    assertSame(view3, target.last);
    performTouch(view4);
    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)

Example 12 with UiThreadTest

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

the class OnTouchTest method multipleIds.

@UiThreadTest
@Test
public void multipleIds() {
    View tree = ViewTree.create(1, 2);
    View view1 = tree.findViewById(1);
    View view2 = tree.findViewById(2);
    MultipleIds target = new MultipleIds();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(0, target.touches);
    performTouch(view1);
    assertEquals(1, target.touches);
    performTouch(view2);
    assertEquals(2, target.touches);
    unbinder.unbind();
    performTouch(view1);
    performTouch(view2);
    assertEquals(2, target.touches);
}
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 13 with UiThreadTest

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

the class OnTouchTest method optionalIdAbsent.

@UiThreadTest
@Test
public void optionalIdAbsent() {
    View tree = ViewTree.create(2);
    View view2 = tree.findViewById(2);
    OptionalId target = new OptionalId();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(0, target.touches);
    performTouch(view2);
    assertEquals(0, target.touches);
    unbinder.unbind();
    performTouch(view2);
    assertEquals(0, target.touches);
}
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 14 with UiThreadTest

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

the class OnTouchTest 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.touches);
    assertTrue(performTouch(view1));
    assertEquals(1, target.touches);
    unbinder.unbind();
    performTouch(view1);
    assertEquals(1, target.touches);
}
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 15 with UiThreadTest

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

the class OnTouchTest 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.touches);
    performTouch(view1);
    assertEquals(1, target.touches);
    unbinder.unbind();
    performTouch(view1);
    assertEquals(1, target.touches);
}
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)

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