Search in sources :

Example 16 with SwitchBar

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

the class DevelopmentSettingsDashboardFragmentTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    SwitchBar switchBar = new SwitchBar(mContext);
    mSwitch = switchBar.getSwitch();
    mDashboard = spy(new DevelopmentSettingsDashboardFragment());
    ReflectionHelpers.setField(mDashboard, "mSwitchBar", switchBar);
    mShadowUserManager = Shadow.extract(mContext.getSystemService(Context.USER_SERVICE));
    mShadowUserManager.setIsAdminUser(true);
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) Before(org.junit.Before)

Example 17 with SwitchBar

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

the class DevelopmentSwitchBarControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final Context context = RuntimeEnvironment.application;
    ShadowUserManager.getShadow().setIsAdminUser(true);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mSwitchBar = new SwitchBar(context);
    when(mSettings.getContext()).thenReturn(context);
}
Also used : Context(android.content.Context) SwitchBar(com.android.settings.widget.SwitchBar) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) Before(org.junit.Before)

Example 18 with SwitchBar

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

the class AutomaticStorageManagerSwitchBarControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mSwitchBar = new SwitchBar(mContext);
    mMetricsFeatureProvider = FakeFeatureFactory.setupForTest().getMetricsFeatureProvider();
    mPreference = new Preference(mContext);
    mController = new AutomaticStorageManagerSwitchBarController(mContext, mSwitchBar, mMetricsFeatureProvider, mPreference, mFragmentManager);
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) Preference(androidx.preference.Preference) Before(org.junit.Before)

Example 19 with SwitchBar

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

the class WifiTetherSettings method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (mUnavailable) {
        return;
    }
    // Assume we are in a SettingsActivity. This is only safe because we currently use
    // SettingsActivity as base for all preference fragments.
    final SettingsActivity activity = (SettingsActivity) getActivity();
    final SwitchBar switchBar = activity.getSwitchBar();
    mSwitchBarController = new WifiTetherSwitchBarController(activity, new SwitchBarController(switchBar));
    getSettingsLifecycle().addObserver(mSwitchBarController);
    switchBar.show();
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) SettingsActivity(com.android.settings.SettingsActivity) SwitchBarController(com.android.settings.widget.SwitchBarController)

Example 20 with SwitchBar

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

the class MobileNetworkSwitchControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
    when(mSubscriptionManager.setSubscriptionEnabled(eq(mSubId), anyBoolean())).thenReturn(true);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    when(mSubscription.getSubscriptionId()).thenReturn(mSubId);
    // Most tests want to have 2 available subscriptions so that the switch bar will show.
    SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
    when(sub2.getSubscriptionId()).thenReturn(456);
    SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSubscription, sub2));
    String key = "prefKey";
    mController = new MobileNetworkSwitchController(mContext, key);
    mController.init(mLifecycle, mSubscription.getSubscriptionId());
    mSwitchBar = new SwitchBar(mContext);
    when(mScreen.findPreference(key)).thenReturn(mLayoutPreference);
    when(mLayoutPreference.findViewById(R.id.switch_bar)).thenReturn(mSwitchBar);
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) SubscriptionInfo(android.telephony.SubscriptionInfo) 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