Search in sources :

Example 1 with LifecycleRegistry

use of androidx.lifecycle.LifecycleRegistry in project android_packages_apps_Settings by omnirom.

the class NetworkProviderSimListControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreference = new Preference(mContext);
    mPreference.setKey(KEY_PREFERENCE_SIM_LIST);
    mController = new MockNetworkProviderSimListController(mContext, mLifecycle);
    mLifecycleRegistry = new LifecycleRegistry(mLifecycleOwner);
    when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycleRegistry);
}
Also used : LifecycleRegistry(androidx.lifecycle.LifecycleRegistry) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 2 with LifecycleRegistry

use of androidx.lifecycle.LifecycleRegistry in project android_packages_apps_Settings by omnirom.

the class SubscriptionsPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mLifecycleRegistry = new LifecycleRegistry(mLifecycleOwner);
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
    when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
    when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
    when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
    when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
    when(mConnectivityManager.getActiveNetwork()).thenReturn(mActiveNetwork);
    when(mConnectivityManager.getNetworkCapabilities(mActiveNetwork)).thenReturn(mNetworkCapabilities);
    when(mUserManager.isAdminUser()).thenReturn(true);
    when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycleRegistry);
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreferenceScreen.setInitialExpandedChildrenCount(3);
    mPreferenceCategory = new PreferenceCategory(mContext);
    mPreferenceCategory.setKey(KEY);
    mPreferenceCategory.setOrderingAsAdded(true);
    mPreferenceScreen.addPreference(mPreferenceCategory);
    mOnChildUpdatedCount = 0;
    mUpdateListener = () -> mOnChildUpdatedCount++;
    sInjector = spy(new SubsPrefCtrlInjector());
    initializeMethod(true, 1, 1, 1, false, false);
    mController = new FakeSubscriptionsPreferenceController(mContext, mLifecycle, mUpdateListener, KEY, 5);
    Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0);
}
Also used : LifecycleRegistry(androidx.lifecycle.LifecycleRegistry) PreferenceCategory(androidx.preference.PreferenceCategory) SubsPrefCtrlInjector(com.android.settings.network.SubscriptionsPreferenceController.SubsPrefCtrlInjector) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 3 with LifecycleRegistry

use of androidx.lifecycle.LifecycleRegistry in project android_packages_apps_Settings by omnirom.

the class NetworkProviderCallsSmsControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreference = new RestrictedPreference(mContext);
    mPreference.setKey(KEY_PREFERENCE_CALLS_SMS);
    mController = new MockNetworkProviderCallsSmsController(mContext, mLifecycle);
    mController.setInService(true);
    mLifecycleRegistry = new LifecycleRegistry(mLifecycleOwner);
    when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycleRegistry);
}
Also used : LifecycleRegistry(androidx.lifecycle.LifecycleRegistry) RestrictedPreference(com.android.settingslib.RestrictedPreference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 4 with LifecycleRegistry

use of androidx.lifecycle.LifecycleRegistry in project android_packages_apps_Settings by omnirom.

the class NetworkProviderDownloadedSimListControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreference = new Preference(mContext);
    mPreference.setKey(KEY_PREFERENCE_DOWNLOADED_SIM);
    mController = new MockNetworkProviderDownloadedSimListController(mContext, mLifecycle);
    mAddMorePreference = new Preference(mContext);
    mAddMorePreference.setKey(KEY_ADD_MORE);
    mAddMorePreference.setVisible(true);
    mLifecycleRegistry = new LifecycleRegistry(mLifecycleOwner);
    when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycleRegistry);
}
Also used : LifecycleRegistry(androidx.lifecycle.LifecycleRegistry) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 5 with LifecycleRegistry

use of androidx.lifecycle.LifecycleRegistry in project android_packages_apps_Settings by omnirom.

the class MobileNetworkPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
    when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreference = new Preference(mContext);
    mPreference.setKey(MobileNetworkPreferenceController.KEY_MOBILE_NETWORK_SETTINGS);
    mLifecycleRegistry = new LifecycleRegistry(mLifecycleOwner);
    when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycleRegistry);
}
Also used : LifecycleRegistry(androidx.lifecycle.LifecycleRegistry) RestrictedPreference(com.android.settingslib.RestrictedPreference) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Aggregations

LifecycleRegistry (androidx.lifecycle.LifecycleRegistry)5 PreferenceManager (androidx.preference.PreferenceManager)5 Before (org.junit.Before)5 Preference (androidx.preference.Preference)3 RestrictedPreference (com.android.settingslib.RestrictedPreference)2 PreferenceCategory (androidx.preference.PreferenceCategory)1 SubsPrefCtrlInjector (com.android.settings.network.SubscriptionsPreferenceController.SubsPrefCtrlInjector)1