Loading src/com/android/settings/LegalSettings.java +3 −1 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -76,7 +77,7 @@ public class LegalSettings extends SettingsPreferenceFragment implements Indexab @Override public List<String> getNonIndexableKeys(Context context) { final List<String> keys = new ArrayList<String>(); final List<String> keys = super.getNonIndexableKeys(context); if (!checkIntentAction(context, "android.settings.TERMS")) { keys.add(KEY_TERMS); } Loading @@ -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; } Loading src/com/android/settings/search/BaseSearchIndexProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider { } return nonIndexableKeys; } else { return EMPTY_LIST; return new ArrayList<>(); } } Loading tests/robotests/src/com/android/settings/LegalSettingsTest.java 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * 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<String> niks = LegalSettings.SEARCH_INDEX_DATA_PROVIDER .getNonIndexableKeys(context); final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, R.xml.about_legal); assertThat(keys).containsAllIn(niks); } } No newline at end of file tests/robotests/src/com/android/settings/search2/DatabaseIndexingManagerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -671,9 +671,9 @@ public class DatabaseIndexingManagerTest { new HashMap<String, Set<String>>()); 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 Loading Loading
src/com/android/settings/LegalSettings.java +3 −1 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -76,7 +77,7 @@ public class LegalSettings extends SettingsPreferenceFragment implements Indexab @Override public List<String> getNonIndexableKeys(Context context) { final List<String> keys = new ArrayList<String>(); final List<String> keys = super.getNonIndexableKeys(context); if (!checkIntentAction(context, "android.settings.TERMS")) { keys.add(KEY_TERMS); } Loading @@ -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; } Loading
src/com/android/settings/search/BaseSearchIndexProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider { } return nonIndexableKeys; } else { return EMPTY_LIST; return new ArrayList<>(); } } Loading
tests/robotests/src/com/android/settings/LegalSettingsTest.java 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * 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<String> niks = LegalSettings.SEARCH_INDEX_DATA_PROVIDER .getNonIndexableKeys(context); final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, R.xml.about_legal); assertThat(keys).containsAllIn(niks); } } No newline at end of file
tests/robotests/src/com/android/settings/search2/DatabaseIndexingManagerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -671,9 +671,9 @@ public class DatabaseIndexingManagerTest { new HashMap<String, Set<String>>()); 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 Loading