use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class SubscriptionsPreferenceControllerTest method onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndNotActive_showRat.
@Test
@UiThreadTest
public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndNotActive_showRat() {
final CharSequence expectedSummary = Html.fromHtml("LTE", Html.FROM_HTML_MODE_LEGACY);
final String networkType = "LTE";
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
final TelephonyDisplayInfo telephonyDisplayInfo = new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UNKNOWN, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true, true, ServiceState.STATE_IN_SERVICE);
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType).when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
mController.onResume();
mController.displayPreference(mPreferenceScreen);
mController.onTelephonyDisplayInfoChanged(telephonyDisplayInfo);
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
}
use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class SubscriptionsPreferenceControllerTest method setIcon_greatSignal_correctLevels.
@Test
@UiThreadTest
public void setIcon_greatSignal_correctLevels() {
final List<SubscriptionInfo> subs = setupMockSubscriptions(2, 1, true);
setMockSubSignalStrength(subs, 0, SIGNAL_STRENGTH_GREAT);
setMockSubSignalStrength(subs, 1, SIGNAL_STRENGTH_GREAT);
final Preference pref = new Preference(mContext);
final Drawable greatDrawWithoutCutOff = mock(Drawable.class);
doReturn(greatDrawWithoutCutOff).when(sInjector).getIcon(any(), anyInt(), anyInt(), anyBoolean());
mController.setIcon(pref, 1, true);
assertThat(pref.getIcon()).isEqualTo(greatDrawWithoutCutOff);
final Drawable greatDrawWithCutOff = mock(Drawable.class);
doReturn(greatDrawWithCutOff).when(sInjector).getIcon(any(), anyInt(), anyInt(), anyBoolean());
mController.setIcon(pref, 2, false);
assertThat(pref.getIcon()).isEqualTo(greatDrawWithCutOff);
}
use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class SubscriptionsPreferenceControllerTest method dataSubscriptionChanged_providerAndHasMultiSim_showSubId1Preference.
@Test
@UiThreadTest
public void dataSubscriptionChanged_providerAndHasMultiSim_showSubId1Preference() {
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
doReturn(sub).when(mSubscriptionManager).getAvailableSubscriptionInfoList();
Intent intent = new Intent(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
mController.onResume();
mController.displayPreference(mPreferenceScreen);
mController.mConnectionChangeReceiver.onReceive(mContext, intent);
assertThat(mController.isAvailable()).isTrue();
assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(1);
assertThat(mPreferenceCategory.getPreference(0).getTitle()).isEqualTo("sub1");
}
use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class SubscriptionsPreferenceControllerTest method getIcon_voiceInServiceAndMobileDataOff_iconIsSignalIcon.
@Test
@UiThreadTest
public void getIcon_voiceInServiceAndMobileDataOff_iconIsSignalIcon() {
final List<SubscriptionInfo> subs = setupMockSubscriptions(1);
final int subId = subs.get(0).getSubscriptionId();
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
doReturn(subs.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
Drawable icon = mock(Drawable.class);
when(mTelephonyManager.isDataEnabled()).thenReturn(false);
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(true));
setupGetIconConditions(subId, false, false, false, ServiceState.STATE_IN_SERVICE);
mController.onResume();
mController.displayPreference(mPreferenceScreen);
Drawable actualIcon = mPreferenceCategory.getPreference(0).getIcon();
ServiceState ss = mock(ServiceState.class);
NetworkRegistrationInfo regInfo = new NetworkRegistrationInfo.Builder().setDomain(NetworkRegistrationInfo.DOMAIN_PS).setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN).setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME).setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE).build();
doReturn(ss).when(mTelephonyManagerForSub).getServiceState();
doReturn(regInfo).when(ss).getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
assertThat(icon).isEqualTo(actualIcon);
}
use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.
the class SubscriptionsPreferenceControllerTest method dataSubscriptionChanged_providerAndHasMultiSim_showSubId2Preference.
@Test
@UiThreadTest
public void dataSubscriptionChanged_providerAndHasMultiSim_showSubId2Preference() {
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
final int subId = sub.get(0).getSubscriptionId();
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
doReturn(sub).when(mSubscriptionManager).getAvailableSubscriptionInfoList();
Intent intent = new Intent(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
mController.onResume();
mController.displayPreference(mPreferenceScreen);
assertThat(mController.isAvailable()).isTrue();
assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(1);
assertThat(mPreferenceCategory.getPreference(0).getTitle()).isEqualTo("sub1");
doReturn(sub.get(1)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
mController.mConnectionChangeReceiver.onReceive(mContext, intent);
assertThat(mController.isAvailable()).isTrue();
assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(1);
assertThat(mPreferenceCategory.getPreference(0).getTitle()).isEqualTo("sub2");
}
Aggregations