Remove locale checking for indexing.
Remove the the indexing check for the index data's locale to match the locale of the device. We don't require locale for indexables, and we reindex on locale change. It had introduced a bug where when locale changed, the default us-en results would not be added to the db. Change-Id: I43a4284f5c23bc51ee3efdfcabe511eac2d3317d Fixes: 66916397 Fixes: 68380443 Test: robotests
This commit is contained in:
@@ -86,15 +86,12 @@ public class DatabaseIndexingManagerTest {
|
||||
private final String updatedSummaryOn = "summary-on";
|
||||
private final String normalizedSummaryOn = "summaryon";
|
||||
private final String summaryOff = "summary\u2011off";
|
||||
private final String updatedSummaryOff = "summary-off";
|
||||
private final String normalizedSummaryOff = "summaryoff";
|
||||
private final String entries = "entries";
|
||||
private final String keywords = "keywords, keywordss, keywordsss";
|
||||
private final String spaceDelimittedKeywords = "keywords keywordss keywordsss";
|
||||
private final String screenTitle = "screen title";
|
||||
private final String className = "class name";
|
||||
private final int iconResId = 0xff;
|
||||
private final int noIcon = 0;
|
||||
private final String action = "action";
|
||||
private final String targetPackage = "target package";
|
||||
private final String targetClass = "target class";
|
||||
@@ -210,8 +207,7 @@ public class DatabaseIndexingManagerTest {
|
||||
|
||||
mManager.performIndexing();
|
||||
|
||||
verify(mManager).updateDatabase(data, true /* isFullIndex */,
|
||||
Locale.getDefault().toString());
|
||||
verify(mManager).updateDatabase(data, true /* isFullIndex */);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -243,8 +239,7 @@ public class DatabaseIndexingManagerTest {
|
||||
|
||||
mManager.performIndexing();
|
||||
|
||||
verify(mManager).updateDatabase(data, true /* isFullIndex */,
|
||||
Locale.getDefault().toString());
|
||||
verify(mManager).updateDatabase(data, true /* isFullIndex */);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -278,7 +273,7 @@ public class DatabaseIndexingManagerTest {
|
||||
@Test
|
||||
public void testLocaleUpdated_afterIndexing_localeNotAdded() {
|
||||
PreIndexData emptydata = new PreIndexData();
|
||||
mManager.updateDatabase(emptydata, true /* isFullIndex */, localeStr);
|
||||
mManager.updateDatabase(emptydata, true /* isFullIndex */);
|
||||
|
||||
assertThat(IndexDatabaseHelper.isLocaleAlreadyIndexed(mContext, localeStr)).isFalse();
|
||||
}
|
||||
@@ -295,7 +290,7 @@ public class DatabaseIndexingManagerTest {
|
||||
// Test that addDataToDatabase is called when dataToUpdate is non-empty
|
||||
PreIndexData indexData = new PreIndexData();
|
||||
indexData.dataToUpdate.add(getFakeRaw());
|
||||
mManager.updateDatabase(indexData, true /* isFullIndex */, localeStr);
|
||||
mManager.updateDatabase(indexData, true /* isFullIndex */);
|
||||
|
||||
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index", null);
|
||||
cursor.moveToPosition(0);
|
||||
@@ -383,7 +378,7 @@ public class DatabaseIndexingManagerTest {
|
||||
public void testEmptyNonIndexableKeys_emptyDataKeyResources_addedToDatabase() {
|
||||
insertSpecialCase(TITLE_ONE, true /* enabled */, null /* dataReferenceKey */);
|
||||
PreIndexData emptydata = new PreIndexData();
|
||||
mManager.updateDatabase(emptydata, false /* needsReindexing */, localeStr);
|
||||
mManager.updateDatabase(emptydata, false /* needsReindexing */);
|
||||
|
||||
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE enabled = 1", null);
|
||||
cursor.moveToPosition(0);
|
||||
|
@@ -56,10 +56,7 @@ public class IndexDataConverterTest {
|
||||
private static final String normalizedTitle = "titletitle";
|
||||
private static final String summaryOn = "summary\u2011on";
|
||||
private static final String updatedSummaryOn = "summary-on";
|
||||
private static final String normalizedSummaryOn = "summaryon";
|
||||
private static final String summaryOff = "summary\u2011off";
|
||||
private static final String updatedSummaryOff = "summary-off";
|
||||
private static final String normalizedSummaryOff = "summaryoff";
|
||||
private static final String entries = "entries";
|
||||
private static final String keywords = "keywords, keywordss, keywordsss";
|
||||
private static final String spaceDelimittedKeywords = "keywords keywordss keywordsss";
|
||||
@@ -100,7 +97,7 @@ public class IndexDataConverterTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mConverter = spy(new IndexDataConverter(mContext, localeStr));
|
||||
mConverter = spy(new IndexDataConverter(mContext));
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -160,13 +157,13 @@ public class IndexDataConverterTest {
|
||||
* TODO (b/66916397) investigate why locale is attached to IndexData
|
||||
*/
|
||||
@Test
|
||||
public void testInsertRawColumn_mismatchedLocale_noRowInserted() {
|
||||
public void testInsertRawColumn_mismatchedLocale_rowInserted() {
|
||||
final SearchIndexableRaw raw = getFakeRaw("ca-fr");
|
||||
PreIndexData preIndexData = new PreIndexData();
|
||||
preIndexData.dataToUpdate.add(raw);
|
||||
List<IndexData> indexData = mConverter.convertPreIndexDataToIndexData(preIndexData);
|
||||
|
||||
assertThat(indexData).isEmpty();
|
||||
assertThat(indexData).hasSize(1);
|
||||
}
|
||||
|
||||
// Tests for the flow: IndexOneResource -> IndexFromResource ->
|
||||
|
@@ -40,7 +40,7 @@ import org.robolectric.annotation.Config;
|
||||
public class IndexDataTest {
|
||||
private IndexData.Builder mBuilder;
|
||||
|
||||
private static final String LOCALE = "locale";
|
||||
private static final String LOCALE = "en_US";
|
||||
private static final String TITLE = "updated-title";
|
||||
private static final String NORM_TITLE = "updatedtitle";
|
||||
private static final String SUMMARY_ON = "updated-summary-on";
|
||||
@@ -156,8 +156,7 @@ public class IndexDataTest {
|
||||
|
||||
private IndexData.Builder createBuilder() {
|
||||
mBuilder = new IndexData.Builder();
|
||||
mBuilder.setLocale(LOCALE)
|
||||
.setTitle(TITLE)
|
||||
mBuilder.setTitle(TITLE)
|
||||
.setSummaryOn(SUMMARY_ON)
|
||||
.setEntries(ENTRIES)
|
||||
.setClassName(CLASS_NAME)
|
||||
|
Reference in New Issue
Block a user