Misc search fix
- Remove incorrect summary from set date/time - Remove some unused resources - Remove ability to clear individual search history - Add remove all query history menu item Change-Id: I4383d075310297163fd2206d1a5b9c8f4ed94078 Fix: 62741488 Fix: 31589605 Test: robotests
This commit is contained in:
@@ -210,7 +210,7 @@
|
||||
|
||||
<activity android:name=".search.SearchActivity"
|
||||
android:label="@string/search_settings"
|
||||
android:icon="@drawable/ic_search_history"
|
||||
android:icon="@drawable/ic_search_24dp"
|
||||
android:parentActivityName="Settings"
|
||||
android:theme="@style/Theme.Settings.NoActionBar">
|
||||
</activity>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 767 B |
Binary file not shown.
Before Width: | Height: | Size: 643 B |
Binary file not shown.
Before Width: | Height: | Size: 836 B |
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 16 KiB |
@@ -1,24 +0,0 @@
|
||||
<!-- Copyright (C) 2016 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"
|
||||
android:fillColor="#757575"/>
|
||||
</vector>
|
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2014, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:src="@drawable/ic_search_history_am"
|
||||
android:autoMirrored="true"
|
||||
/>
|
@@ -20,28 +20,25 @@
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="@dimen/dashboard_tile_image_size"
|
||||
android:layout_height="@dimen/dashboard_tile_image_size"
|
||||
android:scaleType="centerInside"
|
||||
android:layout_marginStart="@dimen/dashboard_tile_image_margin"
|
||||
android:layout_marginEnd="@dimen/dashboard_tile_image_margin"
|
||||
android:src="@drawable/ic_restore" />
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="test"
|
||||
android:layout_width="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:paddingStart="@dimen/preference_no_icon_padding_start"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem" />
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:layout_width="@dimen/dashboard_category_height"
|
||||
android:layout_height="@dimen/dashboard_category_height"
|
||||
android:paddingStart="@dimen/search_suggestion_item_image_margin_start"
|
||||
android:paddingEnd="@dimen/search_suggestion_item_image_margin_end"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_cross_grey_24dp" />
|
||||
|
||||
</LinearLayout>
|
@@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2014 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/search_title_padding_start"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:minWidth="@*android:dimen/preference_icon_minWidth"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/search_suggestion_item_image_size"
|
||||
android:layout_height="@dimen/search_suggestion_item_image_size"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_search_history"
|
||||
android:layout_marginStart="@dimen/search_suggestion_item_image_margin_start"
|
||||
android:layout_marginEnd="@dimen/search_suggestion_item_image_margin_end"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@@ -59,13 +59,6 @@
|
||||
<dimen name="switchbar_subsettings_margin_start">80dp</dimen>
|
||||
<dimen name="switchbar_subsettings_margin_end">24dp</dimen>
|
||||
|
||||
<!-- Search title (recent / results) padding start -->
|
||||
<dimen name="search_title_padding_start">24dp</dimen>
|
||||
|
||||
<!-- Result item image margin start / end -->
|
||||
<dimen name="search_result_item_image_margin_start">24dp</dimen>
|
||||
<dimen name="search_result_item_image_margin_end">32dp</dimen>
|
||||
|
||||
<dimen name="search_bar_height">64dp</dimen>
|
||||
|
||||
<!-- Dimensions for Wifi Assistant Card -->
|
||||
|
@@ -96,9 +96,6 @@
|
||||
<!-- Dashboard category panel elevation -->
|
||||
<dimen name="dashboard_category_elevation">2dp</dimen>
|
||||
|
||||
<!-- Dashboard category layout height -->
|
||||
<dimen name="dashboard_category_height">48dp</dimen>
|
||||
|
||||
<!-- Dashboard tile minimum height -->
|
||||
<dimen name="dashboard_tile_minimum_height">72dp</dimen>
|
||||
|
||||
@@ -116,26 +113,6 @@
|
||||
<dimen name="switchbar_subsettings_margin_start">72dp</dimen>
|
||||
<dimen name="switchbar_subsettings_margin_end">16dp</dimen>
|
||||
|
||||
<!-- Search Panel elevation -->
|
||||
<dimen name="search_panel_elevation">4dp</dimen>
|
||||
|
||||
<!-- Search title (recent / results) padding start -->
|
||||
<dimen name="search_title_padding_start">12dp</dimen>
|
||||
|
||||
<!-- Result item image size -->
|
||||
<dimen name="search_result_item_image_size">24dp</dimen>
|
||||
|
||||
<!-- Result item image margin start / end -->
|
||||
<dimen name="search_result_item_image_margin_start">12dp</dimen>
|
||||
<dimen name="search_result_item_image_margin_end">32dp</dimen>
|
||||
|
||||
<!-- Suggestion item image size -->
|
||||
<dimen name="search_suggestion_item_image_size">24dp</dimen>
|
||||
|
||||
<!-- Suggestion item image margin start / end -->
|
||||
<dimen name="search_suggestion_item_image_margin_start">32dp</dimen>
|
||||
<dimen name="search_suggestion_item_image_margin_end">32dp</dimen>
|
||||
|
||||
<!-- The following two margins need to match, with the caveat that
|
||||
the second should be negative. The second one ensures that the icons and text
|
||||
align despite the additional padding caused by the search bar's card background. -->
|
||||
|
@@ -2345,6 +2345,9 @@
|
||||
<!-- There are no search results for the user's search [CHAR LIMIT=NONE]-->
|
||||
<string name="search_settings_no_results">No results</string>
|
||||
|
||||
<!-- Button to clear all search history in Settings [CHAR LIMIT=40]-->
|
||||
<string name="search_clear_history">Clear history</string>
|
||||
|
||||
<!-- Display settings --><skip/>
|
||||
<!-- Sound & display settings screen, section header for settings related to display -->
|
||||
<string name="display_settings">Display</string>
|
||||
|
@@ -14,44 +14,44 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||
android:title="@string/date_and_time"
|
||||
settings:keywords="@string/keywords_date_and_time">
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||
android:title="@string/date_and_time"
|
||||
settings:keywords="@string/keywords_date_and_time">
|
||||
|
||||
<com.android.settingslib.RestrictedSwitchPreference android:key="auto_time"
|
||||
<com.android.settingslib.RestrictedSwitchPreference
|
||||
android:key="auto_time"
|
||||
android:title="@string/date_time_auto"
|
||||
android:summaryOn="@string/date_time_auto_summaryOn"
|
||||
android:summaryOff="@string/date_time_auto_summaryOff"
|
||||
settings:useAdditionalSummary="true"
|
||||
settings:restrictedSwitchSummary="@string/enabled_by_admin"
|
||||
/>
|
||||
settings:restrictedSwitchSummary="@string/enabled_by_admin" />
|
||||
|
||||
<SwitchPreference android:key="auto_zone"
|
||||
<SwitchPreference
|
||||
android:key="auto_zone"
|
||||
android:title="@string/zone_auto"
|
||||
android:summaryOn="@string/zone_auto_summaryOn"
|
||||
android:summaryOff="@string/zone_auto_summaryOff"
|
||||
/>
|
||||
android:summaryOff="@string/zone_auto_summaryOff" />
|
||||
|
||||
<Preference android:key="date"
|
||||
<Preference
|
||||
android:key="date"
|
||||
android:title="@string/date_time_set_date"
|
||||
android:summary="03/10/2008"
|
||||
/>
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
<Preference android:key="time"
|
||||
<Preference
|
||||
android:key="time"
|
||||
android:title="@string/date_time_set_time"
|
||||
android:summary="12:00am"
|
||||
/>
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.datetime.ZonePicker"
|
||||
android:key="timezone"
|
||||
android:title="@string/date_time_set_timezone"
|
||||
android:summary="GMT-8:00"
|
||||
/>
|
||||
android:summary="GMT-8:00" />
|
||||
|
||||
<SwitchPreference android:key="24 hour"
|
||||
android:title="@string/date_time_24hour"
|
||||
/>
|
||||
<SwitchPreference
|
||||
android:key="24 hour"
|
||||
android:title="@string/date_time_24hour" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -21,12 +21,16 @@ import android.app.LoaderManager;
|
||||
import android.content.Context;
|
||||
import android.content.Loader;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SavedQueryController implements LoaderManager.LoaderCallbacks {
|
||||
public class SavedQueryController implements LoaderManager.LoaderCallbacks,
|
||||
MenuItem.OnMenuItemClickListener {
|
||||
|
||||
// TODO: make a generic background task manager to handle one-off tasks like this one.
|
||||
|
||||
@@ -35,6 +39,8 @@ public class SavedQueryController implements LoaderManager.LoaderCallbacks {
|
||||
private static final int LOADER_ID_SAVED_QUERIES = 2;
|
||||
private static final String ARG_QUERY = "remove_query";
|
||||
|
||||
private static final int MENU_SEARCH_HISTORY = 1000;
|
||||
|
||||
private final Context mContext;
|
||||
private final LoaderManager mLoaderManager;
|
||||
private final SearchFeatureProvider mSearchFeatureProvider;
|
||||
@@ -55,7 +61,7 @@ public class SavedQueryController implements LoaderManager.LoaderCallbacks {
|
||||
case LOADER_ID_SAVE_QUERY_TASK:
|
||||
return new SavedQueryRecorder(mContext, args.getString(ARG_QUERY));
|
||||
case LOADER_ID_REMOVE_QUERY_TASK:
|
||||
return new SavedQueryRemover(mContext, args.getString(ARG_QUERY));
|
||||
return new SavedQueryRemover(mContext);
|
||||
case LOADER_ID_SAVED_QUERIES:
|
||||
return mSearchFeatureProvider.getSavedQueryLoader(mContext);
|
||||
}
|
||||
@@ -76,7 +82,21 @@ public class SavedQueryController implements LoaderManager.LoaderCallbacks {
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader loader) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (item.getItemId() != MENU_SEARCH_HISTORY) {
|
||||
return false;
|
||||
}
|
||||
removeQueries();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void buildMenuItem(Menu menu) {
|
||||
final MenuItem item =
|
||||
menu.add(Menu.NONE, MENU_SEARCH_HISTORY, Menu.NONE, R.string.search_clear_history);
|
||||
item.setOnMenuItemClickListener(this);
|
||||
}
|
||||
|
||||
public void saveQuery(String query) {
|
||||
@@ -85,9 +105,11 @@ public class SavedQueryController implements LoaderManager.LoaderCallbacks {
|
||||
mLoaderManager.restartLoader(LOADER_ID_SAVE_QUERY_TASK, args, this);
|
||||
}
|
||||
|
||||
public void removeQuery(String query) {
|
||||
/**
|
||||
* Remove all saved queries from DB
|
||||
*/
|
||||
public void removeQueries() {
|
||||
final Bundle args = new Bundle();
|
||||
args.putString(ARG_QUERY, query);
|
||||
mLoaderManager.restartLoader(LOADER_ID_REMOVE_QUERY_TASK, args, this);
|
||||
}
|
||||
|
||||
|
@@ -17,25 +17,21 @@
|
||||
|
||||
package com.android.settings.search;
|
||||
|
||||
import static com.android.settings.search.IndexDatabaseHelper.Tables.TABLE_SAVED_QUERIES;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteException;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.search.IndexDatabaseHelper;
|
||||
import com.android.settings.utils.AsyncLoader;
|
||||
|
||||
import static com.android.settings.search.IndexDatabaseHelper.Tables.TABLE_SAVED_QUERIES;
|
||||
|
||||
public class SavedQueryRemover extends AsyncLoader<Void> {
|
||||
|
||||
private static final String LOG_TAG = "SavedQueryRemover";
|
||||
|
||||
private final String mQuery;
|
||||
|
||||
public SavedQueryRemover(Context context, String query) {
|
||||
public SavedQueryRemover(Context context) {
|
||||
super(context);
|
||||
mQuery = query;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,8 +40,8 @@ public class SavedQueryRemover extends AsyncLoader<Void> {
|
||||
try {
|
||||
// First, delete all saved queries that are the same
|
||||
database.delete(TABLE_SAVED_QUERIES,
|
||||
IndexDatabaseHelper.SavedQueriesColumns.QUERY + " = ?",
|
||||
new String[]{mQuery});
|
||||
null /* where */,
|
||||
null /* whereArgs */);
|
||||
} catch (Exception e) {
|
||||
Log.d(LOG_TAG, "Cannot update saved Search queries", e);
|
||||
}
|
||||
|
@@ -25,12 +25,10 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
public class SavedQueryViewHolder extends SearchViewHolder {
|
||||
|
||||
public final TextView titleView;
|
||||
public final View removeButton;
|
||||
|
||||
public SavedQueryViewHolder(View view) {
|
||||
super(view);
|
||||
titleView = view.findViewById(android.R.id.title);
|
||||
removeButton = view.findViewById(android.R.id.icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,8 +38,7 @@ public class SavedQueryViewHolder extends SearchViewHolder {
|
||||
|
||||
@Override
|
||||
public void onBind(SearchFragment fragment, SearchResult result) {
|
||||
itemView.setOnClickListener(v -> fragment.onSavedQueryClicked(result.title));
|
||||
titleView.setText(result.title);
|
||||
titleView.setOnClickListener(v -> fragment.onSavedQueryClicked(result.title));
|
||||
removeButton.setOnClickListener(v -> fragment.onRemoveSavedQueryClicked(result.title));
|
||||
}
|
||||
}
|
@@ -32,6 +32,8 @@ import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
@@ -103,7 +105,7 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
||||
@VisibleForTesting
|
||||
SearchFeatureProvider mSearchFeatureProvider;
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
@VisibleForTesting
|
||||
SearchResultsAdapter mSearchAdapter;
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -164,6 +166,12 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
mSavedQueryController.buildMenuItem(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@@ -361,10 +369,6 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
||||
onQueryTextChange(queryString);
|
||||
}
|
||||
|
||||
public void onRemoveSavedQueryClicked(CharSequence title) {
|
||||
mSavedQueryController.removeQuery(title.toString());
|
||||
}
|
||||
|
||||
private void restartLoaders() {
|
||||
mShowingSavedQuery = false;
|
||||
final LoaderManager loaderManager = getLoaderManager();
|
||||
|
@@ -17,6 +17,8 @@
|
||||
|
||||
package com.android.settings.search;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -26,14 +28,14 @@ import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.android.settings.DisplaySettings;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.dashboard.SiteMapManager;
|
||||
import com.android.settings.gestures.SwipeToNotificationSettings;
|
||||
import com.android.settings.search.ResultPayload.Availability;
|
||||
import com.android.settings.search.ResultPayload.PayloadType;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.wifi.WifiSettings;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -48,8 +50,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class CursorToSearchResultConverterTest {
|
||||
@@ -60,7 +60,7 @@ public class CursorToSearchResultConverterTest {
|
||||
private static final String TARGET_CLASS = "a.b.c.class";
|
||||
private static final String KEY = "key";
|
||||
private static final Intent INTENT = new Intent("com.android.settings");
|
||||
private static final int ICON = R.drawable.ic_search_history;
|
||||
private static final int ICON = R.drawable.ic_search_24dp;
|
||||
private static final int BASE_RANK = 1;
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
|
@@ -17,14 +17,18 @@
|
||||
|
||||
package com.android.settings.search;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -38,10 +42,6 @@ import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class InlineSwitchViewHolderTest {
|
||||
@@ -65,7 +65,7 @@ public class InlineSwitchViewHolderTest {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
mIcon = context.getDrawable(R.drawable.ic_search_history);
|
||||
mIcon = context.getDrawable(R.drawable.ic_search_24dp);
|
||||
FakeFeatureFactory.setupForTest(mContext);
|
||||
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
|
||||
|
||||
|
@@ -85,7 +85,7 @@ public class IntentSearchViewHolderTest {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.search_intent_item, null);
|
||||
mHolder = new IntentSearchViewHolder(view);
|
||||
|
||||
mIcon = context.getDrawable(R.drawable.ic_search_history);
|
||||
mIcon = context.getDrawable(R.drawable.ic_search_24dp);
|
||||
mBadgedIcon = context.getDrawable(R.drawable.ic_add);
|
||||
when(mFragment.getActivity().getPackageManager()).thenReturn(mPackageManager);
|
||||
}
|
||||
|
@@ -18,11 +18,13 @@
|
||||
package com.android.settings.search;
|
||||
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.DatabaseTestUtils;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -33,8 +35,6 @@ import org.robolectric.annotation.Config;
|
||||
|
||||
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 SavedQueryRecorderAndRemoverTest {
|
||||
@@ -57,7 +57,7 @@ public class SavedQueryRecorderAndRemoverTest {
|
||||
public void canSaveAndRemoveQuery() {
|
||||
final String query = "test";
|
||||
mRecorder = new SavedQueryRecorder(mContext, query);
|
||||
mRemover = new SavedQueryRemover(mContext, query);
|
||||
mRemover = new SavedQueryRemover(mContext);
|
||||
|
||||
// Record a new query and load all queries from DB
|
||||
mRecorder.loadInBackground();
|
||||
@@ -75,4 +75,22 @@ public class SavedQueryRecorderAndRemoverTest {
|
||||
// Saved query list should be empty because it's removed.
|
||||
assertThat(results).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canRemoveAllQueriesAtOnce() {
|
||||
mRemover = new SavedQueryRemover(mContext);;
|
||||
|
||||
// Record a new query and load all queries from DB
|
||||
new SavedQueryRecorder(mContext, "Test1").loadInBackground();
|
||||
new SavedQueryRecorder(mContext, "Test2").loadInBackground();
|
||||
final SavedQueryLoader loader = new SavedQueryLoader(mContext);
|
||||
List<? extends SearchResult> results = loader.loadInBackground();
|
||||
assertThat(results.size()).isEqualTo(2);
|
||||
|
||||
mRemover.loadInBackground();
|
||||
results = loader.loadInBackground();
|
||||
|
||||
// Saved query list should be empty because it's removed.
|
||||
assertThat(results).isEmpty();
|
||||
}
|
||||
}
|
||||
|
@@ -26,8 +26,8 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -47,7 +47,6 @@ public class SavedQueryViewHolderTest {
|
||||
private SavedQueryViewHolder mHolder;
|
||||
private View mView;
|
||||
private View mTitleView;
|
||||
private View mRemoveButton;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -56,7 +55,6 @@ public class SavedQueryViewHolderTest {
|
||||
mView = LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.search_saved_query_item, null);
|
||||
mTitleView = mView.findViewById(android.R.id.title);
|
||||
mRemoveButton = mView.findViewById(android.R.id.icon);
|
||||
mHolder = new SavedQueryViewHolder(mView);
|
||||
}
|
||||
|
||||
@@ -65,10 +63,8 @@ public class SavedQueryViewHolderTest {
|
||||
final SearchResult result = mock(SearchResult.class);
|
||||
mHolder.onBind(mSearchFragment, result);
|
||||
|
||||
mTitleView.performClick();
|
||||
mRemoveButton.performClick();
|
||||
mHolder.itemView.performClick();
|
||||
|
||||
verify(mSearchFragment).onSavedQueryClicked(nullable(CharSequence.class));
|
||||
verify(mSearchFragment).onRemoveSavedQueryClicked(nullable(CharSequence.class));
|
||||
}
|
||||
}
|
||||
|
@@ -17,14 +17,16 @@
|
||||
|
||||
package com.android.settings.search;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.search.SearchResult.Builder;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -34,8 +36,6 @@ import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class SearchResultBuilderTest {
|
||||
@@ -57,7 +57,7 @@ public class SearchResultBuilderTest {
|
||||
mResultPayload = new ResultPayload(new Intent());
|
||||
|
||||
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
||||
mIcon = context.getDrawable(R.drawable.ic_search_history);
|
||||
mIcon = context.getDrawable(R.drawable.ic_search_24dp);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -17,6 +17,14 @@
|
||||
|
||||
package com.android.settings.search;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -26,10 +34,10 @@ import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.search.SearchResult.Builder;
|
||||
import com.android.settings.search.ranking.SearchResultsRankerCallback;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -49,14 +57,6 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class SearchResultsAdapterTest {
|
||||
@@ -553,7 +553,7 @@ public class SearchResultsAdapterTest {
|
||||
private Set<SearchResult> getIntentSampleResults() {
|
||||
Set<SearchResult> sampleResults = new HashSet<>();
|
||||
ArrayList<String> breadcrumbs = new ArrayList<>();
|
||||
final Drawable icon = mContext.getDrawable(R.drawable.ic_search_history);
|
||||
final Drawable icon = mContext.getDrawable(R.drawable.ic_search_24dp);
|
||||
final ResultPayload payload = new ResultPayload(null);
|
||||
final SearchResult.Builder builder = new Builder();
|
||||
builder.setTitle("title")
|
||||
|
Reference in New Issue
Block a user