Declare "searchable" attribute for preferences.
Now we can easily mark a preference nonIndexable in xml instead of adding key into searchIndexProvider. Bug: 112608186 Test: robotests Change-Id: I0ff16d44bb7b6ad148d3d35f09ca0da0163f73f4
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.applications;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -26,7 +27,6 @@ import android.os.UserManager;
|
||||
|
||||
import com.android.settings.notification.EmergencyBroadcastPreferenceController;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -42,19 +42,16 @@ public class AppAndNotificationDashboardFragmentTest {
|
||||
|
||||
@Test
|
||||
@Config(shadows = {ShadowEmergencyBroadcastPreferenceController.class})
|
||||
public void testNonIndexableKeys_existInXmlLayout() {
|
||||
public void getNonIndexableKeys_shouldIncludeSpecialAppAccess() {
|
||||
final Context context = spy(RuntimeEnvironment.application);
|
||||
UserManager manager = mock(UserManager.class);
|
||||
when(manager.isAdminUser()).thenReturn(true);
|
||||
when(context.getSystemService(Context.USER_SERVICE)).thenReturn(manager);
|
||||
final List<String> niks = AppAndNotificationDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getNonIndexableKeys(context);
|
||||
AppAndNotificationDashboardFragment fragment = new AppAndNotificationDashboardFragment();
|
||||
final int xmlId = fragment.getPreferenceScreenResId();
|
||||
|
||||
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
||||
|
||||
assertThat(keys).containsAllIn(niks);
|
||||
assertThat(niks).contains(
|
||||
new SpecialAppAccessPreferenceController(context).getPreferenceKey());
|
||||
}
|
||||
|
||||
@Implements(EmergencyBroadcastPreferenceController.class)
|
||||
|
||||
@@ -165,7 +165,7 @@ public class DefaultAppSettingsTest {
|
||||
final List<String> niks = DefaultAppSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getNonIndexableKeys(context);
|
||||
|
||||
final int xmlId = (new DefaultAppSettings()).getPreferenceScreenResId();
|
||||
final int xmlId = new DefaultAppSettings().getPreferenceScreenResId();
|
||||
|
||||
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user