use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.
the class OnItemLongClickTest 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.performItemLongClick(0);
assertSame(spinner1, target.last);
spinner2.performItemLongClick(0);
assertSame(spinner2, target.last);
spinner3.performItemLongClick(0);
assertSame(spinner3, target.last);
}
use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.
the class OnItemLongClickTest method multipleIds.
@UiThreadTest
@Test
public void multipleIds() {
View tree = ViewTree.create(TestSpinner.class, 1, 2);
TestSpinner spinner1 = tree.findViewById(1);
TestSpinner spinner2 = tree.findViewById(2);
MultipleIds target = new MultipleIds();
Unbinder unbinder = ButterKnife.bind(target, tree);
assertEquals(-1, target.clickedPosition);
spinner1.performItemLongClick(0);
assertEquals(0, target.clickedPosition);
spinner2.performItemLongClick(1);
assertEquals(1, target.clickedPosition);
unbinder.unbind();
spinner1.performItemLongClick(2);
assertEquals(1, target.clickedPosition);
spinner2.performItemLongClick(2);
assertEquals(1, target.clickedPosition);
}
use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.
the class OnItemLongClickTest 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);
assertTrue(spinner.performItemLongClick(0));
assertEquals(0, target.clickedPosition);
target.returnValue = false;
assertFalse(spinner.performItemLongClick(1));
assertEquals(1, target.clickedPosition);
unbinder.unbind();
spinner.performItemLongClick(2);
assertEquals(1, target.clickedPosition);
}
use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.
the class OnLongClickTest 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.clicks);
assertTrue(view1.performLongClick());
assertEquals(1, target.clicks);
target.returnValue = false;
assertFalse(view1.performLongClick());
assertEquals(2, target.clicks);
unbinder.unbind();
view1.performLongClick();
assertEquals(2, target.clicks);
}
use of androidx.test.annotation.UiThreadTest in project butterknife by JakeWharton.
the class OnLongClickTest 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.clicks);
view1.performLongClick();
assertEquals(1, target.clicks);
view2.performLongClick();
assertEquals(2, target.clicks);
unbinder.unbind();
view1.performLongClick();
view2.performLongClick();
assertEquals(2, target.clicks);
}
Aggregations