Disable AssistGestureSetting search if not supported
Change-Id: Id5f79506635592d98783b2b99b7ee09dd223c43c Fixes: 64066820 Test: robotests
This commit is contained in:
@@ -15,10 +15,11 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||
android:title="@string/assist_gesture_title">
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:key="gesture_assist_settings_page"
|
||||
android:title="@string/assist_gesture_title">
|
||||
|
||||
<com.android.settings.widget.VideoPreference
|
||||
android:key="gesture_assist_video"
|
||||
@@ -28,6 +29,6 @@
|
||||
<SwitchPreference
|
||||
android:key="gesture_assist"
|
||||
android:title="@string/assist_gesture_title"
|
||||
app:keywords="@string/keywords_assist_gesture_launch"/>
|
||||
app:keywords="@string/keywords_assist_gesture_launch" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -79,9 +79,17 @@ public class AssistGestureSettings extends DashboardFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> getPreferenceControllers(Context context) {
|
||||
public List<AbstractPreferenceController> getPreferenceControllers(
|
||||
Context context) {
|
||||
return buildPreferenceControllers(context, null /* lifecycle */);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return new AssistGesturePreferenceController(context, null /* lifecycle */,
|
||||
null /* key */, false /* assistOnly */)
|
||||
.isAvailable();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -34,6 +34,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
@@ -45,14 +46,12 @@ public class AssistGestureSettingsTest {
|
||||
@Mock
|
||||
private Context mContext;
|
||||
private FakeFeatureFactory mFakeFeatureFactory;
|
||||
private AssistGestureFeatureProvider mFeatureProvider;
|
||||
private AssistGestureSettings mSettings;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mFakeFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
|
||||
mFeatureProvider = mFakeFeatureFactory.getAssistGestureFeatureProvider();
|
||||
mSettings = new AssistGestureSettings();
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ public class AssistGestureSettingsTest {
|
||||
@Test
|
||||
public void testGetPreferenceControllers_shouldAllBeCreated() {
|
||||
final List<AbstractPreferenceController> controllers =
|
||||
mSettings.getPreferenceControllers(mContext);
|
||||
mSettings.getPreferenceControllers(mContext);
|
||||
assertThat(controllers.isEmpty()).isFalse();
|
||||
}
|
||||
|
||||
@@ -79,5 +78,15 @@ public class AssistGestureSettingsTest {
|
||||
assertThat(indexRes).isNotNull();
|
||||
assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchIndexProvider_noSensor_shouldDisablePageSearch() {
|
||||
when(mFakeFeatureFactory.assistGestureFeatureProvider.isSensorAvailable(any(Context.class)))
|
||||
.thenReturn(false);
|
||||
|
||||
assertThat(AssistGestureSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
|
||||
RuntimeEnvironment.application))
|
||||
.contains("gesture_assist_settings_page");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user