use of org.robolectric.manifest.ActivityData in project robolectric by robolectric.
the class DefaultPackageManager method queryImplicitIntent.
private List<ResolveInfo> queryImplicitIntent(Intent intent, int flags) {
List<ResolveInfo> resolveInfoList = new ArrayList<>();
for (Map.Entry<String, AndroidManifest> androidManifest : androidManifests.entrySet()) {
String packageName = androidManifest.getKey();
AndroidManifest appManifest = androidManifest.getValue();
for (Map.Entry<String, ActivityData> activity : appManifest.getActivityDatas().entrySet()) {
String activityName = activity.getKey();
ActivityData activityData = activity.getValue();
if (activityData.getTargetActivity() != null) {
activityName = activityData.getTargetActivityName();
}
if (matchIntentFilter(activityData, intent)) {
ResolveInfo resolveInfo = new ResolveInfo();
resolveInfo.resolvePackageName = packageName;
resolveInfo.activityInfo = new ActivityInfo();
resolveInfo.activityInfo.targetActivity = activityName;
resolveInfoList.add(resolveInfo);
}
}
}
return resolveInfoList;
}
use of org.robolectric.manifest.ActivityData in project robolectric by robolectric.
the class DefaultPackageManager method getActivityInfo.
@Override
public ActivityInfo getActivityInfo(ComponentName className, int flags) throws NameNotFoundException {
ActivityInfo activityInfo = new ActivityInfo();
String packageName = className.getPackageName();
String activityName = className.getClassName();
activityInfo.name = activityName;
activityInfo.packageName = packageName;
AndroidManifest androidManifest = androidManifests.get(packageName);
// simply an android.app.Activity just return what we have.
if (androidManifest == null) {
return activityInfo;
}
ActivityData activityData = androidManifest.getActivityData(activityName);
if (activityData != null) {
activityInfo.configChanges = getConfigChanges(activityData);
activityInfo.parentActivityName = activityData.getParentActivityName();
activityInfo.metaData = metaDataToBundle(activityData.getMetaData().getValueMap());
String themeRef;
// Based on ShadowActivity
if (activityData.getThemeRef() != null) {
themeRef = activityData.getThemeRef();
} else {
themeRef = androidManifest.getThemeRef();
}
if (themeRef != null) {
activityInfo.theme = RuntimeEnvironment.application.getResources().getIdentifier(themeRef.replace("@", ""), "style", packageName);
}
}
activityInfo.applicationInfo = getApplicationInfo(packageName, flags);
return activityInfo;
}
use of org.robolectric.manifest.ActivityData in project android_packages_apps_Settings by LineageOS.
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.ActivityData in project android_packages_apps_Settings by omnirom.
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.ActivityData in project android_packages_apps_Settings by crdroidandroid.
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