Skip to content

Commit

Permalink
Merge pull request #1623 from JakeWharton/jw/test/2020-08-07
Browse files Browse the repository at this point in the history
Test OnTouch argument support
  • Loading branch information
JakeWharton committed Aug 7, 2020
2 parents afdad5f + 8e6db6c commit 442e6c2
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,41 @@ static final class Simple {
assertEquals(2, target.touches);
}

static final class Arguments {
int touches = 0;

@OnTouch(1) boolean touch(View v) {
touches++;
return true;
}

@OnTouch(2) boolean touch(View v, MotionEvent event) {
touches++;
return true;
}
}

@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);
}

static final class ReturnVoid {
int touches = 0;

Expand Down

0 comments on commit 442e6c2

Please sign in to comment.