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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations