Search in sources :

Example 1 with MockWifiCallingQueryImsState

use of com.android.settings.network.ims.MockWifiCallingQueryImsState in project android_packages_apps_Settings by omnirom.

the class WifiCallingSettingsForSubTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    doReturn(mContext.getTheme()).when(mActivity).getTheme();
    mFragment = spy(new TestFragment());
    doReturn(mActivity).when(mFragment).getActivity();
    doReturn(mContext).when(mFragment).getContext();
    doReturn(mock(Intent.class)).when(mActivity).getIntent();
    doReturn(mContext.getResources()).when(mFragment).getResources();
    doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
    doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt());
    final Bundle bundle = new Bundle();
    when(mFragment.getArguments()).thenReturn(bundle);
    doNothing().when(mFragment).addPreferencesFromResource(anyInt());
    doReturn(mock(ListWithEntrySummaryPreference.class)).when(mFragment).findPreference(any());
    doReturn(mButtonWfcMode).when(mFragment).findPreference(BUTTON_WFC_MODE);
    doReturn(mButtonWfcRoamingMode).when(mFragment).findPreference(BUTTON_WFC_ROAMING_MODE);
    doNothing().when(mFragment).finish();
    doReturn(mView).when(mFragment).getView();
    mEmptyView = new TextView(mContext);
    doReturn(mEmptyView).when(mView).findViewById(android.R.id.empty);
    mSwitchBar = new SettingsMainSwitchBar(mContext);
    doReturn(mSwitchBar).when(mView).findViewById(R.id.switch_bar);
    mQueryImsState = new MockWifiCallingQueryImsState(mContext, SUB_ID);
    doReturn(mImsMmTelManager).when(mFragment).getImsMmTelManager();
    mQueryImsState.setIsProvisionedOnDevice(true);
    mQueryImsState.setIsEnabledByPlatform(true);
    mQueryImsState.setIsEnabledByUser(true);
    mQueryImsState.setIsTtyOnVolteEnabled(true);
    doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED).when(mImsMmTelManager).getVoWiFiModeSetting();
    doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED).when(mImsMmTelManager).getVoWiFiRoamingModeSetting();
    doReturn(mBundle).when(sCarrierConfigManager).getConfigForSubId(anyInt());
    setDefaultCarrierConfigValues();
    doReturn(sCarrierConfigManager).when(mActivity).getSystemService(CarrierConfigManager.class);
    doReturn(mContext.getResources()).when(mFragment).getResourcesForSubId();
    doNothing().when(mFragment).startActivityForResult(any(Intent.class), anyInt());
    mFragment.onAttach(mContext);
    mFragment.onCreate(null);
    mFragment.onActivityCreated(null);
}
Also used : SettingsMainSwitchBar(com.android.settings.widget.SettingsMainSwitchBar) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) Intent(android.content.Intent) TextView(android.widget.TextView) MockWifiCallingQueryImsState(com.android.settings.network.ims.MockWifiCallingQueryImsState) Before(org.junit.Before)

Example 2 with MockWifiCallingQueryImsState

use of com.android.settings.network.ims.MockWifiCallingQueryImsState in project android_packages_apps_Settings by omnirom.

the class WifiCallingSettingsTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mQueryImsState1 = new MockWifiCallingQueryImsState(mContext, SUB_ID1);
    mQueryImsState2 = new MockWifiCallingQueryImsState(mContext, SUB_ID2);
    mQueryImsState1.setIsEnabledByUser(true);
    mQueryImsState2.setIsEnabledByUser(true);
    mQueryImsState1.setIsEnabledByPlatform(true);
    mQueryImsState2.setIsEnabledByPlatform(true);
    mQueryImsState1.setIsProvisionedOnDevice(true);
    mQueryImsState2.setIsProvisionedOnDevice(true);
    mFragment = spy(new WifiCallingSettings());
    doReturn(mQueryImsState1).when(mFragment).queryImsState(SUB_ID1);
    doReturn(mQueryImsState2).when(mFragment).queryImsState(SUB_ID2);
}
Also used : MockWifiCallingQueryImsState(com.android.settings.network.ims.MockWifiCallingQueryImsState) Before(org.junit.Before)

