use of org.robolectric.manifest.IntentFilterData 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.IntentFilterData 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);
}
use of org.robolectric.manifest.IntentFilterData in project android_packages_apps_Settings by SudaMod.
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.IntentFilterData in project robolectric by robolectric.
the class DefaultPackageManager method matchIntentFilter.
private boolean matchIntentFilter(ActivityData activityData, Intent intent) {
for (IntentFilterData intentFilterData : activityData.getIntentFilters()) {
List<String> actionList = intentFilterData.getActions();
List<String> categoryList = intentFilterData.getCategories();
IntentFilter intentFilter = new IntentFilter();
for (String action : actionList) {
intentFilter.addAction(action);
}
for (String category : categoryList) {
intentFilter.addCategory(category);
}
for (String scheme : intentFilterData.getSchemes()) {
intentFilter.addDataScheme(scheme);
}
for (String mimeType : intentFilterData.getMimeTypes()) {
try {
intentFilter.addDataType(mimeType);
} catch (IntentFilter.MalformedMimeTypeException ex) {
throw new RuntimeException(ex);
}
}
for (String path : intentFilterData.getPaths()) {
intentFilter.addDataPath(path, PatternMatcher.PATTERN_LITERAL);
}
for (String pathPattern : intentFilterData.getPathPatterns()) {
intentFilter.addDataPath(pathPattern, PatternMatcher.PATTERN_SIMPLE_GLOB);
}
for (String pathPrefix : intentFilterData.getPathPrefixes()) {
intentFilter.addDataPath(pathPrefix, PatternMatcher.PATTERN_PREFIX);
}
for (IntentFilterData.DataAuthority authority : intentFilterData.getAuthorities()) {
intentFilter.addDataAuthority(authority.getHost(), authority.getPort());
}
// match action
boolean matchActionResult = intentFilter.matchAction(intent.getAction());
// match category
String matchCategoriesResult = intentFilter.matchCategories(intent.getCategories());
// match data
int matchResult = intentFilter.matchData(intent.getType(), (intent.getData() != null ? intent.getData().getScheme() : null), intent.getData());
if (matchActionResult && (matchCategoriesResult == null) && (matchResult != IntentFilter.NO_MATCH_DATA && matchResult != IntentFilter.NO_MATCH_TYPE)) {
return true;
}
}
return false;
}
use of org.robolectric.manifest.IntentFilterData 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);
}
Aggregations