Remove accessibility duplicates in settings search

Bug: 33701673
Test: make RunSettingsRoboTests
Change-Id: I46e79051d10c4cae851f8e76304e6cfe0a3f73d4
Merged-In: Idda6d2f98cb8d2cb91a9a4721b2ef84921f9056a
This commit is contained in:
Matthew Fritze
2017-04-17 07:55:41 -07:00
parent f1f35ee107
commit 7ae3c078b6
7 changed files with 69 additions and 6 deletions

View File

@@ -0,0 +1,34 @@
package com.android.settings.accessibility;
import android.content.Context;
import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
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.ArrayList;
import java.util.List;
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class AccessibilitySettingsTest {
@Test
public void testNonIndexableKeys_existInXmlLayout() {
final Context context = RuntimeEnvironment.application;
final List<String> niks = AccessibilitySettings.SEARCH_INDEX_DATA_PROVIDER
.getNonIndexableKeys(context);
final List<String> keys = new ArrayList<>();
keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context, R.xml.accessibility_settings));
assertThat(keys).containsAllIn(niks);
}
}

View File

@@ -93,10 +93,7 @@ public class DataIntegrityTest {
for (Integer xmlResId : xmlList) {
// Get all keys to be indexed
final List<String> prefKeys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlResId);
pageKeys.addAll(prefKeys);
// Remove grandfathered keys.
pageKeys.removeAll(grandfatheredKeys);
// Find all already-existing keys.
pageKeys.retainAll(masterKeys);
// Keep list of offending duplicate keys.
@@ -105,7 +102,7 @@ public class DataIntegrityTest {
masterKeys.addAll(prefKeys);
pageKeys.clear();
}
assertThat(duplicateKeys).isEmpty();
assertThat(duplicateKeys).containsExactlyElementsIn(grandfatheredKeys);
}
/**