Example 3 with MockWifiCallingQueryImsState

use of com.android.settings.network.ims.MockWifiCallingQueryImsState in project android_packages_apps_Settings by omnirom.

the class WifiCallingSliceHelperTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    // setup for SettingsSliceProvider tests
    mProvider = spy(new SettingsSliceProvider());
    doReturn(mContext).when(mProvider).getContext();
    mProvider.onCreateSliceProvider();
    // setup for SliceBroadcastReceiver test
    mReceiver = spy(new SliceBroadcastReceiver());
    mFeatureFactory = FakeFeatureFactory.setupForTest();
    mSlicesFeatureProvider = mFeatureFactory.getSlicesFeatureProvider();
    mQueryImsState = new MockWifiCallingQueryImsState(mContext, SUB_ID);
    mQueryImsState.setIsEnabledByUser(true);
    mQueryImsState.setIsEnabledByPlatform(true);
    mQueryImsState.setIsProvisionedOnDevice(true);
    mWfcSliceHelper = spy(new FakeWifiCallingSliceHelper(mContext));
    doReturn(mQueryImsState).when(mWfcSliceHelper).queryImsState(anyInt());
    // Set-up specs for SliceMetadata.
    SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
}
Also used : SettingsSliceProvider(com.android.settings.slices.SettingsSliceProvider) SliceBroadcastReceiver(com.android.settings.slices.SliceBroadcastReceiver) MockWifiCallingQueryImsState(com.android.settings.network.ims.MockWifiCallingQueryImsState) Before(org.junit.Before)

Example 4 with MockWifiCallingQueryImsState

use of com.android.settings.network.ims.MockWifiCallingQueryImsState in project android_packages_apps_Settings by omnirom.

the class WifiCallingPreferenceControllerTest method setUp.

@Before
@UiThreadTest
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
    mQueryImsState = new MockWifiCallingQueryImsState(mContext, SUB_ID);
    mQueryImsState.setIsEnabledByUser(true);
    mQueryImsState.setIsProvisionedOnDevice(true);
    mController = new TestWifiCallingPreferenceController(mContext, "wifi_calling");
    mController.mCarrierConfigManager = mCarrierConfigManager;
    mController.init(SUB_ID);
    mController.mCallState = TelephonyManager.CALL_STATE_IDLE;
    mCarrierConfig = new PersistableBundle();
    when(mCarrierConfigManager.getConfigForSubId(SUB_ID)).thenReturn(mCarrierConfig);
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreference = new Preference(mContext);
    mPreference.setKey(mController.getPreferenceKey());
    mScreen.addPreference(mPreference);
}
Also used : PersistableBundle(android.os.PersistableBundle) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) MockWifiCallingQueryImsState(com.android.settings.network.ims.MockWifiCallingQueryImsState) Before(org.junit.Before) UiThreadTest(androidx.test.annotation.UiThreadTest)

Aggregations

MockWifiCallingQueryImsState (com.android.settings.network.ims.MockWifiCallingQueryImsState)4 Before (org.junit.Before)4 PersistableBundle (android.os.PersistableBundle)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 TextView (android.widget.TextView)1 Preference (androidx.preference.Preference)1 PreferenceManager (androidx.preference.PreferenceManager)1 UiThreadTest (androidx.test.annotation.UiThreadTest)1 SettingsSliceProvider (com.android.settings.slices.SettingsSliceProvider)1 SliceBroadcastReceiver (com.android.settings.slices.SliceBroadcastReceiver)1 SettingsMainSwitchBar (com.android.settings.widget.SettingsMainSwitchBar)1