use of org.robolectric.shadows.ShadowTelephonyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DataUsageSliceTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
// Set-up specs for SliceMetadata.
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
when(mContext.getSystemService(NetworkStatsManager.class)).thenReturn(mNetworkStatsManager);
mDataUsageSlice = spy(new DataUsageSlice(mContext));
final TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
final ShadowTelephonyManager shadowTelephonyManager = Shadows.shadowOf(telephonyManager);
shadowTelephonyManager.setTelephonyManagerForSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID, telephonyManager);
}
use of org.robolectric.shadows.ShadowTelephonyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DataUsageSummaryTest method setUp.
/**
* This set up is contrived to get a passing test so that the build doesn't block without tests.
* These tests should be updated as code gets refactored to improve testability.
*/
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
ShadowApplication shadowContext = ShadowApplication.getInstance();
ShadowUserManager.getShadow().setIsAdminUser(true);
shadowContext.setSystemService(Context.NETWORK_POLICY_SERVICE, mNetworkPolicyManager);
mContext = spy(RuntimeEnvironment.application);
mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
final ShadowTelephonyManager shadowTelephonyManager = Shadows.shadowOf(mTelephonyManager);
shadowTelephonyManager.setTelephonyManagerForSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID, mTelephonyManager);
shadowTelephonyManager.setTelephonyManagerForSubscriptionId(1, mTelephonyManager);
mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).get());
doReturn(mNetworkStatsManager).when(mActivity).getSystemService(NetworkStatsManager.class);
mSummaryProvider = DataUsageSummary.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(mActivity, mSummaryLoader);
}
use of org.robolectric.shadows.ShadowTelephonyManager in project android_packages_apps_Settings by omnirom.
the class ImeiInfoDialogControllerTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
final ShadowSubscriptionManager ssm = Shadow.extract(mContext.getSystemService(SubscriptionManager.class));
ssm.setActiveSubscriptionInfos(mSubscriptionInfo);
when(mSubscriptionInfo.getSubscriptionId()).thenReturn(SUB_ID);
final ShadowTelephonyManager stm = Shadow.extract(mContext.getSystemService(TelephonyManager.class));
stm.setTelephonyManagerForSubscriptionId(SUB_ID, mTelephonyManager);
when(mDialog.getContext()).thenReturn(mContext);
mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID));
when(mTelephonyManager.getCdmaPrlVersion()).thenReturn(PRL_VERSION);
when(mTelephonyManager.getMeid(anyInt())).thenReturn(MEID_NUMBER);
when(mTelephonyManager.getCdmaMin(anyInt())).thenReturn(MIN_NUMBER);
when(mTelephonyManager.getDeviceSoftwareVersion(anyInt())).thenReturn(IMEI_SV_NUMBER);
when(mTelephonyManager.getImei(anyInt())).thenReturn(IMEI_NUMBER);
}
use of org.robolectric.shadows.ShadowTelephonyManager in project android_packages_apps_Settings by omnirom.
the class ControllerRendererPoolTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
// SubscriptionManager and TelephonyManager for CellularDataConditionController
ShadowSubscriptionManager shadowSubscriptionMgr = shadowOf(mContext.getSystemService(SubscriptionManager.class));
shadowSubscriptionMgr.setDefaultDataSubscriptionId(SUB_ID);
ShadowTelephonyManager shadowTelephonyMgr = Shadow.extract(mContext.getSystemService(TelephonyManager.class));
shadowTelephonyMgr.setTelephonyManagerForSubscriptionId(SUB_ID, mTelephonyMgr);
when(mTelephonyMgr.createForSubscriptionId(anyInt())).thenReturn(mTelephonyMgr);
mPool = new ControllerRendererPool();
}
use of org.robolectric.shadows.ShadowTelephonyManager in project android_packages_apps_Settings by omnirom.
the class ConditionContextualCardControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
// parameters required by CellularDataConditionController
final ShadowSubscriptionManager shadowSubscriptionMgr = shadowOf(mContext.getSystemService(SubscriptionManager.class));
shadowSubscriptionMgr.setDefaultDataSubscriptionId(SUB_ID);
final TelephonyManager telephonyManager = spy(mContext.getSystemService(TelephonyManager.class));
final ShadowTelephonyManager shadowTelephonyMgr = shadowOf(telephonyManager);
shadowTelephonyMgr.setTelephonyManagerForSubscriptionId(SUB_ID, telephonyManager);
mController = spy(new ConditionContextualCardController(mContext));
ReflectionHelpers.setField(mController, "mConditionManager", mConditionManager);
}
Aggregations