Merge "Remove silky flag from System for official release" into sc-dev
This commit is contained in:
@@ -20,22 +20,9 @@ import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowSecureSettings;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -46,7 +33,6 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -57,8 +43,6 @@ public class GesturesSettingsPreferenceControllerTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Activity mActivity;
|
||||
@Mock
|
||||
private Preference mPreference;
|
||||
|
||||
private GesturesSettingPreferenceController mController;
|
||||
|
||||
@@ -67,7 +51,6 @@ public class GesturesSettingsPreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
FakeFeatureFactory.setupForTest();
|
||||
mController = new GesturesSettingPreferenceController(mActivity);
|
||||
FeatureFlagUtils.setEnabled(RuntimeEnvironment.application, FeatureFlags.SILKY_HOME, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,43 +79,4 @@ public class GesturesSettingsPreferenceControllerTest {
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowSecureSettings.class)
|
||||
public void updateState_assistSupported_shouldSetToAssistGestureStatus() {
|
||||
final FakeFeatureFactory featureFactory =
|
||||
(FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity);
|
||||
when(featureFactory.assistGestureFeatureProvider.isSupported(any(Context.class)))
|
||||
.thenReturn(true);
|
||||
when(featureFactory.assistGestureFeatureProvider.isSensorAvailable(any(Context.class)))
|
||||
.thenReturn(true);
|
||||
|
||||
final ContentResolver cr = mActivity.getContentResolver();
|
||||
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 0);
|
||||
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 0);
|
||||
mController.updateState(mPreference);
|
||||
verify(mActivity).getText(R.string.language_input_gesture_summary_off);
|
||||
|
||||
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 1);
|
||||
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 0);
|
||||
mController.updateState(mPreference);
|
||||
verify(mActivity).getText(R.string.language_input_gesture_summary_on_with_assist);
|
||||
|
||||
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 0);
|
||||
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 1);
|
||||
mController.updateState(mPreference);
|
||||
verify(mActivity).getText(R.string.language_input_gesture_summary_on_non_assist);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowSecureSettings.class)
|
||||
public void updateState_sensorNotAvailable_shouldSetToEmptyStatus() {
|
||||
final FakeFeatureFactory featureFactory =
|
||||
(FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity);
|
||||
when(featureFactory.assistGestureFeatureProvider.isSensorAvailable(any(Context.class)))
|
||||
.thenReturn(false);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
verify(mPreference).setSummary("");
|
||||
}
|
||||
}
|
||||
|
@@ -18,14 +18,6 @@ package com.android.settings.system;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -35,11 +27,9 @@ import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = ShadowUserManager.class)
|
||||
public class ResetPreferenceControllerTest {
|
||||
|
||||
private static final String KEY_RESET_DASHBOARD = "reset_dashboard";
|
||||
private ShadowUserManager mShadowUserManager;
|
||||
|
||||
private Context mContext;
|
||||
private ResetPreferenceController mController;
|
||||
@@ -48,8 +38,6 @@ public class ResetPreferenceControllerTest {
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = new ResetPreferenceController(mContext, KEY_RESET_DASHBOARD);
|
||||
mShadowUserManager = ShadowUserManager.getShadow();
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,35 +50,4 @@ public class ResetPreferenceControllerTest {
|
||||
public void isAvailable_ifNotVisible_false() {
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_systemUser_shouldReturnFullSummary() {
|
||||
mShadowUserManager.setIsAdminUser(true);
|
||||
|
||||
assertThat(mController.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.reset_dashboard_summary));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_nonSystemUser_shouldReturnAppsSummary() {
|
||||
mShadowUserManager.setIsAdminUser(false);
|
||||
mShadowUserManager.setIsDemoUser(false);
|
||||
|
||||
assertThat(mController.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.reset_dashboard_summary_onlyApps));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_demoUser_shouldReturnFullSummary() {
|
||||
mShadowUserManager.setIsAdminUser(false);
|
||||
|
||||
// Place the device in demo mode.
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DEVICE_DEMO_MODE, 1);
|
||||
|
||||
// Indicate the user is a demo user.
|
||||
mShadowUserManager.addUser(UserHandle.myUserId(), "test", UserInfo.FLAG_DEMO);
|
||||
|
||||
assertThat(mController.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.reset_dashboard_summary));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user