From 1cc318d4e1cca2ee993f62536869e3659a1aa659 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Thu, 14 Nov 2019 08:15:05 -0800 Subject: TelephonyUtil: Use public API for isSimPresent Bug: 142935310 Test: atest com.android.server.wifi Change-Id: I07e23d125105346485ca9bebdc80baff1ab82918 --- .../android/server/wifi/util/TelephonyUtilTest.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java index 5cff6d3d1..b31bb057e 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java @@ -49,6 +49,7 @@ import org.mockito.quality.Strictness; import java.security.PublicKey; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -652,8 +653,12 @@ public class TelephonyUtilTest extends WifiBaseTest { */ @Test public void isSimPresentWithValidSubscriptionIdList() { - when(mSubscriptionManager.getActiveSubscriptionIdList()) - .thenReturn(new int[] {DATA_SUBID, NON_DATA_SUBID}); + SubscriptionInfo subInfo1 = mock(SubscriptionInfo.class); + when(subInfo1.getSubscriptionId()).thenReturn(DATA_SUBID); + SubscriptionInfo subInfo2 = mock(SubscriptionInfo.class); + when(subInfo2.getSubscriptionId()).thenReturn(NON_DATA_SUBID); + when(mSubscriptionManager.getActiveSubscriptionInfoList()) + .thenReturn(Arrays.asList(subInfo1, subInfo2)); assertTrue(mTelephonyUtil.isSimPresent(DATA_SUBID)); } @@ -663,13 +668,15 @@ public class TelephonyUtilTest extends WifiBaseTest { */ @Test public void isSimPresentWithInvalidOrEmptySubscriptionIdList() { - when(mSubscriptionManager.getActiveSubscriptionIdList()) - .thenReturn(new int[]{}); + when(mSubscriptionManager.getActiveSubscriptionInfoList()) + .thenReturn(Collections.emptyList()); assertFalse(mTelephonyUtil.isSimPresent(DATA_SUBID)); - when(mSubscriptionManager.getActiveSubscriptionIdList()) - .thenReturn(new int[]{NON_DATA_SUBID}); + SubscriptionInfo subInfo = mock(SubscriptionInfo.class); + when(subInfo.getSubscriptionId()).thenReturn(NON_DATA_SUBID); + when(mSubscriptionManager.getActiveSubscriptionInfoList()) + .thenReturn(Arrays.asList(subInfo)); assertFalse(mTelephonyUtil.isSimPresent(DATA_SUBID)); } -- cgit v1.2.3