Search in sources :

Example 36 with SwitchBar

use of com.android.settings.widget.SwitchBar in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothEnablerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mRestrictedSwitchPreference = new RestrictedSwitchPreference(mContext);
    mSwitchController = spy(new SwitchBarController(new SwitchBar(mContext)));
    mBluetoothEnabler = new BluetoothEnabler(mContext, mSwitchController, mMetricsFeatureProvider, 123, mRestrictionUtils);
    mHolder = PreferenceViewHolder.createInstanceForTests(mock(View.class));
    mRestrictedSwitchPreference.onBindViewHolder(mHolder);
    mBluetoothEnabler.setToggleCallback(mCallback);
    mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) SwitchBarController(com.android.settings.widget.SwitchBarController) Before(org.junit.Before)

Example 37 with SwitchBar

use of com.android.settings.widget.SwitchBar in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BlockPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    ShadowApplication shadowApplication = ShadowApplication.getInstance();
    shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
    shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
    mContext = RuntimeEnvironment.application;
    mController = spy(new BlockPreferenceController(mContext, mImportanceListener, mBackend));
    mSwitch = new SwitchBar(mContext);
    when(mPreference.findViewById(R.id.switch_bar)).thenReturn(mSwitch);
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) ShadowApplication(org.robolectric.shadows.ShadowApplication) Before(org.junit.Before)

Aggregations

SwitchBar (com.android.settings.widget.SwitchBar)37 Before (org.junit.Before)26 SwitchBarController (com.android.settings.widget.SwitchBarController)12 SettingsActivity (com.android.settings.SettingsActivity)10 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)8 Context (android.content.Context)7 Preference (android.support.v7.preference.Preference)6 FeatureFactory (com.android.settings.overlay.FeatureFactory)6 FakeFeatureFactory (com.android.settings.testutils.FakeFeatureFactory)6 SubscriptionInfo (android.telephony.SubscriptionInfo)1 Preference (androidx.preference.Preference)1 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)1 LayoutPreference (com.android.settingslib.widget.LayoutPreference)1 ShadowApplication (org.robolectric.shadows.ShadowApplication)1