@Test
public void shouldLaunchUriWithFallbackIfCustomTabIntentFails() throws Exception {
doThrow(ActivityNotFoundException.class)
.doNothing()
.when(context).startActivity(any(Intent.class));
controller.launchUri(uri);
verify(context, new Timeout(MAX_TEST_WAIT_TIME_MS, VerificationModeFactory.times(2))).startActivity(launchIntentCaptor.capture());
List<Intent> intents = launchIntentCaptor.getAllValues();
Intent customTabIntent = intents.get(0);
assertThat(customTabIntent.getAction(), is(Intent.ACTION_VIEW));
assertThat(customTabIntent.getData(), is(uri));
assertThat(customTabIntent, not(hasFlag(Intent.FLAG_ACTIVITY_NO_HISTORY)));
assertThat(customTabIntent.hasExtra(CustomTabsIntent.EXTRA_SESSION), is(true));
assertThat(customTabIntent.hasExtra(CustomTabsIntent.EXTRA_TITLE_VISIBILITY_STATE), is(true));
assertThat(customTabIntent.hasExtra(CustomTabsIntent.EXTRA_TOOLBAR_COLOR), is(false));
assertThat(customTabIntent.getIntExtra(CustomTabsIntent.EXTRA_TITLE_VISIBILITY_STATE, CustomTabsIntent.NO_TITLE), is(CustomTabsIntent.NO_TITLE));
Intent fallbackIntent = intents.get(1);
assertThat(fallbackIntent.getAction(), is(Intent.ACTION_VIEW));
assertThat(fallbackIntent.getData(), is(uri));
assertThat(fallbackIntent, hasFlag(Intent.FLAG_ACTIVITY_NO_HISTORY));
assertThat(fallbackIntent.hasExtra(CustomTabsIntent.EXTRA_SESSION), is(false));
assertThat(fallbackIntent.hasExtra(CustomTabsIntent.EXTRA_TITLE_VISIBILITY_STATE), is(false));
}
CustomTabsControllerTest.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:Auth0.Android
作者:
评论列表
文章目录