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

Commit 2c4a6cc0 authored by Joonhun Shin's avatar Joonhun Shin Committed by Automerger Merge Worker
Browse files

Merge "Add test function to verify abnormal case." into main am: 7e9ac17a...

Merge "Add test function to verify abnormal case." into main am: 7e9ac17a am: a4a4dbab am: b214f2d1

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/2671276



Change-Id: Ic4c99b1f905a28facfa545525c50842b5eed46ba
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7f567c07 b214f2d1
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.internal.telephony.imsphone;

import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -237,4 +238,40 @@ public class ImsCallTest extends TelephonyTest {
        assertFalse(mTestImsCall.isWifiCall());
        assertEquals(mTestImsCall.getNetworkType(), TelephonyManager.NETWORK_TYPE_LTE);
    }

    @Test
    @SmallTest
    public void testListenerCalledAfterCallClosed() throws Exception {
        ImsCallSession mockSession = mock(ImsCallSession.class);
        ImsCall testImsCall = new ImsCall(mContext, mTestCallProfile);
        ImsCallProfile profile = new ImsCallProfile();
        when(mockSession.getCallProfile()).thenReturn(profile);
        testImsCall.attachSession(mockSession);

        ArgumentCaptor<ImsCallSession.Listener> listenerCaptor =
                ArgumentCaptor.forClass(ImsCallSession.Listener.class);
        verify(mockSession).setListener(listenerCaptor.capture(), any());
        ImsCallSession.Listener listener = listenerCaptor.getValue();
        assertNotNull(listener);

        // Call closed
        testImsCall.close();
        // Set CallProfile value to null because ImsCallSession was closed
        when(mockSession.getCallProfile()).thenReturn(null);

        // Set new profile with direction of none
        ImsStreamMediaProfile newProfile = new ImsStreamMediaProfile(
                ImsStreamMediaProfile.AUDIO_QUALITY_AMR_WB,
                ImsStreamMediaProfile.DIRECTION_INACTIVE,
                ImsStreamMediaProfile.VIDEO_QUALITY_NONE,
                ImsStreamMediaProfile.DIRECTION_INACTIVE,
                ImsStreamMediaProfile.RTT_MODE_DISABLED);
        try {
            listener.callSessionProgressing(mockSession, newProfile);
        } catch (Exception e) {
            throw new AssertionError("not expected exception", e);
        }

        assertNull(testImsCall.getCallProfile());
    }
}