OSDN Git Service

Block inline-results from Settings search
authorMatthew Fritze <mfritze@google.com>
Tue, 20 Jun 2017 15:16:24 +0000 (08:16 -0700)
committerMatthew Fritze <mfritze@google.com>
Tue, 20 Jun 2017 15:16:24 +0000 (08:16 -0700)
Change-Id: I51ac1d6510bdbd6818c91836117d9ffb059cf4ab
Fixes: 62806412
Test: make RunSettingsRoboTests

src/com/android/settings/display/AutoBrightnessPreferenceController.java
src/com/android/settings/search/SearchResultsAdapter.java
tests/robotests/src/com/android/settings/search/SearchResultsAdapterTest.java

index f731264..d4226e2 100644 (file)
@@ -19,6 +19,7 @@ import android.provider.Settings;
 import android.support.v14.preference.SwitchPreference;
 import android.support.v7.preference.Preference;
 
+import com.android.settings.DisplaySettings;
 import com.android.settings.core.PreferenceController;
 import com.android.settings.search.DatabaseIndexingUtils;
 import com.android.settings.search.InlineSwitchPayload;
@@ -69,7 +70,7 @@ public class AutoBrightnessPreferenceController extends PreferenceController imp
     @Override
     public ResultPayload getResultPayload() {
         final Intent intent = DatabaseIndexingUtils.buildSubsettingIntent(mContext,
-                getClass().getName(), mAutoBrightnessKey,
+                DisplaySettings.class.getName(), mAutoBrightnessKey,
                 mContext.getString(R.string.display_settings));
 
         return new InlineSwitchPayload(SCREEN_BRIGHTNESS_MODE,
index 199930f..c7a1a9f 100644 (file)
@@ -106,8 +106,10 @@ public class SearchResultsAdapter extends RecyclerView.Adapter<SearchViewHolder>
                 view = inflater.inflate(R.layout.search_intent_item, parent, false);
                 return new IntentSearchViewHolder(view);
             case ResultPayload.PayloadType.INLINE_SWITCH:
-                view = inflater.inflate(R.layout.search_inline_switch_item, parent, false);
-                return new InlineSwitchViewHolder(view, context);
+                // TODO (b/62807132) replace layout InlineSwitchViewHolder and return an
+                // InlineSwitchViewHolder.
+                view = inflater.inflate(R.layout.search_intent_item, parent, false);
+                return new IntentSearchViewHolder(view);
             case ResultPayload.PayloadType.SAVED_QUERY:
                 view = inflater.inflate(R.layout.search_saved_query_item, parent, false);
                 return new SavedQueryViewHolder(view);
index 0320526..503054b 100644 (file)
@@ -112,19 +112,20 @@ public class SearchResultsAdapterTest {
     }
 
     @Test
-    public void testCreateViewHolder_returnsInlineSwitchResult() {
+    public void testCreateViewHolder_returnsIntentSwitchResult() {
+        // TODO (b/62807132) test for InlineResult
         ViewGroup group = new FrameLayout(mContext);
         SearchViewHolder view = mAdapter.onCreateViewHolder(group,
                 ResultPayload.PayloadType.INLINE_SWITCH);
-        assertThat(view).isInstanceOf(InlineSwitchViewHolder.class);
+        assertThat(view).isInstanceOf(IntentSearchViewHolder.class);
     }
 
     @Test
     public void testEndToEndSearch_properResultsMerged_correctOrder() {
         mAdapter.initializeSearch("");
-        mAdapter.addSearchResults(new HashSet<SearchResult>(getDummyAppResults()),
+        mAdapter.addSearchResults(new HashSet<>(getDummyAppResults()),
                 InstalledAppResultLoader.class.getName());
-        mAdapter.addSearchResults(new HashSet<SearchResult>(getDummyDbResults()),
+        mAdapter.addSearchResults(new HashSet<>(getDummyDbResults()),
                 DatabaseResultLoader.class.getName());
         mAdapter.notifyResultsLoaded();
 
@@ -145,17 +146,17 @@ public class SearchResultsAdapterTest {
         List<SearchResult> dbResults = getDummyDbResults();
         mAdapter.initializeSearch("");
         // Add two individual items
-        mAdapter.addSearchResults(new HashSet<SearchResult>(appResults.subList(0, 1)),
+        mAdapter.addSearchResults(new HashSet<>(appResults.subList(0, 1)),
                 InstalledAppResultLoader.class.getName());
-        mAdapter.addSearchResults(new HashSet<SearchResult>(dbResults.subList(0, 1)),
+        mAdapter.addSearchResults(new HashSet<>(dbResults.subList(0, 1)),
                 DatabaseResultLoader.class.getName());
         mAdapter.notifyResultsLoaded();
         // Add super-set of items
         mAdapter.initializeSearch("");
         mAdapter.addSearchResults(
-                new HashSet<SearchResult>(appResults), InstalledAppResultLoader.class.getName());
+                new HashSet<>(appResults), InstalledAppResultLoader.class.getName());
         mAdapter.addSearchResults(
-                new HashSet<SearchResult>(dbResults), DatabaseResultLoader.class.getName());
+                new HashSet<>(dbResults), DatabaseResultLoader.class.getName());
         mAdapter.notifyResultsLoaded();
 
         List<SearchResult> results = mAdapter.getSearchResults();
@@ -176,14 +177,14 @@ public class SearchResultsAdapterTest {
         List<SearchResult> dbResults = getDummyDbResults();
         // Add list of items
         mAdapter.initializeSearch("");
-        mAdapter.addSearchResults(new HashSet<SearchResult>(appResults),
+        mAdapter.addSearchResults(new HashSet<>(appResults),
                 InstalledAppResultLoader.class.getName());
-        mAdapter.addSearchResults(new HashSet<SearchResult>(dbResults),
+        mAdapter.addSearchResults(new HashSet<>(dbResults),
                 DatabaseResultLoader.class.getName());
         mAdapter.notifyResultsLoaded();
         // Add subset of items
         mAdapter.initializeSearch("");
-        mAdapter.addSearchResults(new HashSet<SearchResult>(appResults.subList(0, 1)),
+        mAdapter.addSearchResults(new HashSet<>(appResults.subList(0, 1)),
                 InstalledAppResultLoader.class.getName());
         mAdapter.addSearchResults(new HashSet<>(dbResults.subList(0, 1)),
                 DatabaseResultLoader.class.getName());
@@ -568,12 +569,9 @@ public class SearchResultsAdapterTest {
     private List<Pair<String, Float>> getDummyRankingScores() {
         List<SearchResult> results = getDummyDbResults();
         List<Pair<String, Float>> scores = new ArrayList<>();
-        scores.add(
-                new Pair<String, Float>(Long.toString(results.get(2).stableId), 0.9f)); // charlie
-        scores.add(
-                new Pair<String, Float>(Long.toString(results.get(0).stableId), 0.8f)); // alpha
-        scores.add(
-                new Pair<String, Float>(Long.toString(results.get(1).stableId), 0.2f)); // bravo
+        scores.add(new Pair<>(Long.toString(results.get(2).stableId), 0.9f)); // charlie
+        scores.add(new Pair<>(Long.toString(results.get(0).stableId), 0.8f)); // alpha
+        scores.add(new Pair<>(Long.toString(results.get(1).stableId), 0.2f)); // bravo
         return scores;
     }
 }