PopupBridgeTest.java 文件源码

java
阅读 35 收藏 0 点赞 0 评论 0

项目:popup-bridge-android 作者:
@Test
public void open_launchesActivityWithUrl() {
    Context context = mock(Context.class);
    when(context.getPackageName()).thenReturn("com.braintreepayments.popupbridge");
    PackageManager packageManager = mock(PackageManager.class);
    when(packageManager.queryIntentActivities(any(Intent.class), anyInt()))
            .thenReturn(Collections.singletonList(new ResolveInfo()));
    when(context.getPackageManager()).thenReturn(packageManager);
    mActivity = spy(Robolectric.setupActivity(TestActivity.class));
    when(mActivity.getApplicationContext()).thenReturn(context);
    mWebView = new MockWebView(mActivity);
    mPopupBridge = PopupBridge.newInstance(mActivity, mWebView);

    mPopupBridge.open("someUrl://");

    ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
    verify(context).startActivity(captor.capture());
    Uri intentUri = captor.getValue().getData();
    assertEquals(intentUri.toString(), "someUrl://");
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号