Dar*_*han 5 android deep-linking android-espresso
我想编写浓缩咖啡脚本来测试深度链接,但不知道如何开始。寻找能够帮助我获得更多想法的解决方案,可能是有关如何开始的分步过程。
例如:我正在寻找一种场景,例如您在 Gmail 中获得一个链接,点击该链接应将哪个用户定向到移动应用程序。我如何开始使用浓缩咖啡测试类似的东西?
提前致谢。
从活动规则开始
@Rule
public ActivityTestRule<YourAppMainActivity> mActivityRule =
new ActivityTestRule<>(YourAppMainActivity.class, true, false);
Run Code Online (Sandbox Code Playgroud)
然后你需要一些东西来解析链接中的 uri 并返回意图
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;
}
Run Code Online (Sandbox Code Playgroud)
然后您希望活动规则启动意图
Intent intent = getDeepLinkIntent(deepLinkUri);
mActivityRule.launchActivity(intent);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5622 次 |
| 最近记录: |