From d11f93babe450b80b5ae8f90b806b20e01d72ad4 Mon Sep 17 00:00:00 2001 From: Neil Fuller Date: Thu, 22 Oct 2020 14:55:23 +0100 Subject: [PATCH 1/2] Revert "Stop search tests using location_settings" This reverts commit b71f7af512b506ee74f75f92a1cc254018c3c924. Bug: 171371424 Test: m -j30 RunSettingsRoboTests Change-Id: Id483ca41d3aced0893f0eff370270b5010eb8a7a --- .../src/com/android/settings/testutils/FakeIndexProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/robotests/src/com/android/settings/testutils/FakeIndexProvider.java b/tests/robotests/src/com/android/settings/testutils/FakeIndexProvider.java index 910ca54b177..c96155942b0 100644 --- a/tests/robotests/src/com/android/settings/testutils/FakeIndexProvider.java +++ b/tests/robotests/src/com/android/settings/testutils/FakeIndexProvider.java @@ -30,7 +30,7 @@ public class FakeIndexProvider implements Indexable { public static final String KEY = "TestKey"; public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = - new BaseSearchIndexProvider(R.xml.sound_settings) { + new BaseSearchIndexProvider(R.xml.location_settings) { @Override public List getNonIndexableKeys(Context context) { From 94a64d61392a2e0f197ba799b62e52c349dffd4e Mon Sep 17 00:00:00 2001 From: Neil Fuller Date: Thu, 22 Oct 2020 15:08:38 +0100 Subject: [PATCH 2/2] Fix search test using location_settings Second attempt to proactively fix a search test. SearchIndexableResourcesTest uses the FakeIndexProvider, which implicitly assumes that the robotests/res/xml-mcc999/location_settings.xml xml is in use. Without it, the test is accessing the real location_settings.xml / real preference controllers. This was working until now, but by luck and probably not intent. There is an upcoming change which will break the test, so this fixes the test ahead of time. This change updates the test to use the "mcc999" config, and improves the docs around FakeIndexProvider to try to make the requirements for use clearer. Bug: 171371424 Test: m RunSettingsRoboTests Change-Id: I868d191281a2030fa49134893bcd6720f757ea91 --- .../settings/search/SearchIndexableResourcesTest.java | 2 ++ .../com/android/settings/testutils/FakeIndexProvider.java | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java b/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java index 5bcce579795..893b56e0b6b 100644 --- a/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java +++ b/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java @@ -39,6 +39,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Config; @RunWith(RobolectricTestRunner.class) public class SearchIndexableResourcesTest { @@ -89,6 +90,7 @@ public class SearchIndexableResourcesTest { } @Test + @Config(qualifiers = "mcc999") public void testNonIndexableKeys_GetsKeyFromProvider() { mSearchProvider.getSearchIndexableResources().getProviderValues().clear(); mSearchProvider.getSearchIndexableResources().addIndex( diff --git a/tests/robotests/src/com/android/settings/testutils/FakeIndexProvider.java b/tests/robotests/src/com/android/settings/testutils/FakeIndexProvider.java index c96155942b0..8cd0892aa43 100644 --- a/tests/robotests/src/com/android/settings/testutils/FakeIndexProvider.java +++ b/tests/robotests/src/com/android/settings/testutils/FakeIndexProvider.java @@ -29,6 +29,12 @@ public class FakeIndexProvider implements Indexable { public static final String KEY = "TestKey"; + /** + * The fake SearchIndexProvider. Note that the use of location_settings below implies that tests + * using this should be using the res/xml-mcc999/location_settings.xml or + * res/xml-mcc998/location_settings.xml. Annotate tests with + * {@code @Config(qualifiers = "mcc999")}. + */ public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider(R.xml.location_settings) {