Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78867803 authored by Amit Mahajan's avatar Amit Mahajan
Browse files

New unit test for GsmCdmaPhone and fixes for some existing tests

Bug: 25691379
Change-Id: I323fdef84792459db312df7bd58917e52a1a995e
parent 7be665f8
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -786,14 +786,16 @@ public class SmsMessage {
            Binder.restoreCallingIdentity(identity);
        }

        if (!TextUtils.isEmpty(simOperator)) {
            for (NoEmsSupportConfig currentConfig : mNoEmsSupportConfigList) {
                if (simOperator.startsWith(currentConfig.mOperatorNumber) &&
                        (TextUtils.isEmpty(currentConfig.mGid1) ||
                (!TextUtils.isEmpty(currentConfig.mGid1)
                && currentConfig.mGid1.equalsIgnoreCase(gid)))) {
                                (!TextUtils.isEmpty(currentConfig.mGid1) &&
                                        currentConfig.mGid1.equalsIgnoreCase(gid)))) {
                    return false;
                }
            }
        }
        return true;
    }

+17 −20
Original line number Diff line number Diff line
@@ -1509,10 +1509,7 @@ public class GsmCdmaPhone extends Phone {
    }

    @Override
    public void setVoiceMailNumber(String alphaTag,
                            String voiceMailNumber,
                            Message onComplete) {

    public void setVoiceMailNumber(String alphaTag, String voiceMailNumber, Message onComplete) {
        Message resp;
        mVmNumber = voiceMailNumber;
        resp = obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete);
+31 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.internal.telephony;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncResult;
import android.os.HandlerThread;
import android.os.Message;
@@ -59,6 +60,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
                new AsyncResult(null, new int[]{ServiceState.RIL_RADIO_TECHNOLOGY_GSM}, null)));
        //wait for voice RAT to be updated
        TelephonyTestUtils.waitForMs(50);
        assertTrue(PhoneConstants.PHONE_TYPE_GSM == mPhoneUT.getPhoneType());
    }

    private void switchToCdma() {
@@ -67,6 +69,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
                new AsyncResult(null, new int[]{ServiceState.RIL_RADIO_TECHNOLOGY_IS95A}, null)));
        //wait for voice RAT to be updated
        TelephonyTestUtils.waitForMs(50);
        assertTrue(PhoneConstants.PHONE_TYPE_CDMA == mPhoneUT.getPhoneType());
    }

    @Before
@@ -276,4 +279,32 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        mPhoneUT.sendBurstDtmf("1234567890", 0, 0, null);
        verify(mSimulatedCommandsVerifier).sendBurstDtmf("1234567890", 0, 0, null);
    }

    @Test @SmallTest
    public void testVoiceMailNumber() {
        String voiceMailNumber = "1234567890";
        // first test for GSM
        assertEquals(PhoneConstants.PHONE_TYPE_GSM, mPhoneUT.getPhoneType());

        mPhoneUT.setVoiceMailNumber("alphaTag", voiceMailNumber, null);
        verify(mIccRecords).setVoiceMailNumber(eq("alphaTag"), voiceMailNumber,
                any(Message.class));

        doReturn(voiceMailNumber).when(mIccRecords).getVoiceMailNumber();
        assertTrue(voiceMailNumber.equals(mPhoneUT.getVoiceMailNumber()));

        // test for CDMA
        switchToCdma();
        voiceMailNumber = "9876543210";

        mPhoneUT.setVoiceMailNumber("alphaTag", voiceMailNumber, null);
        verify(mIccRecords).setVoiceMailNumber(eq("alphaTag"), voiceMailNumber,
                any(Message.class));

        // todo: trigger code that writes to shared preference
        SharedPreferences sharedPreferences = mContext.getSharedPreferences(null, 0);
        doReturn(voiceMailNumber).when(sharedPreferences).getString(anyString(), anyString());

        assertTrue(voiceMailNumber.equals(mPhoneUT.getVoiceMailNumber()));
    }
}
 No newline at end of file
+17 −6
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.test.SimulatedCommands;
import com.android.internal.telephony.test.SimulatedCommandsVerifier;
import com.android.internal.telephony.uicc.IccCardProxy;
import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.UiccCardApplication;
import com.android.internal.telephony.uicc.UiccController;

import static org.mockito.Mockito.*;
@@ -85,9 +87,13 @@ public abstract class TelephonyTest {
    @Mock
    protected WspTypeDecoder mWspTypeDecoder;
    @Mock
    private SparseArray<TelephonyEventLog> mTelephonyEventLogInstances;
    protected SparseArray<TelephonyEventLog> mTelephonyEventLogInstances;
    @Mock
    private TelephonyEventLog mTelephonyEventLog;
    protected TelephonyEventLog mTelephonyEventLog;
    @Mock
    protected UiccCardApplication mUiccCardApplication;
    @Mock
    protected IccRecords mIccRecords;

    protected SimulatedCommands mSimulatedCommands;
    protected ContextFixture mContextFixture;
@@ -192,20 +198,25 @@ public abstract class TelephonyTest {
                getIDeviceIdleController();
        doReturn(mWspTypeDecoder).when(mTelephonyComponentFactory).
                makeWspTypeDecoder(any(byte[].class));

        doReturn(mContext).when(mPhone).getContext();
        doReturn(true).when(mPhone).getUnitTestMode();
        doReturn(mCdmaSSM).when(mTelephonyComponentFactory).
                getCdmaSubscriptionSourceManagerInstance(any(Context.class),
                        any(CommandsInterface.class), any(Handler.class),
                        anyInt(), any(Object.class));

        doReturn(mContext).when(mPhone).getContext();
        doReturn(true).when(mPhone).getUnitTestMode();

        doReturn(true).when(mImsManagerInstances).containsKey(anyInt());

        doReturn(mPhone).when(mInboundSmsHandler).getPhone();

        doReturn(mTelephonyEventLog).when(mTelephonyEventLogInstances).get(anyInt());

        doReturn(mUiccCardApplication).when(mUiccController).getUiccCardApplication(anyInt(),
                anyInt());

        doReturn(mIccRecords).when(mUiccCardApplication).getIccRecords();

        setReady(false);
    }

+1 −3
Original line number Diff line number Diff line
@@ -231,9 +231,7 @@ public class UiccCardTest {
        /* wait till the async result and message delay */
        waitUntilReady();

        assertFalse(mUicccard.areCarrierPriviligeRulesLoaded());
        assertEquals(mUicccard.getCardState(),
                IccCardStatus.CardState.CARDSTATE_PRESENT);
        assertEquals(mUicccard.getCardState(), IccCardStatus.CardState.CARDSTATE_PRESENT);

        TelephonyTestUtils.waitForMs(50);

Loading