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);
}
Aggregations