use of org.robolectric.res.builder.RobolectricPackageManager in project materialistic by hidroh.
the class BaseListActivityTest method testSelectItemStartActionView.
@Test
public void testSelectItemStartActionView() {
RobolectricPackageManager packageManager = (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager();
packageManager.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com")), ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
packageManager.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com")), ShadowResolveInfo.newResolveInfo("label", "com.android.browser", "DefaultActivity"));
PreferenceManager.getDefaultSharedPreferences(activity).edit().putBoolean(activity.getString(R.string.pref_external), true).commit();
controller.pause().resume();
activity.onItemSelected(new TestWebItem() {
@Override
public String getUrl() {
return "http://example.com";
}
});
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_VIEW);
}
use of org.robolectric.res.builder.RobolectricPackageManager in project materialistic by hidroh.
the class BaseListActivityTest method testSelectItemOpenExternal.
@Test
public void testSelectItemOpenExternal() {
RobolectricPackageManager packageManager = (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager();
packageManager.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com")), ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
PreferenceManager.getDefaultSharedPreferences(activity).edit().putBoolean(activity.getString(R.string.pref_external), true).commit();
controller.pause().resume();
activity.onItemSelected(new TestWebItem() {
@Override
public String getUrl() {
return "http://example.com";
}
});
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_VIEW);
}
use of org.robolectric.res.builder.RobolectricPackageManager in project materialistic by hidroh.
the class BaseListActivityTest method testSelectItemOpenChooser.
@Test
public void testSelectItemOpenChooser() {
RobolectricPackageManager packageManager = (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager();
packageManager.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://news.ycombinator.com/item?id=1")), ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
packageManager.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://news.ycombinator.com/item?id=1")), ShadowResolveInfo.newResolveInfo("label", "com.android.browser", "DefaultActivity"));
PreferenceManager.getDefaultSharedPreferences(activity).edit().putBoolean(activity.getString(R.string.pref_external), true).commit();
controller.pause().resume();
activity.onItemSelected(new TestWebItem() {
@Override
public String getUrl() {
return "http://news.ycombinator.com/item?id=1";
}
});
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_CHOOSER);
}
use of org.robolectric.res.builder.RobolectricPackageManager in project robolectric by robolectric.
the class RobolectricTestRunnerSelfTest method clearOrder.
@Before
public void clearOrder() {
onTerminateCalledFromMain = null;
order.clear();
RobolectricPackageManager mockManager = mock(RobolectricPackageManager.class);
doAnswer(new Answer<Void>() {
public Void answer(InvocationOnMock invocation) {
order.add("reset");
return null;
}
}).when(mockManager).reset();
RuntimeEnvironment.setRobolectricPackageManager(mockManager);
}
use of org.robolectric.res.builder.RobolectricPackageManager in project robolectric by robolectric.
the class ParallelUniverseTest method tearDownApplication_shouldNotResetPackageManager.
@Test
public void tearDownApplication_shouldNotResetPackageManager() {
RobolectricPackageManager pm = mock(RobolectricPackageManager.class);
RuntimeEnvironment.setRobolectricPackageManager(pm);
pu.tearDownApplication();
verify(pm, never()).reset();
}
Aggregations