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
I upgraded to the latest Robolectric (version 2.1.1) and the PackageManager doesn't come up null anymore.
The code below verifies that a browser intent is fired (and configured with a url). I haven't tested this on 1.x, but I think it works there too:
@Test
public void recipeTitleShouldOpenBrowserOnClick() throws Exception
{
title.performClick();
ShadowActivity shadowActivity = shadowOf( detailFragment.getActivity() );
ShadowActivity.IntentForResult intent = shadowActivity.peekNextStartedActivityForResult();
// or
// ShadowActivity.IntentForResult intent = shadowActivity.getNextStartedActivityForResult();
assertThat( intent.intent,
equalTo( createBrowserIntentWithURL( "url" ) ) );
}
Note: I'm invoking start activity from a fragment here.