use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.
the class AccountDashboardFragmentTest method searchIndexProvider_hasManagedProfile_shouldNotIndex.
@Test
public void searchIndexProvider_hasManagedProfile_shouldNotIndex() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(PROFILE_ID, PROFILE_NAME, UserInfo.FLAG_MANAGED_PROFILE));
doReturn(infos).when(mUserManager).getProfiles(anyInt());
final List<SearchIndexableRaw> indexRaws = AccountDashboardFragment.SEARCH_INDEX_DATA_PROVIDER.getDynamicRawDataToIndex(mContext, true);
assertThat(indexRaws).isEmpty();
}
use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.
the class AccountDashboardFragmentTest method searchIndexProvider_hasAccounts_shouldIndex.
@Test
public void searchIndexProvider_hasAccounts_shouldIndex() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(PROFILE_ID, PROFILE_NAME, UserInfo.FLAG_PRIMARY));
doReturn(infos).when(mUserManager).getProfiles(anyInt());
final Account[] accounts = { new Account(ACCOUNT_NAME, ACCOUNT_TYPE) };
when(AccountManager.get(mContext)).thenReturn(mAccountManager);
doReturn(accounts).when(mAccountManager).getAccounts();
final List<SearchIndexableRaw> indexRaws = AccountDashboardFragment.SEARCH_INDEX_DATA_PROVIDER.getDynamicRawDataToIndex(mContext, true);
assertThat(indexRaws).isNotEmpty();
}
use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.
the class EmergencyInfoPreferenceControllerTest method updateRawDataToIndex_prefAvailable_shouldUpdate.
@Test
public void updateRawDataToIndex_prefAvailable_shouldUpdate() {
final List<SearchIndexableRaw> data = new ArrayList<>();
final List<ResolveInfo> infos = new ArrayList<>();
infos.add(new ResolveInfo());
when(mContext.getPackageManager().queryIntentActivities(any(Intent.class), anyInt())).thenReturn(infos);
mController.updateRawDataToIndex(data);
assertThat(mController.isAvailable()).isTrue();
assertThat(data).isNotEmpty();
}
use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.
the class SupportDashboardActivityTest method shouldIndexSearchActivityForSearch.
@Test
public void shouldIndexSearchActivityForSearch() {
final List<SearchIndexableRaw> indexables = SupportDashboardActivity.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, true);
assertThat(indexables).hasSize(1);
final SearchIndexableRaw value = indexables.get(0);
assertThat(value.title).isEqualTo(mContext.getString(R.string.page_tab_title_support));
assertThat(value.screenTitle).isEqualTo(mContext.getString(R.string.page_tab_title_support));
assertThat(value.intentTargetPackage).isEqualTo(mContext.getPackageName());
assertThat(value.intentTargetClass).isEqualTo(SupportDashboardActivity.class.getName());
assertThat(value.intentAction).isEqualTo(Intent.ACTION_MAIN);
}
use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.
the class AccountPreferenceController method updateDynamicRawDataToIndex.
@Override
public void updateDynamicRawDataToIndex(List<SearchIndexableRaw> rawData) {
if (!isAvailable()) {
return;
}
final Resources res = mContext.getResources();
final String screenTitle = res.getString(R.string.account_settings_title);
List<UserInfo> profiles = mUm.getProfiles(UserHandle.myUserId());
for (final UserInfo userInfo : profiles) {
if (userInfo.isEnabled() && userInfo.isManagedProfile()) {
if (!mHelper.hasBaseUserRestriction(DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId())) {
final SearchIndexableRaw data = new SearchIndexableRaw(mContext);
data.key = PREF_KEY_REMOVE_PROFILE;
data.title = res.getString(R.string.remove_managed_profile_label);
data.screenTitle = screenTitle;
rawData.add(data);
}
final SearchIndexableRaw data = new SearchIndexableRaw(mContext);
data.key = PREF_KEY_WORK_PROFILE_SETTING;
data.title = res.getString(R.string.managed_profile_settings_title);
data.screenTitle = screenTitle;
rawData.add(data);
}
}
}
Aggregations