Issue
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);
Solution
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
Answered By - Prabin Timsina
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.