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
This commit is contained in:
@@ -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(
|
||||
|
@@ -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) {
|
||||
|
||||
|
Reference in New Issue
Block a user