diff --git a/src/com/android/settings/LegalSettings.java b/src/com/android/settings/LegalSettings.java index e40152a0212..d5b998891b5 100644 --- a/src/com/android/settings/LegalSettings.java +++ b/src/com/android/settings/LegalSettings.java @@ -40,6 +40,7 @@ public class LegalSettings extends SettingsPreferenceFragment implements Indexab private static final String KEY_LICENSE = "license"; private static final String KEY_COPYRIGHT = "copyright"; private static final String KEY_WEBVIEW_LICENSE = "webview_license"; + private static final String KEY_WALLPAPER_ATTRIBUTIONS = "wallpaper_attributions"; public void onCreate(Bundle icicle) { super.onCreate(icicle); @@ -76,7 +77,7 @@ public class LegalSettings extends SettingsPreferenceFragment implements Indexab @Override public List getNonIndexableKeys(Context context) { - final List keys = new ArrayList(); + final List keys = super.getNonIndexableKeys(context); if (!checkIntentAction(context, "android.settings.TERMS")) { keys.add(KEY_TERMS); } @@ -89,6 +90,7 @@ public class LegalSettings extends SettingsPreferenceFragment implements Indexab if (!checkIntentAction(context, "android.settings.WEBVIEW_LICENSE")) { keys.add(KEY_WEBVIEW_LICENSE); } + keys.add(KEY_WALLPAPER_ATTRIBUTIONS); return keys; } diff --git a/src/com/android/settings/search/BaseSearchIndexProvider.java b/src/com/android/settings/search/BaseSearchIndexProvider.java index 87322279134..f5e06ca53cb 100644 --- a/src/com/android/settings/search/BaseSearchIndexProvider.java +++ b/src/com/android/settings/search/BaseSearchIndexProvider.java @@ -72,7 +72,7 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider { } return nonIndexableKeys; } else { - return EMPTY_LIST; + return new ArrayList<>(); } } diff --git a/tests/robotests/src/com/android/settings/LegalSettingsTest.java b/tests/robotests/src/com/android/settings/LegalSettingsTest.java new file mode 100644 index 00000000000..6cfe2119de8 --- /dev/null +++ b/tests/robotests/src/com/android/settings/LegalSettingsTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.settings; + +import android.content.Context; + +import com.android.settings.testutils.XmlTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Config; + +import java.util.List; + +import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Mockito.spy; + +@RunWith(SettingsRobolectricTestRunner.class) +@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) +public class LegalSettingsTest { + + @Test + public void testNonIndexableKeys_existInXmlLayout() { + final Context context = RuntimeEnvironment.application; + final List niks = LegalSettings.SEARCH_INDEX_DATA_PROVIDER + .getNonIndexableKeys(context); + + final List keys = XmlTestUtils.getKeysFromPreferenceXml(context, + R.xml.about_legal); + + assertThat(keys).containsAllIn(niks); + } +} \ No newline at end of file diff --git a/tests/robotests/src/com/android/settings/search2/DatabaseIndexingManagerTest.java b/tests/robotests/src/com/android/settings/search2/DatabaseIndexingManagerTest.java index b76feff1a64..6844be589b3 100644 --- a/tests/robotests/src/com/android/settings/search2/DatabaseIndexingManagerTest.java +++ b/tests/robotests/src/com/android/settings/search2/DatabaseIndexingManagerTest.java @@ -671,9 +671,9 @@ public class DatabaseIndexingManagerTest { new HashMap>()); Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE enabled = 1", null); - assertThat(cursor.getCount()).isEqualTo(2); + assertThat(cursor.getCount()).isEqualTo(1); cursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE enabled = 0", null); - assertThat(cursor.getCount()).isEqualTo(4); + assertThat(cursor.getCount()).isEqualTo(5); } @Test