use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class DefaultPackageManagerTest method getServiceInfo_shouldReturnServiceInfoWithoutMetaDataWhenFlagsNotSet.
@Test
@Config(manifest = "src/test/resources/TestPackageManagerGetServiceInfo.xml")
public void getServiceInfo_shouldReturnServiceInfoWithoutMetaDataWhenFlagsNotSet() throws Exception {
ServiceInfo serviceInfo = rpm.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 DefaultPackageManagerTest method getActivityMetaData_configChanges.
@Test
@Config(manifest = "src/test/resources/TestAndroidManifest.xml")
public void getActivityMetaData_configChanges() throws Exception {
Activity activity = setupActivity(ActivityWithConfigChanges.class);
ActivityInfo activityInfo = activity.getPackageManager().getActivityInfo(activity.getComponentName(), 0);
int configChanges = activityInfo.configChanges;
assertThat(configChanges & ActivityInfo.CONFIG_MCC).isEqualTo(ActivityInfo.CONFIG_MCC);
assertThat(configChanges & ActivityInfo.CONFIG_SCREEN_LAYOUT).isEqualTo(ActivityInfo.CONFIG_SCREEN_LAYOUT);
assertThat(configChanges & ActivityInfo.CONFIG_ORIENTATION).isEqualTo(ActivityInfo.CONFIG_ORIENTATION);
// Spot check a few other possible values that shouldn't be in the flags.
assertThat(configChanges & ActivityInfo.CONFIG_MNC).isZero();
assertThat(configChanges & ActivityInfo.CONFIG_FONT_SCALE).isZero();
assertThat(configChanges & ActivityInfo.CONFIG_SCREEN_SIZE).isZero();
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class DefaultPackageManagerTest method queryIntentActivities_MatchWithImplicitIntents.
@Test
@Config(manifest = "src/test/resources/TestAndroidManifestForActivitiesWithIntentFilterWithData.xml")
public void queryIntentActivities_MatchWithImplicitIntents() throws Exception {
Uri uri = Uri.parse("content://testhost1.com:1/testPath/test.jpeg");
Intent i = new Intent(Intent.ACTION_VIEW);
i.addCategory(Intent.CATEGORY_DEFAULT);
i.setDataAndType(uri, "image/jpeg");
rpm.setQueryIntentImplicitly(true);
List<ResolveInfo> activities = rpm.queryIntentActivities(i, 0);
assertThat(activities).isNotNull();
assertThat(activities).hasSize(1);
assertThat(activities.get(0).resolvePackageName.toString()).isEqualTo("org.robolectric");
assertThat(activities.get(0).activityInfo.targetActivity.toString()).isEqualTo("org.robolectric.shadows.TestActivity");
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class AndroidTranslatorClassInstrumentedTest method testNativeMethodsAreDelegated.
@Test
@Config(shadows = ShadowPaintForTests.class)
public void testNativeMethodsAreDelegated() throws Exception {
Paint paint = new Paint();
paint.setColor(1234);
assertThat(paint.getColor()).isEqualTo(1234);
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class DefaultPackageManagerTest method getProviderInfo_shouldPopulatePermissionsInProviderInfos.
@Test
@Config(manifest = "src/test/resources/TestAndroidManifestWithContentProviders.xml")
public void getProviderInfo_shouldPopulatePermissionsInProviderInfos() throws Exception {
ProviderInfo providerInfo = packageManager.getProviderInfo(new ComponentName(RuntimeEnvironment.application, "org.robolectric.android.controller.ContentProviderControllerTest$MyContentProvider"), 0);
assertThat(providerInfo.authority).isEqualTo("org.robolectric.authority2");
assertThat(providerInfo.readPermission).isEqualTo("READ_PERMISSION");
assertThat(providerInfo.writePermission).isEqualTo("WRITE_PERMISSION");
assertThat(providerInfo.pathPermissions).hasSize(1);
assertThat(providerInfo.pathPermissions[0].getPath()).isEqualTo("/path/*");
assertThat(providerInfo.pathPermissions[0].getType()).isEqualTo(PathPermission.PATTERN_SIMPLE_GLOB);
assertThat(providerInfo.pathPermissions[0].getReadPermission()).isEqualTo("PATH_READ_PERMISSION");
assertThat(providerInfo.pathPermissions[0].getWritePermission()).isEqualTo("PATH_WRITE_PERMISSION");
}
Aggregations