Search in sources :

Example 31 with Unbinder

use of butterknife.Unbinder in project butterknife by JakeWharton.

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

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class OnItemSelectedTest method optionalIdAbsent.

@UiThreadTest
@Test
public void optionalIdAbsent() {
    View tree = ViewTree.create(TestSpinner.class, 2);
    TestSpinner spinner = tree.findViewById(2);
    OptionalId target = new OptionalId();
    target.selectedPosition = 1;
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(1, target.selectedPosition);
    spinner.performSelection(0);
    assertEquals(1, target.selectedPosition);
    spinner.clearSelection();
    assertEquals(1, target.selectedPosition);
    unbinder.unbind();
    spinner.performSelection(1);
    assertEquals(1, target.selectedPosition);
    spinner.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 33 with Unbinder

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class OnTouchTest method arguments.

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

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class OnTouchTest 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.touches);
    assertTrue(performTouch(view1));
    assertEquals(1, target.touches);
    target.returnValue = false;
    assertFalse(performTouch(view1));
    assertEquals(2, target.touches);
    unbinder.unbind();
    performTouch(view1);
    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 35 with Unbinder

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

Aggregations

Unbinder (butterknife.Unbinder)86 Test (org.junit.Test)70 View (android.view.View)55 UiThreadTest (androidx.test.annotation.UiThreadTest)31 TextView (android.widget.TextView)23 Bundle (android.os.Bundle)15 LayoutInflater (android.view.LayoutInflater)15 AdapterView (android.widget.AdapterView)15 BindView (butterknife.BindView)15 ButterKnife (butterknife.ButterKnife)15 ViewGroup (android.view.ViewGroup)14 R (com.simplecity.amp_library.R)10 List (java.util.List)10 Inject (javax.inject.Inject)9 Nullable (android.support.annotation.Nullable)8 MenuItem (android.view.MenuItem)8 Aesthetic (com.afollestad.aesthetic.Aesthetic)8 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 Rx.distinctToMainThread (com.afollestad.aesthetic.Rx.distinctToMainThread)6 Song (com.simplecity.amp_library.model.Song)6