Exemplo n.º 1
0
  @Test
  public void intentForNativeBrowserScheme_shouldProperlyHandleEncodedUrls()
      throws UrlParseException {
    Intent intent;

    intent =
        Intents.intentForNativeBrowserScheme(
            Uri.parse("mopubnativebrowser://navigate?url=https%3A%2F%2Fwww.example.com"));
    assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
    assertThat(intent.getDataString()).isEqualTo("https://www.example.com");

    intent =
        Intents.intentForNativeBrowserScheme(
            Uri.parse("mopubnativebrowser://navigate?url=https://www.example.com/?query=1&two=2"));
    assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
    assertThat(intent.getDataString()).isEqualTo("https://www.example.com/?query=1");

    intent =
        Intents.intentForNativeBrowserScheme(
            Uri.parse(
                "mopubnativebrowser://navigate?url=https%3A%2F%2Fwww.example.com%2F%3Fquery%3D1%26two%3D2"));
    assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
    assertThat(intent.getDataString()).isEqualTo("https://www.example.com/?query=1&two=2");
  }
Exemplo n.º 2
0
 @Test(expected = UrlParseException.class)
 public void intentForNativeBrowserScheme_whenUrlParameterMissing_shouldThrowException()
     throws UrlParseException {
   Intents.intentForNativeBrowserScheme(Uri.parse("mopubnativebrowser://navigate"));
 }
Exemplo n.º 3
0
 @Test(expected = UrlParseException.class)
 public void intentForNativeBrowserScheme_whenNotNavigate_shouldThrowException()
     throws UrlParseException {
   Intents.intentForNativeBrowserScheme(
       Uri.parse("mopubnativebrowser://getout?url=https://www.example.com"));
 }
Exemplo n.º 4
0
 @Test(expected = UrlParseException.class)
 public void intentForNativeBrowserScheme_whenNotMoPubNativeBrowser_shouldThrowException()
     throws UrlParseException {
   Intents.intentForNativeBrowserScheme(
       Uri.parse("mailto://navigate?url=https://www.example.com"));
 }