Search in sources :

Example 51 with FakeFeatureFactory

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

the class SetNewPasswordActivityTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
    mockMetricsProvider = fakeFeatureFactory.getMetricsFeatureProvider();
    when(mockMetricsProvider.getAttribution(any())).thenReturn(SettingsEnums.PAGE_UNKNOWN);
    mProvisioned = Settings.Global.getInt(RuntimeEnvironment.application.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
}
Also used : FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Before(org.junit.Before)

Example 52 with FakeFeatureFactory

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

the class RedactNotificationPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
    when(featureFactory.securityFeatureProvider.getLockPatternUtils(mMockContext)).thenReturn(mLockPatternUtils);
    when(mMockContext.getContentResolver()).thenReturn(mContext.getContentResolver());
    when(mMockContext.getSystemService(UserManager.class)).thenReturn(mUm);
    when(mMockContext.getSystemService(DevicePolicyManager.class)).thenReturn(mDpm);
    when(mMockContext.getSystemService(KeyguardManager.class)).thenReturn(mKm);
    when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] { 10 });
    mController = new RedactNotificationPreferenceController(mMockContext, RedactNotificationPreferenceController.KEY_LOCKSCREEN_REDACT);
    mPreference = new Preference(mContext);
    mPreference.setKey(mController.getPreferenceKey());
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    mWorkController = new RedactNotificationPreferenceController(mMockContext, RedactNotificationPreferenceController.KEY_LOCKSCREEN_WORK_PROFILE_REDACT);
    mWorkPreference = new Preference(mContext);
    mWorkPreference.setKey(mWorkController.getPreferenceKey());
    when(mScreen.findPreference(mWorkController.getPreferenceKey())).thenReturn(mWorkPreference);
}
Also used : Preference(androidx.preference.Preference) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Before(org.junit.Before)

Example 53 with FakeFeatureFactory

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

the class WifiTetherSettingsTest method startFragment_notAdminUser_shouldRemoveAllPreferences.

@Test
public void startFragment_notAdminUser_shouldRemoveAllPreferences() {
    final WifiTetherSettings settings = spy(new WifiTetherSettings());
    final FragmentActivity activity = mock(FragmentActivity.class);
    when(settings.getActivity()).thenReturn(activity);
    when(settings.getContext()).thenReturn(mContext);
    final Resources.Theme theme = mContext.getTheme();
    when(activity.getTheme()).thenReturn(theme);
    when(activity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
    doNothing().when(settings).onCreatePreferences(any(Bundle.class), nullable(String.class));
    final FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
    ReflectionHelpers.setField(settings, "mDashboardFeatureProvider", fakeFeatureFactory.dashboardFeatureProvider);
    final TextView emptyTextView = mock(TextView.class);
    ReflectionHelpers.setField(settings, "mEmptyTextView", emptyTextView);
    final PreferenceScreen screen = mock(PreferenceScreen.class);
    doReturn(screen).when(settings).getPreferenceScreen();
    settings.onCreate(Bundle.EMPTY);
    settings.onStart();
    verify(screen).removeAll();
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) PreferenceScreen(androidx.preference.PreferenceScreen) Bundle(android.os.Bundle) TextView(android.widget.TextView) Resources(android.content.res.Resources) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Test(org.junit.Test)

Example 54 with FakeFeatureFactory

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

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 55 with FakeFeatureFactory

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

the class TopLevelSettingsTest method setUp.

@Before
public void setUp() {
    mContext = RuntimeEnvironment.application;
    mSettings = spy(new TopLevelSettings());
    when(mSettings.getContext()).thenReturn(mContext);
    final FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
    when(featureFactory.dashboardFeatureProvider.getTilesForCategory(nullable(String.class))).thenReturn(null);
    mSettings.onAttach(mContext);
}
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