I'm just trying to test a submit button at the end of a form.
FormAndroidTest.java:
@Test
public void testSubmitButton() throws Exception {
// Execute
onView(withId(R.id.btnSaveFeedback))
.perform(click());
}
The click()
is called, I can see it performed the click in the app, but the call never comes back (until it times out).
I've narrowed it down to being caused by the startActivity
call in the click handler:
FormActivity.java:
public void onSubmitClicked(View view) {
...
startActivity(new Intent(this, NextActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME));
...
}
I've traced it down to the call sendUp()
call in Espresso's Tap.java failing:
private static Tapper.Status sendSingleTap(...) {
...
DownResultHolder res = MotionEvents.sendDown(uiController, coordinates, precision);
try {
if (!MotionEvents.sendUp(uiController, res.down)) { <-- THIS TIMES OUT
Log.d(TAG, "Injection of up event as part of the click failed. Send cancel event.");
MotionEvents.sendCancel(uiController, res.down);
return Tapper.Status.FAILURE;
...
}
Within that it's the uiController.injectMotionEvent(motionEvent);
which loops until the injection has completed, which in this case it never does and times out.
I'm assuming it must have something to do with my threads not settling, but I don't see why or how to resolve it. I've seen a few related threads, but the given answers don't seem to solve my exact problem.
- Espresso test stuck/inactive after perform(click()) on button in ViewAnimator - I've already disabled all animations, and manually trying to manipulate the screen doesn't help.
- Android Espresso Test gets stuck at perform(click()); - Same answer of manually swiping given, doesn't help.
Thanks