@Test public void intentForShareTweetScheme_whenValidUri_shouldReturnShareTweetIntent() throws UrlParseException { Intent intent; final String shareMessage = "Check out @SpaceX's Tweet: https://twitter.com/SpaceX/status/596026229536460802"; intent = Intents.intentForShareTweet( Uri.parse("mopubshare://tweet?screen_name=SpaceX&tweet_id=596026229536460802")); assertThat(intent.getAction()).isEqualTo(Intent.ACTION_SEND); assertThat(intent.getType()).isEqualTo("text/plain"); assertThat(intent.getStringExtra(Intent.EXTRA_SUBJECT)).isEqualTo(shareMessage); assertThat(intent.getStringExtra(Intent.EXTRA_TEXT)).isEqualTo(shareMessage); }
@Test(expected = UrlParseException.class) public void intentForShareTweetScheme_whenTweetIdParameterIsEmpty_shouldThrowException() throws UrlParseException { Intents.intentForShareTweet(Uri.parse("mopubshare://tweet?screen_name=SpaceX&tweet_id=")); }
@Test(expected = UrlParseException.class) public void intentForShareTweetScheme_whenTweetIdParameterMissing_shouldThrowException() throws UrlParseException { Intents.intentForShareTweet( Uri.parse("mopubshare://tweet?screen_name=SpaceX&bar=596026229536460802")); }
@Test(expected = UrlParseException.class) public void intentForShareTweetScheme_whenScreenNameParameterIsEmpty_shouldThrowException() throws UrlParseException { Intents.intentForShareTweet( Uri.parse("mopubshare://tweet?screen_name=&tweet_id=596026229536460802")); }
@Test(expected = UrlParseException.class) public void intentForShareTweetScheme_whenWrongHost_shouldThrowException() throws UrlParseException { Intents.intentForShareTweet( Uri.parse("mopubshare://twat?screen_name=SpaceX&tweet_id=596026229536460802")); }