use of com.android.settings.testutils.FakeFeatureFactory in project android_packages_apps_Settings by omnirom.
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);
}
use of com.android.settings.testutils.FakeFeatureFactory in project android_packages_apps_Settings by omnirom.
the class WifiTetherSettingsTest method startFragment_notAdminUser_shouldRemoveAllPreferences.
@Test
@Config(shadows = ShadowFragment.class)
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 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[] { 0 });
mController = new RedactNotificationPreferenceController(mMockContext, RedactNotificationPreferenceController.KEY_LOCKSCREEN_REDACT);
mPreference = new RestrictedSwitchPreference(mContext);
mPreference.setKey(mController.getPreferenceKey());
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
assertThat(mController.mProfileUserId).isEqualTo(0);
when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] { 0, 10 });
mWorkController = new RedactNotificationPreferenceController(mMockContext, RedactNotificationPreferenceController.KEY_LOCKSCREEN_WORK_PROFILE_REDACT);
mWorkPreference = new RestrictedSwitchPreference(mContext);
mWorkPreference.setKey(mWorkController.getPreferenceKey());
when(mScreen.findPreference(mWorkController.getPreferenceKey())).thenReturn(mWorkPreference);
assertThat(mWorkController.mProfileUserId).isEqualTo(10);
}
Aggregations