@Test public void removeResolveInfosForIntent_forService() throws Exception { Intent intent = new Intent(Intent.ACTION_APP_ERROR, null).addCategory(Intent.CATEGORY_APP_BROWSER); ResolveInfo info = new ResolveInfo(); info.nonLocalizedLabel = TEST_PACKAGE_LABEL; info.serviceInfo = new ServiceInfo(); info.serviceInfo.packageName = "com.org"; shadowPackageManager.addResolveInfoForIntent(intent, info); shadowPackageManager.removeResolveInfosForIntent(intent, "com.org"); assertThat(packageManager.resolveService(intent, 0)).isNull(); }
@Test public void removeResolveInfosForIntent_shouldCauseResolveActivityToReturnNull() throws Exception { Intent intent = new Intent(Intent.ACTION_APP_ERROR, null).addCategory(Intent.CATEGORY_APP_BROWSER); ResolveInfo info = new ResolveInfo(); info.nonLocalizedLabel = TEST_PACKAGE_LABEL; info.activityInfo = new ActivityInfo(); info.activityInfo.packageName = "com.org"; shadowPackageManager.addResolveInfoForIntent(intent, info); shadowPackageManager.removeResolveInfosForIntent(intent, "com.org"); assertThat(packageManager.resolveActivity(intent, 0)).isNull(); }