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);
}
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);
}
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();
}
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));
}
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);
}
Aggregations