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