Search in sources :

Example 91 with UiThreadTest

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

the class OnItemClickTest 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.performItemClick(0);
    assertEquals(-1, target.clickedPosition);
    unbinder.unbind();
    spinner.performItemClick(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 92 with UiThreadTest

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

the class OnItemSelectedTest method multipleIdPermutation.

@UiThreadTest
@Test
public void multipleIdPermutation() {
    View tree = ViewTree.create(TestSpinner.class, 1, 2, 3);
    TestSpinner spinner1 = tree.findViewById(1);
    TestSpinner spinner2 = tree.findViewById(2);
    TestSpinner spinner3 = tree.findViewById(3);
    MultipleIdPermutation target = new MultipleIdPermutation();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(-1, target.selectedPosition);
    spinner1.performSelection(0);
    assertEquals(0, target.selectedPosition);
    spinner1.clearSelection();
    assertEquals(-1, target.selectedPosition);
    spinner2.performSelection(0);
    assertEquals(0, target.selectedPosition);
    spinner2.clearSelection();
    assertEquals(0, target.selectedPosition);
    spinner3.performSelection(1);
    assertEquals(0, target.selectedPosition);
    spinner3.clearSelection();
    assertEquals(-1, target.selectedPosition);
    spinner1.performSelection(1);
    unbinder.unbind();
    spinner1.performSelection(0);
    assertEquals(1, target.selectedPosition);
    spinner2.performSelection(0);
    assertEquals(1, target.selectedPosition);
    spinner3.performSelection(0);
    assertEquals(1, target.selectedPosition);
    spinner1.clearSelection();
    assertEquals(1, target.selectedPosition);
    spinner2.clearSelection();
    assertEquals(1, target.selectedPosition);
    spinner3.clearSelection();
    assertEquals(1, target.selectedPosition);
}
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 93 with UiThreadTest

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

the class OnItemLongClickTest method returnVoid.

@UiThreadTest
@Test
public void returnVoid() {
    View tree = ViewTree.create(TestSpinner.class, 1);
    TestSpinner spinner = tree.findViewById(1);
    ReturnVoid target = new ReturnVoid();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(-1, target.clickedPosition);
    assertTrue(spinner.performItemLongClick(0));
    assertEquals(0, target.clickedPosition);
    unbinder.unbind();
    spinner.performItemLongClick(1);
    assertEquals(0, 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 94 with UiThreadTest

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

the class OnItemLongClickTest method visibilities.

@UiThreadTest
@Test
public void visibilities() {
    View tree = ViewTree.create(TestSpinner.class, 1, 2, 3);
    TestSpinner spinner1 = tree.findViewById(1);
    TestSpinner spinner2 = tree.findViewById(2);
    TestSpinner spinner3 = tree.findViewById(3);
    Visibilities target = new Visibilities();
    ButterKnife.bind(target, tree);
    assertEquals(-1, target.clickedPosition);
    spinner1.performItemLongClick(0);
    assertEquals(0, target.clickedPosition);
    spinner2.performItemLongClick(1);
    assertEquals(1, target.clickedPosition);
    spinner3.performItemLongClick(2);
    assertEquals(2, target.clickedPosition);
}
Also used : View(android.view.View) AdapterView(android.widget.AdapterView) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 95 with UiThreadTest

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

the class OnItemLongClickTest method optionalIdPresent.

@UiThreadTest
@Test
public void optionalIdPresent() {
    View tree = ViewTree.create(TestSpinner.class, 1);
    TestSpinner spinner = tree.findViewById(1);
    OptionalId target = new OptionalId();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(-1, target.clickedPosition);
    spinner.performItemLongClick(0);
    assertEquals(0, target.clickedPosition);
    unbinder.unbind();
    spinner.performItemLongClick(1);
    assertEquals(0, 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)

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