Intents { public static void startExternalUrl(@NonNull Activity activity, @NonNull String url) { CustomTabsIntent intent = new CustomTabsIntent.Builder() .setShowTitle(true) .setToolbarColor(ContextCompat.getColor(activity, R.color.primary)) .build(); intent.launchUrl(activity, Uri.parse(url)); } private  Intents(); static boolean startUri(@NonNull Context context, @NonNull String url); static void startExternalUrl(@NonNull Activity activity, @NonNull String url);  }
@Test public void should_start_external_uri() { String url = "http: RobolectricPackageManager rpm = (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager(); rpm.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), ShadowResolveInfo.newResolveInfo("", "", "")); Intents.startExternalUrl(activity, url); ShadowActivity shadowActivity = Shadows.shadowOf(activity); Intent startedIntent = shadowActivity.getNextStartedActivity(); assertThat(startedIntent.getAction()).isEqualTo(Intent.ACTION_VIEW); assertThat(startedIntent.getData().toString()).isEqualTo(url); }