Merge "Fix crash in non-indexable keys collection" into pi-dev am: 66e6e637a4
am: acc93635c3
Change-Id: I78aab2e3b7bc6f621e2425a88f3787e29f6ec2ff
This commit is contained in:
@@ -21,11 +21,13 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.provider.SearchIndexablesContract;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -36,12 +38,16 @@ public class SettingsSearchIndexablesProviderTest {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = InstrumentationRegistry.getTargetContext();
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanUp() {
|
||||
System.clearProperty(SettingsSearchIndexablesProvider.SYSPROP_CRASH_ON_ERROR);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSiteMapPairsFetched() {
|
||||
final Uri uri = Uri.parse("content://" + mContext.getPackageName() + "/" +
|
||||
@@ -59,4 +65,21 @@ public class SettingsSearchIndexablesProviderTest {
|
||||
.isNotEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* All {@link Indexable.SearchIndexProvider} should collect a list of non-indexable keys
|
||||
* without crashing. This test enables crashing of individual providers in the indexing pipeline
|
||||
* and checks that there are no crashes.
|
||||
*/
|
||||
@Test
|
||||
@Presubmit
|
||||
public void nonIndexableKeys_shouldNotCrash() {
|
||||
// Allow crashes in the indexing pipeline.
|
||||
System.setProperty(SettingsSearchIndexablesProvider.SYSPROP_CRASH_ON_ERROR,
|
||||
"enabled");
|
||||
|
||||
final Uri uri = Uri.parse("content://" + mContext.getPackageName() + "/" +
|
||||
SearchIndexablesContract.NON_INDEXABLES_KEYS_PATH);
|
||||
mContext.getContentResolver().query(uri, null, null, null, null);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user