Search in sources :

Example 11 with ShadowTelephonyManager

use of org.robolectric.shadows.ShadowTelephonyManager in project android_packages_apps_Settings by omnirom.

the class RenameMobileNetworkDialogFragmentTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    Context context = spy(RuntimeEnvironment.application);
    final ShadowTelephonyManager stm = Shadow.extract(context.getSystemService(TelephonyManager.class));
    stm.setTelephonyManagerForSubscriptionId(mSubscriptionId, mTelephonyMgr);
    when(mTelephonyMgr.createForSubscriptionId(anyInt())).thenReturn(mTelephonyMgr);
    when(mSubscriptionInfo.getSubscriptionId()).thenReturn(mSubscriptionId);
    when(mSubscriptionInfo.getDisplayName()).thenReturn("test");
    when(mSubscriptionInfo.getCarrierName()).thenReturn("fake carrier name");
    when(mSubscriptionMgr.setDisplayName(any(), anyInt(), anyInt())).thenReturn(0);
    mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).setup().get());
    mFragment = spy(RenameMobileNetworkDialogFragment.newInstance(mSubscriptionId));
    doReturn(mSubscriptionMgr).when(mFragment).getSubscriptionManager(any());
    mSubscriptionInfoList = new ArrayList<SubscriptionInfo>();
    mSubscriptionInfoList.add(mSubscriptionInfo);
    when(mSubscriptionMgr.getAvailableSubscriptionInfoList()).thenReturn(mSubscriptionInfoList);
    SubscriptionUtil.setAvailableSubscriptionsForTesting(mSubscriptionInfoList);
}
Also used : Context(android.content.Context) ShadowTelephonyManager(org.robolectric.shadows.ShadowTelephonyManager) TelephonyManager(android.telephony.TelephonyManager) ShadowTelephonyManager(org.robolectric.shadows.ShadowTelephonyManager) SubscriptionInfo(android.telephony.SubscriptionInfo) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)11 ShadowTelephonyManager (org.robolectric.shadows.ShadowTelephonyManager)11 TelephonyManager (android.telephony.TelephonyManager)10 SubscriptionManager (android.telephony.SubscriptionManager)4 ShadowSubscriptionManager (org.robolectric.shadows.ShadowSubscriptionManager)4 FragmentActivity (androidx.fragment.app.FragmentActivity)2 SwitchPreference (androidx.preference.SwitchPreference)2 ShadowApplication (org.robolectric.shadows.ShadowApplication)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Location (android.location.Location)1 LocationManager (android.location.LocationManager)1 SubscriptionInfo (android.telephony.SubscriptionInfo)1 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)1 BidRequest (org.prebid.mobile.rendering.models.openrtb.BidRequest)1 AdRequestInput (org.prebid.mobile.rendering.networking.parameters.AdRequestInput)1 ShadowActivity (org.robolectric.shadows.ShadowActivity)1 ShadowLocationManager (org.robolectric.shadows.ShadowLocationManager)1