Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +41 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import android.os.UserHandle; import android.provider.Settings; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.UiccSlotInfo; import android.test.mock.MockContentResolver; import android.test.suitebuilder.annotation.SmallTest; Loading @@ -54,6 +55,7 @@ import java.util.Map; public class SubscriptionControllerTest extends TelephonyTest { private static final int SINGLE_SIM = 1; private static final int DUAL_SIM = 2; private String mCallingPackage; private SubscriptionController mSubscriptionControllerUT; private MockContentResolver mMockContentResolver; Loading Loading @@ -754,6 +756,45 @@ public class SubscriptionControllerTest extends TelephonyTest { .queryLocalInterface(anyString()); } @Test @SmallTest public void testEnableDisableSubscriptionSanity() throws Exception { testInsertSim(); // Non existing subId. assertFalse(mSubscriptionControllerUT.isSubscriptionEnabled(2)); assertFalse(mSubscriptionControllerUT.isSubscriptionEnabled(-1)); // Test invalid arguments. try { mSubscriptionControllerUT.getEnabledSubscriptionId(3); fail("Should throw IllegalArgumentException with invalid subId."); } catch (IllegalArgumentException exception) { // Expected. } } @Test @SmallTest public void testEnableDisableSubscriptionSingleSim() throws Exception { testInsertSim(); // UiccSlotInfo that maps logicalSlotIndex 0 to physicalSlotIndex 0. UiccSlotInfo slotInfo = new UiccSlotInfo(true, false, "", 0, 0, false); UiccSlotInfo[] slotInfos = new UiccSlotInfo[] {slotInfo}; doReturn(slotInfos).when(mTelephonyManager).getUiccSlotsInfo(); // Current active subscription should be the enabled one. assertTrue(mSubscriptionControllerUT.isSubscriptionEnabled(1)); assertEquals(1, mSubscriptionControllerUT.getEnabledSubscriptionId(0)); // SetSubscriptionEnabled should fail (no-op) on single SIM device. assertFalse(mSubscriptionControllerUT.setSubscriptionEnabled(false, 1)); // Current active subscription should be the enabled one. assertTrue(mSubscriptionControllerUT.isSubscriptionEnabled(1)); assertEquals(1, mSubscriptionControllerUT.getEnabledSubscriptionId(0)); // TODO: test dual SIM case when SubscriptionControllerTest supports dual SIM config. } @Test @SmallTest public void testGetActiveSubIdList() throws Exception { Loading Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +41 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import android.os.UserHandle; import android.provider.Settings; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.UiccSlotInfo; import android.test.mock.MockContentResolver; import android.test.suitebuilder.annotation.SmallTest; Loading @@ -54,6 +55,7 @@ import java.util.Map; public class SubscriptionControllerTest extends TelephonyTest { private static final int SINGLE_SIM = 1; private static final int DUAL_SIM = 2; private String mCallingPackage; private SubscriptionController mSubscriptionControllerUT; private MockContentResolver mMockContentResolver; Loading Loading @@ -754,6 +756,45 @@ public class SubscriptionControllerTest extends TelephonyTest { .queryLocalInterface(anyString()); } @Test @SmallTest public void testEnableDisableSubscriptionSanity() throws Exception { testInsertSim(); // Non existing subId. assertFalse(mSubscriptionControllerUT.isSubscriptionEnabled(2)); assertFalse(mSubscriptionControllerUT.isSubscriptionEnabled(-1)); // Test invalid arguments. try { mSubscriptionControllerUT.getEnabledSubscriptionId(3); fail("Should throw IllegalArgumentException with invalid subId."); } catch (IllegalArgumentException exception) { // Expected. } } @Test @SmallTest public void testEnableDisableSubscriptionSingleSim() throws Exception { testInsertSim(); // UiccSlotInfo that maps logicalSlotIndex 0 to physicalSlotIndex 0. UiccSlotInfo slotInfo = new UiccSlotInfo(true, false, "", 0, 0, false); UiccSlotInfo[] slotInfos = new UiccSlotInfo[] {slotInfo}; doReturn(slotInfos).when(mTelephonyManager).getUiccSlotsInfo(); // Current active subscription should be the enabled one. assertTrue(mSubscriptionControllerUT.isSubscriptionEnabled(1)); assertEquals(1, mSubscriptionControllerUT.getEnabledSubscriptionId(0)); // SetSubscriptionEnabled should fail (no-op) on single SIM device. assertFalse(mSubscriptionControllerUT.setSubscriptionEnabled(false, 1)); // Current active subscription should be the enabled one. assertTrue(mSubscriptionControllerUT.isSubscriptionEnabled(1)); assertEquals(1, mSubscriptionControllerUT.getEnabledSubscriptionId(0)); // TODO: test dual SIM case when SubscriptionControllerTest supports dual SIM config. } @Test @SmallTest public void testGetActiveSubIdList() throws Exception { Loading