Extract and fix logic for showing rac dialog.

Added tests to make sure the logic makes sense.

Bug: 335745726
Test: make, manual, atest SubscriptionUtilRoboTest, atest SubscriptionUtilTest, atest ResetNetworkTest
Change-Id: I7092f2747f1ca1f9ef4dc99275a916b9e24d8b28
This commit is contained in:
Rafael Higuera Silva
2024-04-23 17:31:23 +00:00
parent c6005fb22a
commit 36d99e8b09
5 changed files with 87 additions and 13 deletions

View File

@@ -658,36 +658,36 @@ public class SubscriptionUtilTest {
}
@Test
public void hasSubscriptionWithRacCarrier_hasNoWifi_showRacDialog_returnTrue() {
public void hasSubscriptionWithRacCarrier_hasNoWifi_showRacDialogForAllEsims_returnTrue() {
when(mResources.getIntArray(anyInt())).thenReturn(CARRIERS_THAT_USE_RAC);
final SubscriptionInfo info = mock(SubscriptionInfo.class);
when(info.getCarrierId()).thenReturn(RAC_CARRIER_ID);
when(mSubMgr.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info));
addNetworkTransportType(NetworkCapabilities.TRANSPORT_BLUETOOTH);
assertTrue(SubscriptionUtil.shouldShowRacDialog(mContext));
assertTrue(SubscriptionUtil.shouldShowRacDialogWhenErasingAllEsims(mContext));
}
@Test
public void hasSubscriptionWithRacCarrier_hasWifi_showRacDialog_returnFalse() {
public void hasSubscriptionWithRacCarrier_hasWifi_showRacDialogForAllEsims_returnFalse() {
when(mResources.getIntArray(anyInt())).thenReturn(CARRIERS_THAT_USE_RAC);
final SubscriptionInfo info = mock(SubscriptionInfo.class);
when(info.getCarrierId()).thenReturn(RAC_CARRIER_ID);
when(mSubMgr.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info));
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
assertFalse(SubscriptionUtil.shouldShowRacDialog(mContext));
assertFalse(SubscriptionUtil.shouldShowRacDialogWhenErasingAllEsims(mContext));
}
@Test
public void hasNoSubscriptionWithRacCarrier_hasNoWifi_showRacDialog_returnFalse() {
public void hasNoSubscriptionWithRacCarrier_hasNoWifi_showRacDialogForAllEsims_returnFalse() {
when(mResources.getIntArray(anyInt())).thenReturn(CARRIERS_THAT_USE_RAC);
final SubscriptionInfo info = mock(SubscriptionInfo.class);
when(info.getCarrierId()).thenReturn(NO_RAC_CARRIER_ID);
when(mSubMgr.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info));
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
assertFalse(SubscriptionUtil.shouldShowRacDialog(mContext));
assertFalse(SubscriptionUtil.shouldShowRacDialogWhenErasingAllEsims(mContext));
}
private void addNetworkTransportType(int networkType) {