Fall back to Wi-Fi data display in data usage screen with no SIM.
Bug: 70950124 Test: manual Test: make RunSettingsRoboTests Change-Id: I06bf78e54119819be87e15baca7e5b6a241958cb Merged-In: I06bf78e54119819be87e15baca7e5b6a241958cb
This commit is contained in:
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
@@ -37,6 +38,8 @@ public final class DataUsageUtilsTest {
|
||||
|
||||
@Mock
|
||||
private ConnectivityManager mManager;
|
||||
@Mock
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
@@ -45,6 +48,7 @@ public final class DataUsageUtilsTest {
|
||||
ShadowApplication shadowContext = ShadowApplication.getInstance();
|
||||
mContext = shadowContext.getApplicationContext();
|
||||
shadowContext.setSystemService(Context.CONNECTIVITY_SERVICE, mManager);
|
||||
shadowContext.setSystemService(Context.TELEPHONY_SERVICE, mTelephonyManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -60,4 +64,18 @@ public final class DataUsageUtilsTest {
|
||||
boolean hasMobileData = DataUsageUtils.hasMobileData(mContext);
|
||||
assertThat(hasMobileData).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasSim_simStateReady() {
|
||||
when(mTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY);
|
||||
boolean hasSim = DataUsageUtils.hasSim(mContext);
|
||||
assertThat(hasSim).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasSim_simStateMissing() {
|
||||
when(mTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_ABSENT);
|
||||
boolean hasSim = DataUsageUtils.hasSim(mContext);
|
||||
assertThat(hasSim).isFalse();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user