I am testing if form data is retained or not when back key is pressed and user navigates back to the form Activity.
Expected Flow: Press Register Button -> Goto Form page and fill it up -> Press back button -> Press Register Button -> Verify form data is retained
Actual Flow: Espresso launches Form Page -> Press back button -> App Quits
Espresso start from Form Page because that's how the ActivityRule is defined.
public ActivityTestRule<RegisterActivity> mActivity = new ActivityTestRule<>(RegisterActivity.class);
I tried to startActivity() for the Registration Button page, but when I press back, it navigates back to the empty Form Page.
Intent intent = new Intent(mActivity.getActivity(), RegisterButton.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
oActivity.getActivity().startActivity(intent);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.