use of com.android.settings.network.ims.MockWfcQueryImsState in project android_packages_apps_Settings by omnirom.
the class MobileNetworkUtilsTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(SUB_ID_1)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(SUB_ID_2)).thenReturn(mTelephonyManager2);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(mCarrierConfigManager);
mCarrierConfig = new PersistableBundle();
when(mCarrierConfigManager.getConfigForSubId(SUB_ID_1)).thenReturn(mCarrierConfig);
mNetwork = mock(Network.class, CALLS_REAL_METHODS);
when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
when(mConnectivityManager.getActiveNetwork()).thenReturn(mNetwork);
when(mSubscriptionInfo1.getSubscriptionId()).thenReturn(SUB_ID_1);
when(mSubscriptionInfo1.getCarrierName()).thenReturn(PLMN_FROM_SUB_ID_1);
when(mSubscriptionInfo2.getSubscriptionId()).thenReturn(SUB_ID_2);
when(mSubscriptionInfo2.getCarrierName()).thenReturn(PLMN_FROM_SUB_ID_2);
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(Arrays.asList(mSubscriptionInfo1, mSubscriptionInfo2));
when(mTelephonyManager.getNetworkOperatorName()).thenReturn(PLMN_FROM_TELEPHONY_MANAGER_API);
when(mContext.getSystemService(TelecomManager.class)).thenReturn(mTelecomManager);
when(mTelecomManager.getSimCallManagerForSubscription(SUB_ID_1)).thenReturn(mPhoneAccountHandle);
mMockQueryWfcState = new MockWfcQueryImsState(mContext, SUB_ID_1);
}
use of com.android.settings.network.ims.MockWfcQueryImsState in project android_packages_apps_Settings by omnirom.
the class NetworkProviderWifiCallingGroupTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(mCarrierConfigManager);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mContext.getSystemService(TelecomManager.class)).thenReturn(mTelecomManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
when(mSubscriptionInfo.getSubscriptionId()).thenReturn(SUB_ID);
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(Arrays.asList(mSubscriptionInfo));
mCarrierConfig = new PersistableBundle();
doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL, true);
when(mTelecomManager.getSimCallManagerForSubscription(SUB_ID)).thenReturn(mPhoneAccountHandle);
mMockQueryWfcState = new MockWfcQueryImsState(mContext, SUB_ID);
if (Looper.myLooper() == null) {
Looper.prepare();
}
mPreferenceManager = new PreferenceManager(mContext);
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
when(mPreferenceCategory.getKey()).thenReturn(KEY_PREFERENCE_WFC_CATEGORY);
when(mPreferenceCategory.getPreferenceCount()).thenReturn(1);
mPreferenceScreen.addPreference(mPreferenceCategory);
mNetworkProviderWifiCallingGroup = spy(new NetworkProviderWifiCallingGroup(mContext, mLifecycle, KEY_PREFERENCE_WFC_CATEGORY));
}
Aggregations