use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class EnabledNetworkModePreferenceControllerTest method preferredNetworkModeNotification_preferenceUpdates.
@UiThreadTest
@Test
public void preferredNetworkModeNotification_preferenceUpdates() {
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
mPreference.setKey(KEY);
screen.addPreference(mPreference);
mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
// NETWORK_MODE_TDSCDMA_GSM_WCDMA = RAF_TD_SCDMA | GSM | WCDMA
when(mTelephonyManager.getAllowedNetworkTypesForReason(TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER)).thenReturn((long) (RAF_TD_SCDMA | GSM | WCDMA));
mController.displayPreference(screen);
mController.updateState(mPreference);
mLifecycle.handleLifecycleEvent(ON_START);
assertThat(Integer.parseInt(mPreference.getValue())).isEqualTo(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
assertThat(mPreference.getSummary()).isEqualTo("3G");
}
use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class EnabledNetworkModePreferenceControllerTest method setUp.
@UiThreadTest
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(mCarrierConfigManager);
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
doReturn(mInvalidTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
doReturn(mServiceState).when(mTelephonyManager).getServiceState();
mPersistableBundle = new PersistableBundle();
doReturn(mPersistableBundle).when(mCarrierConfigManager).getConfig();
doReturn(mPersistableBundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
mPreference = new ListPreference(mContext);
mController = new EnabledNetworkModePreferenceController(mContext, KEY);
mockAllowedNetworkTypes(ALLOWED_ALL_NETWORK_TYPE);
mockAccessFamily(TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
mController.init(mLifecycle, SUB_ID);
mPreference.setKey(mController.getPreferenceKey());
}
use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class ProviderModelSliceTest method getSlice_haveOneConnectedWifiAndTwoDisconnectedWifiAndNoCarrier_getFiveRow.
@Test
@UiThreadTest
public void getSlice_haveOneConnectedWifiAndTwoDisconnectedWifiAndNoCarrier_getFiveRow() {
mWifiList.clear();
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1", WifiEntry.CONNECTED_STATE_CONNECTED, "wifi1_key", true);
mWifiList.add(mMockWifiSliceItem1);
mockWifiItemCondition(mMockWifiSliceItem2, "wifi2", "wifi2", WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi2_key", true);
mWifiList.add(mMockWifiSliceItem2);
mockWifiItemCondition(mMockWifiSliceItem3, "wifi3", "wifi3", WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi3_key", true);
mWifiList.add(mMockWifiSliceItem3);
mMockNetworkProviderWorker.updateSelfResults(mWifiList);
mockHelperCondition(false, false, false, mWifiList.get(0));
final Slice slice = mMockProviderModelSlice.getSlice();
assertThat(slice).isNotNull();
verify(mListBuilder, times(5)).addRow(any(ListBuilder.RowBuilder.class));
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
}
use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class ProviderModelSliceTest method getSlice_haveEthernetAndCarrierAndTwoDisconnectedWifi_getSixRow.
@Test
@UiThreadTest
public void getSlice_haveEthernetAndCarrierAndTwoDisconnectedWifi_getSixRow() {
mWifiList.clear();
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1", WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi1_key", true);
mWifiList.add(mMockWifiSliceItem1);
mockWifiItemCondition(mMockWifiSliceItem2, "wifi2", "wifi2", WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi2_key", true);
mWifiList.add(mMockWifiSliceItem2);
mMockNetworkProviderWorker.updateSelfResults(mWifiList);
mockHelperCondition(false, true, true, null);
when(mMockNetworkProviderWorker.getInternetType()).thenReturn(InternetUpdater.INTERNET_ETHERNET);
final Slice slice = mMockProviderModelSlice.getSlice();
assertThat(slice).isNotNull();
assertThat(mMockProviderModelSlice.hasCreateEthernetRow()).isTrue();
verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
verify(mListBuilder, times(6)).addRow(any(ListBuilder.RowBuilder.class));
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
}
use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class ProviderModelSliceTest method getSlice_airplaneModeIsOn_oneWifiToggle.
@Test
@UiThreadTest
public void getSlice_airplaneModeIsOn_oneWifiToggle() {
mWifiList.clear();
mMockNetworkProviderWorker.updateSelfResults(null);
mockHelperCondition(true, false, false, null);
final Slice slice = mMockProviderModelSlice.getSlice();
assertThat(slice).isNotNull();
verify(mListBuilder, times(1)).addRow(any(ListBuilder.RowBuilder.class));
final SliceItem sliceTitle = SliceMetadata.from(mContext, slice).getListContent().getHeader().getTitleItem();
assertThat(sliceTitle.getText()).isEqualTo(ResourcesUtils.getResourcesString(mContext, "wifi_settings"));
}
Aggregations