Search in sources :

Example 21 with FakeFeatureFactory

use of com.android.settings.testutils.FakeFeatureFactory in project android_packages_apps_Settings by omnirom.

the class GesturesSettingsPreferenceControllerTest method updateState_sensorNotAvailable_shouldSetToEmptyStatus.

@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("");
}
Also used : Context(android.content.Context) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Test(org.junit.Test) Config(org.robolectric.annotation.Config) TestConfig(com.android.settings.TestConfig)

Example 22 with FakeFeatureFactory

use of com.android.settings.testutils.FakeFeatureFactory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AutomaticStorageManagementSwitchPreferenceControllerTest method togglingShouldCauseMetricsEvent.

@Test
public void togglingShouldCauseMetricsEvent() {
    // FakeFeatureFactory uses mock contexts, so this test scaffolds itself rather than using
    // the instance variables.
    final FakeFeatureFactory factory = FakeFeatureFactory.setupForTest();
    final AutomaticStorageManagementSwitchPreferenceController controller = new AutomaticStorageManagementSwitchPreferenceController(mMockContext, "testkey");
    ReflectionHelpers.setField(controller, "mMetricsFeatureProvider", factory.metricsFeatureProvider);
    controller.setFragmentManager(mFragmentManager);
    controller.onSwitchToggled(true);
    verify(factory.metricsFeatureProvider, times(1)).action(any(Context.class), eq(MetricsEvent.ACTION_TOGGLE_STORAGE_MANAGER), eq(true));
}
Also used : Context(android.content.Context) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Test(org.junit.Test)

Example 23 with FakeFeatureFactory

use of com.android.settings.testutils.FakeFeatureFactory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class GesturesSettingsPreferenceControllerTest method updateState_sensorNotAvailable_shouldSetToEmptyStatus.

@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("");
}
Also used : Context(android.content.Context) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 24 with FakeFeatureFactory

use of com.android.settings.testutils.FakeFeatureFactory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class GesturesSettingsPreferenceControllerTest method updateState_assistSupported_shouldSetToAssistGestureStatus.

@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);
}
Also used : Context(android.content.Context) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) ContentResolver(android.content.ContentResolver) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 25 with FakeFeatureFactory

use of com.android.settings.testutils.FakeFeatureFactory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LockUnificationPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    ShadowApplication.getInstance().setSystemService(Context.USER_SERVICE, mUm);
    when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] { FAKE_PROFILE_USER_ID });
    final FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
    when(featureFactory.securityFeatureProvider.getLockPatternUtils(mContext)).thenReturn(mLockPatternUtils);
}
Also used : FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Before(org.junit.Before)

Aggregations

FakeFeatureFactory (com.android.settings.testutils.FakeFeatureFactory)58 Test (org.junit.Test)35 Before (org.junit.Before)28 Context (android.content.Context)26 Config (org.robolectric.annotation.Config)22 TestConfig (com.android.settings.TestConfig)17 Bundle (android.os.Bundle)12 ArrayList (java.util.ArrayList)11 Activity (android.app.Activity)10 PackageManager (android.content.pm.PackageManager)10 Preference (android.support.v7.preference.Preference)10 ContentResolver (android.content.ContentResolver)7 AppOpsManager (android.app.AppOpsManager)5 Fragment (android.app.Fragment)5 LoaderManager (android.app.LoaderManager)5 ApplicationInfo (android.content.pm.ApplicationInfo)5 Drawable (android.graphics.drawable.Drawable)5 BatteryStats (android.os.BatteryStats)5 UserHandle (android.os.UserHandle)5 RecyclerView (android.support.v7.widget.RecyclerView)5