use of androidx.test.annotation.UiThreadTest 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);
}
use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.
the class OnItemSelectedTest method argumentCast.
@UiThreadTest
@Test
public void argumentCast() {
class MySpinner extends TestSpinner implements ArgumentCast.MyInterface {
MySpinner(Context context) {
super(context);
}
}
Context context = InstrumentationRegistry.getContext();
TestSpinner spinner1 = new MySpinner(context);
spinner1.setId(1);
TestSpinner spinner2 = new MySpinner(context);
spinner2.setId(2);
TestSpinner spinner3 = new MySpinner(context);
spinner3.setId(3);
ViewGroup tree = new FrameLayout(context);
tree.addView(spinner1);
tree.addView(spinner2);
tree.addView(spinner3);
ArgumentCast target = new ArgumentCast();
ButterKnife.bind(target, tree);
spinner1.performSelection(0);
assertSame(spinner1, target.last);
spinner2.performSelection(0);
assertSame(spinner2, target.last);
spinner3.performSelection(0);
assertSame(spinner3, target.last);
spinner1.clearSelection();
assertSame(spinner1, target.last);
spinner2.clearSelection();
assertSame(spinner2, target.last);
spinner3.clearSelection();
assertSame(spinner3, target.last);
}
use of androidx.test.annotation.UiThreadTest 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);
}
use of androidx.test.annotation.UiThreadTest 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);
}
use of androidx.test.annotation.UiThreadTest 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);
}
Aggregations