Search in sources :

Example 81 with Unbinder

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class OnItemLongClickTest method multipleIds.

@UiThreadTest
@Test
public void multipleIds() {
    View tree = ViewTree.create(TestSpinner.class, 1, 2);
    TestSpinner spinner1 = tree.findViewById(1);
    TestSpinner spinner2 = tree.findViewById(2);
    MultipleIds target = new MultipleIds();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(-1, target.clickedPosition);
    spinner1.performItemLongClick(0);
    assertEquals(0, target.clickedPosition);
    spinner2.performItemLongClick(1);
    assertEquals(1, target.clickedPosition);
    unbinder.unbind();
    spinner1.performItemLongClick(2);
    assertEquals(1, target.clickedPosition);
    spinner2.performItemLongClick(2);
    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 82 with Unbinder

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class OnItemLongClickTest method simple.

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

Aggregations

Unbinder (butterknife.Unbinder)82 Test (org.junit.Test)70 View (android.view.View)52 UiThreadTest (androidx.test.annotation.UiThreadTest)31 TextView (android.widget.TextView)21 AdapterView (android.widget.AdapterView)15 BindView (butterknife.BindView)13 Bundle (android.os.Bundle)12 LayoutInflater (android.view.LayoutInflater)12 ViewGroup (android.view.ViewGroup)12 ButterKnife (butterknife.ButterKnife)12 R (com.simplecity.amp_library.R)10 List (java.util.List)9 Nullable (android.support.annotation.Nullable)8 Aesthetic (com.afollestad.aesthetic.Aesthetic)8 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)8 Inject (javax.inject.Inject)8 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 RecyclerView (android.support.v7.widget.RecyclerView)6 Rx.distinctToMainThread (com.afollestad.aesthetic.Rx.distinctToMainThread)6