Skip to content

Commit bce352b

Browse files
committed
add test for subclasses in @EditorAction
1 parent 75b6c1f commit bce352b

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎AndroidAnnotations/functional-test-1-5/res/layout/textviews_injected.xml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,11 @@
6666
android:inputType="text"
6767
/>
6868

69+
<EditText
70+
android:id="@+id/editText4"
71+
android:layout_width="fill_parent"
72+
android:layout_height="wrap_content"
73+
android:inputType="text"
74+
/>
75+
6976
</LinearLayout>

‎AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/EditorActionsHandledActivity.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class EditorActionsHandledActivity extends Activity {
3737
@ViewById
3838
EditText editText1;
3939

40+
EditText passedEditText;
41+
4042
@Override
4143
protected void onCreate(Bundle savedInstanceState) {
4244
super.onCreate(savedInstanceState);
@@ -47,6 +49,11 @@ void editorActionWithFullParameters(TextView tv, int actionId, KeyEvent event) {
4749
actionHandled = true;
4850
}
4951

52+
@EditorAction(R.id.editText4)
53+
void editorActionWithEditTextParameter(EditText et) {
54+
passedEditText = et;
55+
}
56+
5057
@EditorAction(R.id.editText2)
5158
void editorActionInversedParameters(KeyEvent event, int actionId) {
5259
this.actionId = actionId;

‎AndroidAnnotations/functional-test-1-5/src/test/java/org/androidannotations/test15/EditorActionsActivityTest.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ public void testActionHandled() {
5151
assertThat(activity.actionHandled).isTrue();
5252
}
5353

54+
@Test
55+
public void testEditTextPassed() {
56+
assertThat(activity.passedEditText).isNull();
57+
58+
EditText editText = (EditText) activity.findViewById(R.id.editText4);
59+
OnEditorActionListener listener = getOnEditorActionListener(editText);
60+
61+
listener.onEditorAction(editText, 0, null);
62+
63+
assertThat(activity.passedEditText).isSameAs(editText);
64+
}
65+
5466
@Test
5567
public void testActionIdPassed() {
5668
assertThat(activity.actionId).isZero();

0 commit comments

Comments
 (0)