我有这个测试
@Test
public void theTimeViewMustBeDisplayedAfterRecordButtonClick(){
onView(withId(R.id.btn_record)).perform(click());
onView(withId(R.id.tempo)).check(matches(isDisplayed()));
}
但我的R.id.btn_record
有这个OnTouchListener
public View.OnTouchListener getOnTouchListener(){
return new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
status.setText(R.string.record_status_message);
status.setTextColor(Color.BLUE);
tempo.setAnimation(getPulse());
presenter.startRecord(getActivity().getFilesDir().getPath(), UUID.randomUUID().toString());
return true;
case MotionEvent.ACTION_UP:
status.setText(R.string.default_status_message);
status.setTextColor(Color.BLACK);
tempo.clearAnimation();
presenter.stopRecord();
return true;
}
return false;
}
};
}
当我运行我的测试时,此测试会锁定此行
onView(withId(R.id.btn_record)).perform(click());
并没有任何反应,但如果删除OnTouchListener,测试运行正常,为什么?任何的想法?
完整代码:https://github.com/faeldix/faeldix-android-microphone-mvp