Misc fixes to search and UI.

- Use prefContext to create preference.
- rename "Gestures" to "Gesture shortcuts"
- Add search keyword to individual gesture settings so when search
  "gesture" they also show up.
- call super() for all getNonIndexableKeys() in search provider

Fix: 38327387
Fix: 36621897
Fix: 36685646
Test: make RunSettingsRoboTests

Change-Id: Ia5ddfeae08cb27c278dfb8d2376594e21d8f283c
This commit is contained in:
Fan Zhang
2017-05-23 10:46:54 -07:00
parent f51539110a
commit 82be5f0c3f
20 changed files with 51 additions and 42 deletions

View File

@@ -18,11 +18,11 @@
package com.android.settings.nfc;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,7 +33,6 @@ import org.robolectric.annotation.Config;
import java.util.List;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@@ -67,6 +66,6 @@ public class PaymentSettingsTest {
when(mManager.hasSystemFeature(PackageManager.FEATURE_NFC)).thenReturn(true);
List<String> niks = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
assertThat(niks).isNull();
assertThat(niks).isEmpty();
}
}

View File

@@ -369,6 +369,7 @@ public class DatabaseIndexingManagerTest {
mContext.getString(R.string.fingerprint_swipe_for_notifications_title);
final String prefSummary =
mContext.getString(R.string.fingerprint_swipe_for_notifications_summary);
final String keywords = mContext.getString(R.string.keywords_gesture);
Cursor cursor = mDb.rawQuery(
"SELECT * FROM prefs_index where data_title='" + prefTitle + "'", null);
cursor.moveToFirst();
@@ -392,7 +393,7 @@ public class DatabaseIndexingManagerTest {
// Entries - only on for list preferences
assertThat(cursor.getString(8)).isNull();
// Keywords
assertThat(cursor.getString(9)).isEmpty();
assertThat(cursor.getString(9)).isEqualTo(keywords);
// Screen Title
assertThat(cursor.getString(10)).isEqualTo(
mContext.getString(R.string.fingerprint_swipe_for_notifications_title));

View File

@@ -19,12 +19,12 @@ package com.android.settings.search;
import android.content.Context;
import android.provider.SearchIndexableResource;
import com.android.settings.core.PreferenceController;
import java.util.ArrayList;
import java.util.List;
public class FakeIndexProvider implements Indexable {
public class FakeIndexProvider implements Indexable {
public static final String KEY = "TestKey";
@@ -38,7 +38,7 @@ public class FakeIndexProvider implements Indexable {
@Override
public List<String> getNonIndexableKeys(Context context) {
ArrayList<String> result = new ArrayList<>();
List<String> result = super.getNonIndexableKeys(context);
result.add(KEY);
return result;
}