use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ParameterizedRobolectricTestRunnerClassLoaderTest method parse.
@Test
@Config(manifest = Config.NONE)
public void parse() {
Uri currentUri = Uri.parse("http://host/");
assertThat(currentUri).isEqualTo(uri);
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowPackageManagerTest method getServiceInfo_shouldThrowNameNotFoundExceptionIfNotExist.
@Test(expected = PackageManager.NameNotFoundException.class)
@Config(manifest = "src/test/resources/TestPackageManagerGetServiceInfo.xml")
public void getServiceInfo_shouldThrowNameNotFoundExceptionIfNotExist() throws Exception {
ComponentName nonExistComponent = new ComponentName("org.robolectric", "com.foo.NonExistService");
try {
shadowPackageManager.getServiceInfo(nonExistComponent, PackageManager.GET_SERVICES);
fail("should have thrown NameNotFoundException");
} catch (PackageManager.NameNotFoundException e) {
assertThat(e.getMessage()).contains("com.foo.NonExistService");
throw e;
}
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowPackageManagerTest method getServiceInfo_shouldReturnServiceInfoIfExists.
@Test
@Config(manifest = "src/test/resources/TestPackageManagerGetServiceInfo.xml")
public void getServiceInfo_shouldReturnServiceInfoIfExists() throws Exception {
ServiceInfo serviceInfo = shadowPackageManager.getServiceInfo(new ComponentName("org.robolectric", "com.foo.Service"), PackageManager.GET_SERVICES);
assertEquals(serviceInfo.packageName, "org.robolectric");
assertEquals(serviceInfo.name, "com.foo.Service");
assertEquals(serviceInfo.permission, "com.foo.MY_PERMISSION");
assertNotNull(serviceInfo.applicationInfo);
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowPackageManagerTest method getServiceInfo_shouldReturnServiceInfoWithoutMetaDataWhenFlagsNotSet.
@Test
@Config(manifest = "src/test/resources/TestPackageManagerGetServiceInfo.xml")
public void getServiceInfo_shouldReturnServiceInfoWithoutMetaDataWhenFlagsNotSet() throws Exception {
ServiceInfo serviceInfo = shadowPackageManager.getServiceInfo(new ComponentName("org.robolectric", "com.foo.Service"), PackageManager.GET_SERVICES);
assertNull(serviceInfo.metaData);
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowPackageManagerTest method queryIntentActivities_EmptyResultWithNoMatchingImplicitIntents.
@Test
@Config(manifest = "src/test/resources/TestAndroidManifestForActivitiesWithIntentFilterWithData.xml")
public void queryIntentActivities_EmptyResultWithNoMatchingImplicitIntents() throws Exception {
Intent i = new Intent(Intent.ACTION_MAIN, null);
i.addCategory(Intent.CATEGORY_LAUNCHER);
shadowPackageManager.setQueryIntentImplicitly(true);
List<ResolveInfo> activities = shadowPackageManager.queryIntentActivities(i, 0);
assertThat(activities).isEmpty();
}
Aggregations