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

Commit 6cad656c authored by Aswin Sankar's avatar Aswin Sankar Committed by Android (Google) Code Review
Browse files

Merge "Tests for 3rd call reception in DSDA." into udc-dev

parents 2e7106e3 f7c5fef9
Loading
Loading
Loading
Loading
+58 −0
Original line number Diff line number Diff line
@@ -940,6 +940,64 @@ public class CallsManagerTest extends TelecomTestCase {
        verify(incomingCall).answer(VideoProfile.STATE_AUDIO_ONLY);
    }

    @SmallTest
    @Test
    public void testAnswerThirdCallWhenTwoCallsOnDifferentSims_disconnectsHeldCall() {
        // Given an ongoing call on SIM1
        Call ongoingCall = addSpyCall(SIM_1_HANDLE, CallState.ACTIVE);
        doReturn(true).when(ongoingCall).can(Connection.CAPABILITY_SUPPORT_HOLD);
        doReturn(CallState.ACTIVE).when(ongoingCall).getState();
        when(mConnectionSvrFocusMgr.getCurrentFocusCall()).thenReturn(ongoingCall);

        // And a held call on SIM2, which belongs to the same ConnectionService
        Call heldCall = addSpyCall(SIM_2_HANDLE, CallState.ON_HOLD);
        doReturn(CallState.ON_HOLD).when(heldCall).getState();

        // on answering an incoming call on SIM1, which belongs to the same ConnectionService
        Call incomingCall = addSpyCall(SIM_1_HANDLE, CallState.RINGING);
        mCallsManager.answerCall(incomingCall, VideoProfile.STATE_AUDIO_ONLY);

        // THEN the previous held call is disconnected
        verify(heldCall).disconnect();

        // and the ongoing call is held
        verify(ongoingCall).hold();

        // and the focus request is sent
        verifyFocusRequestAndExecuteCallback(incomingCall);
        // and the incoming call is answered
        verify(incomingCall).answer(VideoProfile.STATE_AUDIO_ONLY);
    }

    @SmallTest
    @Test
    public void testAnswerThirdCallDifferentSimWhenTwoCallsOnSameSim_disconnectsHeldCall() {
        // Given an ongoing call on SIM1
        Call ongoingCall = addSpyCall(SIM_1_HANDLE, CallState.ACTIVE);
        doReturn(true).when(ongoingCall).can(Connection.CAPABILITY_SUPPORT_HOLD);
        doReturn(CallState.ACTIVE).when(ongoingCall).getState();
        when(mConnectionSvrFocusMgr.getCurrentFocusCall()).thenReturn(ongoingCall);

        // And a held call on SIM1
        Call heldCall = addSpyCall(SIM_1_HANDLE, CallState.ON_HOLD);
        doReturn(CallState.ON_HOLD).when(heldCall).getState();

        // on answering an incoming call on SIM2, which belongs to the same ConnectionService
        Call incomingCall = addSpyCall(SIM_2_HANDLE, CallState.RINGING);
        mCallsManager.answerCall(incomingCall, VideoProfile.STATE_AUDIO_ONLY);

        // THEN the previous held call is disconnected
        verify(heldCall).disconnect();

        // and the ongoing call is held
        verify(ongoingCall).hold();

        // and the focus request is sent
        verifyFocusRequestAndExecuteCallback(incomingCall);
        // and the incoming call is answered
        verify(incomingCall).answer(VideoProfile.STATE_AUDIO_ONLY);
    }

    @SmallTest
    @Test
    public void testAnswerCallWhenNoOngoingCallExisted() {