use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.
the class OverrideSdkVersionTest method whenNotOverridden_shouldUseTargetSdkVersionFromAppManifest.
@Test
public void whenNotOverridden_shouldUseTargetSdkVersionFromAppManifest() {
AndroidManifest appManifest = ShadowApplication.getInstance().getAppManifest();
assertThat(Build.VERSION.SDK_INT).isEqualTo(appManifest.getTargetSdkVersion());
}
use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.
the class ParallelUniverseTest method setUpApplicationState.
private void setUpApplicationState(Config defaultConfig) {
ResourceTable sdkResourceProvider = ResourceTableFactory.newFrameworkResourceTable(new ResourcePath(android.R.class, null, null));
final RoutingResourceTable routingResourceTable = new RoutingResourceTable(ResourceTableFactory.newResourceTable("org.robolectric", new ResourcePath(R.class, null, null)));
pu.setUpApplicationState(null, new DefaultTestLifecycle(), new AndroidManifest(null, null, null, "package"), defaultConfig, sdkResourceProvider, routingResourceTable, RuntimeEnvironment.getSystemResourceTable());
}
use of org.robolectric.manifest.AndroidManifest in project android_packages_apps_Settings by DirtyUnicorns.
the class SettingsSuggestionsTest method assertSuggestionEquals.
private void assertSuggestionEquals(String activityName, String category, @StringRes int title, @StringRes int summary) {
final AndroidManifest androidManifest = ShadowApplication.getInstance().getAppManifest();
final ActivityData activityData = androidManifest.getActivityData(activityName);
final Map<String, Object> metaData = activityData.getMetaData().getValueMap();
final Context context = RuntimeEnvironment.application;
final String expectedTitle = context.getString(title);
final String expectedSummary = context.getString(summary);
final String pName = context.getPackageName();
final String actualTitle = context.getString(context.getResources().getIdentifier(((String) metaData.get("com.android.settings.title")).substring(8), "string", pName));
final String actualSummary = context.getString(context.getResources().getIdentifier(((String) metaData.get("com.android.settings.summary")).substring(8), "string", pName));
assertThat(actualTitle).isEqualTo(expectedTitle);
assertThat(actualSummary).isEqualTo(expectedSummary);
final List<IntentFilterData> intentFilters = activityData.getIntentFilters();
final List<String> categories = new ArrayList<>();
for (IntentFilterData intentFilter : intentFilters) {
categories.addAll(intentFilter.getCategories());
}
assertThat(categories).contains(category);
}
use of org.robolectric.manifest.AndroidManifest in project android_packages_apps_Settings by DirtyUnicorns.
the class SettingsRobolectricTestRunner method getAppManifest.
/**
* We are going to create our own custom manifest so that we can add multiple resource
* paths to it. This lets us access resources in both Settings and SettingsLib in our tests.
*/
@Override
protected AndroidManifest getAppManifest(Config config) {
// Using the manifest file's relative path, we can figure out the application directory.
final String appRoot = "packages/apps/Settings";
final String manifestPath = appRoot + "/AndroidManifest.xml";
final String resDir = appRoot + "/tests/robotests/res";
final String assetsDir = appRoot + config.assetDir();
// By adding any resources from libraries we need the AndroidManifest, we can access
// them from within the parallel universe's resource loader.
final AndroidManifest manifest = new AndroidManifest(Fs.fileFromPath(manifestPath), Fs.fileFromPath(resDir), Fs.fileFromPath(assetsDir)) {
@Override
public List<ResourcePath> getIncludedResourcePaths() {
List<ResourcePath> paths = super.getIncludedResourcePaths();
SettingsRobolectricTestRunner.getIncludedResourcePaths(getPackageName(), paths);
return paths;
}
};
// Set the package name to the renamed one
manifest.setPackageName("com.android.settings");
return manifest;
}
use of org.robolectric.manifest.AndroidManifest in project platform_packages_apps_Settings by BlissRoms.
the class SettingsSuggestionsTest method assertSuggestionEquals.
private void assertSuggestionEquals(String activityName, String category, @StringRes int title, @StringRes int summary) {
final AndroidManifest androidManifest = ShadowApplication.getInstance().getAppManifest();
final ActivityData activityData = androidManifest.getActivityData(activityName);
final Map<String, Object> metaData = activityData.getMetaData().getValueMap();
final Context context = RuntimeEnvironment.application;
final String expectedTitle = context.getString(title);
final String expectedSummary = context.getString(summary);
final String pName = context.getPackageName();
final String actualTitle = context.getString(context.getResources().getIdentifier(((String) metaData.get("com.android.settings.title")).substring(8), "string", pName));
final String actualSummary = context.getString(context.getResources().getIdentifier(((String) metaData.get("com.android.settings.summary")).substring(8), "string", pName));
assertThat(actualTitle).isEqualTo(expectedTitle);
assertThat(actualSummary).isEqualTo(expectedSummary);
final List<IntentFilterData> intentFilters = activityData.getIntentFilters();
final List<String> categories = new ArrayList<>();
for (IntentFilterData intentFilter : intentFilters) {
categories.addAll(intentFilter.getCategories());
}
assertThat(categories).contains(category);
}
Aggregations