WebIntent extends BaseIntent<WebIntent> { public WebIntent url(@NonNull final String url) { if (WEB_URL_MATCHER.reset(url).matches()) { if (HTTP_FORMAT_MATCHER.reset(url).matches()) { this.url = url; } else { this.url = HTTP_PREFIX + url; } } return this; }  WebIntent url(@NonNull final String url); @NonNull String url(); static final Matcher WEB_URL_MATCHER; }
@Test public void testInstantiation() { final WebIntent intent = new WebIntent(); assertThat(intent.url(), is(notNullValue())); assertThat(intent.url().length(), is(0)); }
@Test public void testUrlText() { final WebIntent intent = new WebIntent(); intent.url("http: assertThat(intent.url(), is("http: }
@Test public void testUrlTextWithoutPrefix() { final WebIntent intent = new WebIntent(); intent.url("www.google.com"); assertThat(intent.url(), is("http: }
@Test public void testUrlTextWithInvalidValue() { final WebIntent intent = new WebIntent(); intent.url("google"); assertThat(intent.url(), is("")); }
@Test public void testBuild() { final WebIntent webIntent = new WebIntent(); webIntent.url("inbox.google.com"); final Intent intent = webIntent.build(context); assertThat(intent, is(not(CoreMatchers.nullValue()))); assertThat(intent.getAction(), is(Intent.ACTION_VIEW)); assertThat(intent.getData(), is(Uri.parse("http: }