use of butterknife.Unbinder in project butterknife by JakeWharton.
the class BindColorTest method asInt.
@Test
public void asInt() {
IntTarget target = new IntTarget();
int expected = context.getResources().getColor(R.color.red);
Unbinder unbinder = ButterKnife.bind(target, tree);
assertThat(target.actual).isEqualTo(expected);
unbinder.unbind();
assertThat(target.actual).isEqualTo(expected);
}
use of butterknife.Unbinder in project butterknife by JakeWharton.
the class BindStringTest method simpleInt.
@Test
public void simpleInt() {
Target target = new Target();
String expected = context.getString(R.string.hey);
Unbinder unbinder = ButterKnife.bind(target, tree);
assertThat(target.actual).isEqualTo(expected);
unbinder.unbind();
assertThat(target.actual).isEqualTo(expected);
}
use of butterknife.Unbinder in project butterknife by JakeWharton.
the class OnClickTest method multipleBindings.
@Test
public void multipleBindings() {
// TODO
assumeFalse("Not implemented", BuildConfig.FLAVOR.equals("reflect"));
View tree = ViewTree.create(1);
View view1 = tree.findViewById(1);
MultipleBindings target = new MultipleBindings();
Unbinder unbinder = ButterKnife.bind(target, tree);
assertEquals(0, target.clicks);
instrumentation.runOnMainSync(() -> {
view1.performClick();
assertEquals(2, target.clicks);
});
instrumentation.runOnMainSync(() -> {
unbinder.unbind();
view1.performClick();
assertEquals(2, target.clicks);
});
}
use of butterknife.Unbinder in project butterknife by JakeWharton.
the class OnClickTest method simple.
@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);
instrumentation.runOnMainSync(() -> {
view1.performClick();
assertEquals(1, target.clicks);
});
instrumentation.runOnMainSync(() -> {
unbinder.unbind();
view1.performClick();
assertEquals(1, target.clicks);
});
}
use of butterknife.Unbinder in project butterknife by JakeWharton.
the class OnClickTest method multipleIds.
@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);
instrumentation.runOnMainSync(() -> {
view1.performClick();
assertEquals(1, target.clicks);
});
instrumentation.runOnMainSync(() -> {
view2.performClick();
assertEquals(2, target.clicks);
});
instrumentation.runOnMainSync(() -> {
unbinder.unbind();
view1.performClick();
view2.performClick();
assertEquals(2, target.clicks);
});
}
Aggregations