Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7fbfda67 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Disable AssistGestureSetting search if not supported" into oc-mr1-dev

parents f8c9a63c eef16a8b
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -15,9 +15,10 @@
  limitations under the License.
  -->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<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:key="gesture_assist_settings_page"
    android:title="@string/assist_gesture_title">

    <com.android.settings.widget.VideoPreference
+9 −1
Original line number Diff line number Diff line
@@ -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();
                }
            };
}
+13 −4
Original line number Diff line number Diff line
@@ -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();
    }

@@ -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");
    }
}