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

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

Fix failing unit tests.

Bug: 29579544
Change-Id: I7a5dc1d641ef5c133e549763b1eb08e767912242
parent 58e123d9
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -353,21 +353,34 @@ public class GsmCdmaCallTrackerTest extends TelephonyTest {
        // verify getCurrentCalls is called on init
        verify(mSimulatedCommandsVerifier).getCurrentCalls(any(Message.class));

        // update phone type
        // update phone type (call the function on same thread as the call tracker)
        Handler updatePhoneTypeHandler = new Handler(mCTUT.getLooper()) {
            @Override
            public void handleMessage(Message msg) {
                mCTUT.updatePhoneType();
            }
        };
        updatePhoneTypeHandler.sendEmptyMessage(0);
        waitForMs(100);

        // verify getCurrentCalls is called on updating phone type
        verify(mSimulatedCommandsVerifier, times(2)).getCurrentCalls(any(Message.class));

        // verify that if phone type is updated, calls and callTracker go to idle
        // we'd like to verify that if phone type is updated, calls and callTracker go to idle.
        // However, as soon as phone type is updated, call tracker queries for calls from RIL and
        // will go back to OFFHOOK

        // call tracker goes to OFFHOOK
        testMOCallPickUp();

        // update phone type
        mCTUT.updatePhoneType();
        // update phone type - call tracker goes to IDLE and then due to getCurrentCalls(),
        // goes back to OFFHOOK
        updatePhoneTypeHandler.sendEmptyMessage(0);
        waitForMs(100);

        // verify CT and calls go to idle
        assertEquals(PhoneConstants.State.IDLE, mCTUT.getState());
        assertEquals(GsmCdmaCall.State.IDLE, mCTUT.mForegroundCall.getState());
        assertEquals(PhoneConstants.State.OFFHOOK, mCTUT.getState());
        assertEquals(GsmCdmaCall.State.ACTIVE, mCTUT.mForegroundCall.getState());
        assertEquals(GsmCdmaCall.State.IDLE, mCTUT.mBackgroundCall.getState());
        assertEquals(GsmCdmaCall.State.IDLE, mCTUT.mRingingCall.getState());
    }
+5 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import com.android.ims.ImsManager;
import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
import com.android.internal.telephony.cdma.EriManager;
import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.imsphone.ImsExternalCallTracker;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.mocks.TelephonyRegistryMock;
@@ -172,6 +173,8 @@ public abstract class TelephonyTest {
    protected IBinder mConnMetLoggerBinder;
    @Mock
    protected CarrierSignalAgent mCarrierSignalAgent;
    @Mock
    protected ImsExternalCallTracker mImsExternalCallTracker;

    protected TelephonyManager mTelephonyManager;
    protected SubscriptionManager mSubscriptionManager;
@@ -340,6 +343,8 @@ public abstract class TelephonyTest {
                        anyInt(), any(Object.class));
        doReturn(mIDeviceIdleController).when(mTelephonyComponentFactory)
                .getIDeviceIdleController();
        doReturn(mImsExternalCallTracker).when(mTelephonyComponentFactory).
                makeImsExternalCallTracker(any(ImsPhone.class));

        //mPhone
        doReturn(mContext).when(mPhone).getContext();