use of com.android.settingslib.search.SearchIndexableResources in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PreferenceControllerContractTest method controllersInSearchShouldImplementPreferenceControllerMixin.
@Test
@Presubmit
public void controllersInSearchShouldImplementPreferenceControllerMixin() {
// Required by AutofillLoggingLevelPreferenceController
Looper.prepare();
final Set<String> errorClasses = new ArraySet<>();
final SearchIndexableResources resources = FeatureFactory.getFactory(mContext).getSearchFeatureProvider().getSearchIndexableResources();
for (Class<?> clazz : resources.getProviderValues()) {
final Indexable.SearchIndexProvider provider = DatabaseIndexingUtils.getSearchIndexProvider(clazz);
if (provider == null) {
continue;
}
final List<AbstractPreferenceController> controllers = provider.getPreferenceControllers(mContext);
if (controllers == null) {
continue;
}
for (AbstractPreferenceController controller : controllers) {
if (!(controller instanceof PreferenceControllerMixin) && !(controller instanceof BasePreferenceController)) {
errorClasses.add(controller.getClass().getName());
}
}
}
if (!errorClasses.isEmpty()) {
final StringBuilder errorMessage = new StringBuilder().append("Each preference must implement PreferenceControllerMixin ").append("or extend BasePreferenceController, ").append("the following classes don't:\n");
for (String c : errorClasses) {
errorMessage.append(c).append("\n");
}
fail(errorMessage.toString());
}
}
use of com.android.settingslib.search.SearchIndexableResources in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceDataContractTest method preferenceWithControllerMustHaveNonEmptyTitle.
@Test
@Presubmit
public void preferenceWithControllerMustHaveNonEmptyTitle() throws IOException, XmlPullParserException {
final Set<String> nullTitleFragments = new HashSet<>();
final SearchIndexableResources resources = FeatureFactory.getFactory(mContext).getSearchFeatureProvider().getSearchIndexableResources();
for (Class<?> clazz : resources.getProviderValues()) {
verifyPreferenceTitle(nullTitleFragments, clazz);
}
if (!nullTitleFragments.isEmpty()) {
final StringBuilder error = new StringBuilder("All preferences with a controller must have a non-empty title by default, " + "found empty title in the following fragments\n");
for (String c : nullTitleFragments) {
error.append(c).append("\n");
}
fail(error.toString());
}
}
use of com.android.settingslib.search.SearchIndexableResources in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UniquePreferenceTest method allPreferencesShouldHaveUniqueKey.
/**
* All preferences should have their unique key. It's especially important for many parts of
* Settings to work properly: we assume pref keys are unique in displaying, search ranking,\
* search result suppression, and many other areas.
* <p/>
* So in this test we are checking preferences participating in search.
* <p/>
* Note: Preference is not limited to just <Preference/> object. Everything in preference xml
* should have a key.
*/
@Test
@Presubmit
public void allPreferencesShouldHaveUniqueKey() throws IOException, XmlPullParserException, Resources.NotFoundException {
final Set<String> uniqueKeys = new HashSet<>();
final Set<String> nullKeyClasses = new HashSet<>();
final Set<String> duplicatedKeys = new HashSet<>();
final SearchIndexableResources resources = FeatureFactory.getFactory(mContext).getSearchFeatureProvider().getSearchIndexableResources();
for (Class<?> clazz : resources.getProviderValues()) {
verifyPreferenceKeys(uniqueKeys, duplicatedKeys, nullKeyClasses, clazz);
}
if (!nullKeyClasses.isEmpty()) {
final StringBuilder nullKeyErrors = new StringBuilder().append("Each preference/SearchIndexableData must have a key, ").append("the following classes have null keys:\n");
for (String c : nullKeyClasses) {
nullKeyErrors.append(c).append("\n");
}
fail(nullKeyErrors.toString());
}
if (!duplicatedKeys.isEmpty()) {
final StringBuilder dupeKeysError = new StringBuilder("The following keys are not unique\n");
for (String c : duplicatedKeys) {
dupeKeysError.append(c).append("\n");
}
fail(dupeKeysError.toString());
}
}
Aggregations