Search in sources :

Example 76 with Unbinder

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class BindFloatTest method asFloat.

@Test
public void asFloat() {
    Target target = new Target();
    TypedValue value = new TypedValue();
    context.getResources().getValue(R.dimen.twelve_point_two, value, true);
    float expected = value.getFloat();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertThat(target.actual).isEqualTo(expected);
    unbinder.unbind();
    assertThat(target.actual).isEqualTo(expected);
}
Also used : Unbinder(butterknife.Unbinder) TypedValue(android.util.TypedValue) Test(org.junit.Test)

Example 77 with Unbinder

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class OnLongClickTest method simple.

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

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class OnLongClickTest 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.clicks);
    view1.performLongClick();
    assertEquals(1, target.clicks);
    view2.performLongClick();
    assertEquals(2, target.clicks);
    unbinder.unbind();
    view1.performLongClick();
    view2.performLongClick();
    assertEquals(2, 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 79 with Unbinder

use of butterknife.Unbinder 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 80 with Unbinder

use of butterknife.Unbinder 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

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