Search in sources :

Example 86 with Lifecycle

use of com.android.settingslib.core.lifecycle.Lifecycle in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class EnabledNetworkModePreferenceControllerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mContext = spy(RuntimeEnvironment.application);
    doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
    doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
    doReturn(mCarrierConfigManager).when(mContext).getSystemService(CarrierConfigManager.class);
    doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
    doReturn(mInvalidTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    doReturn(mContext).when(mContext).createPackageContext(anyString(), anyInt());
    doReturn(mServiceState).when(mTelephonyManager).getServiceState();
    mPersistableBundle = new PersistableBundle();
    doReturn(mPersistableBundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
    mPreference = new ListPreference(mContext);
    mPreference.setEntries(R.array.enabled_networks_choices);
    mPreference.setEntryValues(R.array.enabled_networks_values);
    mController = new EnabledNetworkModePreferenceController(mContext, KEY);
    mController.init(mLifecycle, SUB_ID);
    mPreference.setKey(mController.getPreferenceKey());
}
Also used : PersistableBundle(android.os.PersistableBundle) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) ListPreference(androidx.preference.ListPreference) Before(org.junit.Before)

Example 87 with Lifecycle

use of com.android.settingslib.core.lifecycle.Lifecycle 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)

Example 88 with Lifecycle

use of com.android.settingslib.core.lifecycle.Lifecycle in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LockScreenPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    ShadowApplication.getInstance().setSystemService(Context.USER_SERVICE, mUm);
    mFeatureFactory = FakeFeatureFactory.setupForTest();
    when(mFeatureFactory.securityFeatureProvider.getLockPatternUtils(mContext)).thenReturn(mLockPatternUtils);
    when(mUm.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] { FAKE_PROFILE_USER_ID });
    mPreference = new Preference(mContext);
    when(mScreen.findPreference(anyString())).thenReturn(mPreference);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mController = new LockScreenPreferenceController(mContext, "Test_key");
}
Also used : Preference(androidx.preference.Preference) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) Before(org.junit.Before)

Example 89 with Lifecycle

use of com.android.settingslib.core.lifecycle.Lifecycle in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiP2PPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
    when(mScreen.findPreference(anyString())).thenReturn(mWifiDirectPreference);
    when(mContext.getSystemService(eq(Service.LOCATION_SERVICE))).thenReturn(mLocationManager);
    mController = new WifiP2pPreferenceController(mContext, mLifecycle, mWifiManager);
}
Also used : Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) Before(org.junit.Before)

Example 90 with Lifecycle

use of com.android.settingslib.core.lifecycle.Lifecycle in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiTetherPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    FakeFeatureFactory.setupForTest();
    mPreference = new MasterSwitchPreference(RuntimeEnvironment.application);
    when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mConnectivityManager);
    when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
    when(mScreen.findPreference(anyString())).thenReturn(mPreference);
    when(mWifiManager.getWifiApConfiguration()).thenReturn(mWifiConfiguration);
    mWifiConfiguration.SSID = SSID;
    when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[] { "1", "2" });
    mController = new WifiTetherPreferenceController(mContext, mLifecycle, false);
    mController.displayPreference(mScreen);
}
Also used : MasterSwitchPreference(com.android.settings.widget.MasterSwitchPreference) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) Before(org.junit.Before)

Aggregations

Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)259 Before (org.junit.Before)218 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)33 ArrayList (java.util.ArrayList)32 PreferenceManager (androidx.preference.PreferenceManager)16 Preference (androidx.preference.Preference)15 TextView (android.widget.TextView)11 SettingsActivity (com.android.settings.SettingsActivity)10 Handler (android.os.Handler)9 LinkProperties (android.net.LinkProperties)8 Network (android.net.Network)8 NetworkRequest (android.net.NetworkRequest)8 LockScreenNotificationPreferenceController (com.android.settings.notification.LockScreenNotificationPreferenceController)8 BluetoothManager (android.bluetooth.BluetoothManager)7 Intent (android.content.Intent)7 PreferenceCategory (androidx.preference.PreferenceCategory)7 SwitchBar (com.android.settings.widget.SwitchBar)7 BluetoothCodecConfig (android.bluetooth.BluetoothCodecConfig)6 Bundle (android.os.Bundle)6 RecyclerView (android.support.v7.widget.RecyclerView)6