Fix assist gesture settings summary
Fixes: 62841640 Test: make -j RunSettingsRoboTests && manual testing of settings Merged-In: I75ffce4ff1054dad6b2733a7d4f6bc7e526a8034 Change-Id: I75ffce4ff1054dad6b2733a7d4f6bc7e526a8034
This commit is contained in:
@@ -16,12 +16,18 @@
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import static android.provider.Settings.Secure.ASSIST_GESTURE_ENABLED;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
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;
|
||||
@@ -32,11 +38,6 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import static android.provider.Settings.Secure.ASSIST_GESTURE_ENABLED;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class AssistGesturePreferenceControllerTest {
|
||||
@@ -53,12 +54,13 @@ public class AssistGesturePreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
FakeFeatureFactory.setupForTest(mContext);
|
||||
mFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
|
||||
mController = new AssistGesturePreferenceController(mContext, null, KEY_ASSIST);
|
||||
mController = new AssistGesturePreferenceController(mContext, null, KEY_ASSIST, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_whenSupported_shouldReturnTrue() {
|
||||
when(mFactory.assistGestureFeatureProvider.isSupported(mContext)).thenReturn(true);
|
||||
mController.mAssistOnly = false;
|
||||
when(mFactory.assistGestureFeatureProvider.isSensorAvailable(mContext)).thenReturn(true);
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@@ -73,7 +75,7 @@ public class AssistGesturePreferenceControllerTest {
|
||||
// Set the setting to be enabled.
|
||||
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
||||
Settings.System.putInt(context.getContentResolver(), ASSIST_GESTURE_ENABLED, 1);
|
||||
mController = new AssistGesturePreferenceController(context, null, KEY_ASSIST);
|
||||
mController = new AssistGesturePreferenceController(context, null, KEY_ASSIST, false);
|
||||
|
||||
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
||||
}
|
||||
@@ -83,7 +85,7 @@ public class AssistGesturePreferenceControllerTest {
|
||||
// Set the setting to be disabled.
|
||||
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
||||
Settings.System.putInt(context.getContentResolver(), ASSIST_GESTURE_ENABLED, 0);
|
||||
mController = new AssistGesturePreferenceController(context, null, KEY_ASSIST);
|
||||
mController = new AssistGesturePreferenceController(context, null, KEY_ASSIST, false);
|
||||
|
||||
assertThat(mController.isSwitchPrefEnabled()).isFalse();
|
||||
}
|
||||
|
@@ -163,18 +163,29 @@ public class LanguageAndInputSettingsTest {
|
||||
(FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity);
|
||||
when(featureFactory.assistGestureFeatureProvider.isSupported(any(Context.class)))
|
||||
.thenReturn(true);
|
||||
when(featureFactory.assistGestureFeatureProvider.isSensorAvailable(any(Context.class)))
|
||||
.thenReturn(true);
|
||||
|
||||
final SummaryLoader loader = mock(SummaryLoader.class);
|
||||
SummaryLoader.SummaryProvider provider = mFragment.SUMMARY_PROVIDER_FACTORY
|
||||
.createSummaryProvider(mActivity, loader);
|
||||
|
||||
ShadowSecureSettings.putInt(null, Settings.Secure.ASSIST_GESTURE_ENABLED, 0);
|
||||
ShadowSecureSettings.putInt(null, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 0);
|
||||
provider.setListening(true);
|
||||
verify(mActivity).getString(R.string.language_input_gesture_summary_off);
|
||||
|
||||
ShadowSecureSettings.putInt(null, Settings.Secure.ASSIST_GESTURE_ENABLED, 1);
|
||||
ShadowSecureSettings.putInt(null, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 0);
|
||||
provider.setListening(true);
|
||||
verify(mActivity).getString(R.string.language_input_gesture_summary_on_with_assist);
|
||||
verify(mActivity).getString(
|
||||
R.string.language_input_gesture_summary_on_with_assist);
|
||||
|
||||
ShadowSecureSettings.putInt(null, Settings.Secure.ASSIST_GESTURE_ENABLED, 0);
|
||||
ShadowSecureSettings.putInt(null, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 1);
|
||||
provider.setListening(true);
|
||||
verify(mActivity).getString(
|
||||
R.string.language_input_gesture_summary_on_non_assist);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user