Issue
I want to write espresso scripts to test deep linking and have no idea how to begin with. Looking for solutions that'll help me get more idea, possibly step by step procedure on how to get started.
For ex : I am looking for a scenario like you get a link in gmail tapping on which user should be directed towards the mobile app. How do I get started to test something like this using espresso ?
Thanks in advance.
Solution
Start with an activity rule
@Rule
public ActivityTestRule<YourAppMainActivity> mActivityRule =
new ActivityTestRule<>(YourAppMainActivity.class, true, false);
Then you want something to parse the uri from the link and return the intent
String uri = "http://your_deep_link_from_gmail";
private Intent getDeepLinkIntent(String uri){
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(uri))
.setPackage(getTargetContext().getPackageName());
return intent;
}
Then you want the activity rule to launch the intent
Intent intent = getDeepLinkIntent(deepLinkUri);
mActivityRule.launchActivity(intent);
Answered By - HRVHackers
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.