Search in sources :

Example 16 with UiThreadTest

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

the class OnCheckedChangedTest method optionalIdPresent.

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

Example 17 with UiThreadTest

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

the class OnCheckedChangedTest method visibilities.

@UiThreadTest
@Test
public void visibilities() {
    View tree = ViewTree.create(ToggleButton.class, 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.performClick();
    assertEquals(1, target.clicks);
    view2.performClick();
    assertEquals(2, target.clicks);
    view3.performClick();
    assertEquals(3, target.clicks);
}
Also used : View(android.view.View) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 18 with UiThreadTest

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

the class OnCheckedChangedTest method multipleIds.

@UiThreadTest
@Test
public void multipleIds() {
    View tree = ViewTree.create(ToggleButton.class, 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.clicks);
    view1.performClick();
    assertEquals(1, target.clicks);
    view2.performClick();
    assertEquals(2, target.clicks);
    unbinder.unbind();
    view1.performClick();
    view2.performClick();
    assertEquals(2, target.clicks);
}
Also used : Unbinder(butterknife.Unbinder) View(android.view.View) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 19 with UiThreadTest

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

the class OnCheckedChangedTest method optionalIdAbsent.

@UiThreadTest
@Test
public void optionalIdAbsent() {
    View tree = ViewTree.create(ToggleButton.class, 2);
    View view2 = tree.findViewById(2);
    OptionalId target = new OptionalId();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(0, target.clicks);
    view2.performClick();
    assertEquals(0, target.clicks);
    unbinder.unbind();
    view2.performClick();
    assertEquals(0, target.clicks);
}
Also used : Unbinder(butterknife.Unbinder) View(android.view.View) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 20 with UiThreadTest

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

the class OnCheckedChangedTest method multipleBindings.

@UiThreadTest
@Test
public void multipleBindings() {
    // TODO
    assumeFalse("Not implemented", BuildConfig.FLAVOR.equals("reflect"));
    View tree = ViewTree.create(ToggleButton.class, 1);
    View view1 = tree.findViewById(1);
    MultipleBindings target = new MultipleBindings();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(0, target.clicks);
    view1.performClick();
    assertEquals(2, target.clicks);
    unbinder.unbind();
    view1.performClick();
    assertEquals(2, target.clicks);
}
Also used : Unbinder(butterknife.Unbinder) 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