use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.
the class ZenModeRemindersPreferenceControllerTest method updateState_TotalSilence.
@Test
public void updateState_TotalSilence() {
Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
final SwitchPreference mockPref = mock(SwitchPreference.class);
mController.updateState(mockPref);
verify(mockPref).setEnabled(false);
verify(mockPref).setChecked(false);
}
use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.
the class ContactDiscoveryPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mContext = spy(RuntimeEnvironment.application);
doReturn(mImsManager).when(mContext).getSystemService(ImsManager.class);
doReturn(mImsRcsManager).when(mImsManager).getImsRcsManager(anyInt());
doReturn(mRcsUceAdapter).when(mImsRcsManager).getUceAdapter();
doReturn(mCarrierConfigManager).when(mContext).getSystemService(CarrierConfigManager.class);
doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(eq(TEST_SUB_ID));
// Start all tests with presence being disabled.
setRcsPresenceConfig(false);
doReturn(mContentResolver).when(mContext).getContentResolver();
doReturn(mFragmentTransaction).when(mFragmentManager).beginTransaction();
mPreferenceControllerUT = new ContactDiscoveryPreferenceController(mContext, "ContactDiscovery");
// Ensure subscriptionInfo check doesn't fail.
SubscriptionUtil.setAvailableSubscriptionsForTesting(Collections.emptyList());
mPreferenceControllerUT.init(mFragmentManager, TEST_SUB_ID, mLifecycle);
mSwitchPreferenceUT = spy(new SwitchPreference(mContext));
mSwitchPreferenceUT.setKey(mPreferenceControllerUT.getPreferenceKey());
mPreferenceControllerUT.preference = mSwitchPreferenceUT;
}
use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.
the class DialPadTonePreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
when(mSetting.getActivity()).thenReturn(mActivity);
when(mActivity.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
when(mActivity.getContentResolver()).thenReturn(mContentResolver);
mPreference = new SwitchPreference(RuntimeEnvironment.application);
mController = new DialPadTonePreferenceController(mContext, mSetting, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
doReturn(mScreen).when(mSetting).getPreferenceScreen();
}
use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.
the class DockingSoundPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mSetting.getActivity()).thenReturn(mActivity);
when(mActivity.getContentResolver()).thenReturn(mContentResolver);
mPreference = new SwitchPreference(RuntimeEnvironment.application);
when(mActivity.getResources().getBoolean(com.android.settings.R.bool.has_dock_settings)).thenReturn(true);
mController = new DockingSoundPreferenceController(mContext, mSetting, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
doReturn(mScreen).when(mSetting).getPreferenceScreen();
}
use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.
the class DataUsagePreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
final TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
final ShadowTelephonyManager shadowTelephonyManager = Shadows.shadowOf(telephonyManager);
shadowTelephonyManager.setTelephonyManagerForSubscriptionId(SUB_ID, telephonyManager);
shadowTelephonyManager.setTelephonyManagerForSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID, telephonyManager);
doReturn(mNetworkStatsManager).when(mContext).getSystemService(NetworkStatsManager.class);
mPreference = new SwitchPreference(mContext);
mController = spy(new DataUsagePreferenceController(mContext, "data_usage"));
mController.init(SUB_ID);
mPreference.setKey(mController.getPreferenceKey());
}
Aggregations