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
For some reason you need to set the shadow packagemanager manually on your application. Create a custom test runner (by extending RobolectricTestRunner) and override the setApplicationState method:
public class MyTestRunner extends RobolectricTestRunner {
@Override
public void setupApplicationstate(RobolectricConfig robolectricConfig) {
super.setupApplicationState(robolectricConfig);
ShadowApplication shadowApplication = shadowOf(Robolectric.application);
shadowApplication.setPackageName(robolectricConfig.getPackageName());
shadowApplication.setPackageManager(new RobolectricPackageManager(Robolectric.application, robolectricConfig));
}
}
Then specify in your tests that you want to use your own test runner:
@RunWith(MyTestRunner.class)
public class MyTest { ... }