use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.
the class OnItemLongClickTest 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.performItemLongClick(0);
assertEquals(-1, target.clickedPosition);
unbinder.unbind();
spinner.performItemLongClick(0);
assertEquals(-1, target.clickedPosition);
}
use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.
the class OnLongClickTest method optionalIdPresent.
@UiThreadTest
@Test
public void optionalIdPresent() {
View tree = ViewTree.create(1);
View view1 = tree.findViewById(1);
OptionalId target = new OptionalId();
Unbinder unbinder = ButterKnife.bind(target, tree);
assertEquals(0, target.clicks);
view1.performLongClick();
assertEquals(1, target.clicks);
unbinder.unbind();
view1.performLongClick();
assertEquals(1, target.clicks);
}
use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.
the class OnLongClickTest method returnVoid.
@UiThreadTest
@Test
public void returnVoid() {
View tree = ViewTree.create(1);
View view1 = tree.findViewById(1);
ReturnVoid target = new ReturnVoid();
Unbinder unbinder = ButterKnife.bind(target, tree);
assertEquals(0, target.clicks);
assertTrue(view1.performLongClick());
assertEquals(1, target.clicks);
unbinder.unbind();
view1.performLongClick();
assertEquals(1, target.clicks);
}
use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.
the class OnLongClickTest method visibilities.
@UiThreadTest
@Test
public void visibilities() {
View tree = ViewTree.create(1, 2, 3);
View view1 = tree.findViewById(1);
View view2 = tree.findViewById(2);
View view3 = tree.findViewById(3);
Visibilities target = new Visibilities();
ButterKnife.bind(target, tree);
assertEquals(0, target.clicks);
view1.performLongClick();
assertEquals(1, target.clicks);
view2.performLongClick();
assertEquals(2, target.clicks);
view3.performLongClick();
assertEquals(3, target.clicks);
}
use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.
the class OnLongClickTest method argumentCast.
@UiThreadTest
@Test
public void argumentCast() {
class MyView extends Button implements ArgumentCast.MyInterface {
MyView(Context context) {
super(context);
}
}
View view1 = new MyView(InstrumentationRegistry.getContext());
view1.setId(1);
View view2 = new MyView(InstrumentationRegistry.getContext());
view2.setId(2);
View view3 = new MyView(InstrumentationRegistry.getContext());
view3.setId(3);
View view4 = new MyView(InstrumentationRegistry.getContext());
view4.setId(4);
ViewGroup tree = new FrameLayout(InstrumentationRegistry.getContext());
tree.addView(view1);
tree.addView(view2);
tree.addView(view3);
tree.addView(view4);
ArgumentCast target = new ArgumentCast();
ButterKnife.bind(target, tree);
view1.performLongClick();
assertSame(view1, target.last);
view2.performLongClick();
assertSame(view2, target.last);
view3.performLongClick();
assertSame(view3, target.last);
view4.performLongClick();
assertSame(view4, target.last);
}
Aggregations