Search in sources :

Example 71 with Unbinder

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

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

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class OnItemSelectedTest 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.selectedPosition);
    spinner.performSelection(0);
    assertEquals(0, target.selectedPosition);
    spinner.clearSelection();
    assertEquals(-1, target.selectedPosition);
    spinner.performSelection(1);
    unbinder.unbind();
    spinner.performSelection(0);
    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 74 with Unbinder

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class OnItemSelectedTest method multipleBindings.

@UiThreadTest
@Test
public void multipleBindings() {
    View tree = ViewTree.create(TestSpinner.class, 1);
    TestSpinner spinner = tree.findViewById(1);
    MultipleBindings target = new MultipleBindings();
    Unbinder unbinder = ButterKnife.bind(target, tree);
    assertEquals(-1, target.selectedPosition1);
    assertEquals(-1, target.selectedPosition2);
    spinner.performSelection(0);
    assertEquals(0, target.selectedPosition1);
    assertEquals(0, target.selectedPosition2);
    spinner.clearSelection();
    assertEquals(-1, target.selectedPosition1);
    assertEquals(-1, target.selectedPosition2);
    spinner.performSelection(1);
    unbinder.unbind();
    spinner.performSelection(0);
    assertEquals(1, target.selectedPosition1);
    assertEquals(1, target.selectedPosition2);
    spinner.clearSelection();
    assertEquals(1, target.selectedPosition1);
    assertEquals(1, target.selectedPosition2);
}
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 75 with Unbinder

use of butterknife.Unbinder in project butterknife by JakeWharton.

the class OnItemSelectedTest 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.selectedPosition);
    spinner.performSelection(0);
    assertEquals(0, target.selectedPosition);
    spinner.clearSelection();
    assertEquals(-1, target.selectedPosition);
    spinner.performSelection(1);
    unbinder.unbind();
    spinner.performSelection(0);
    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)

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