My Android application has a simple method to fire off an intent to display a URL.
protected void launchBrowser(int id)
{
Uri uri = Uri.parse( getStrin
You can set the ShadowPackageManager in a separate method (without extending RobolectricTestRunner)
private void setupPackageManager() {
ShadowApplication shadowApplication = shadowOf(Robolectric.application);
shadowApplication.setPackageManager(mockPackageManager);
List activities = new ArrayList();
activities.add(resolveInfo("com.test.package.Class1"));
activities.add(resolveInfo("com.test.package.Class2"));
when(mockPackageManager.queryIntentActivities(any(Intent.class), anyInt())).thenReturn(activities);
}
Note : Here, i have used mockito & mocked the packagemanager for my unittest instead of using the actual PackageManager.