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

Commit 91d39fdd authored by Brad Ebinger's avatar Brad Ebinger
Browse files

New ImsCallTest to ensure that changes to MediaProfile are applied

Add a new ImsCallTest case to ensure that ImsStreamMediaProfile changes
are applied when callSessionProgressing is called.

Bug: 169953890
Test: atest FrameworksTelephonyTests:ImsCallTest
Change-Id: Ib123e2c1f9e25796fc86c44eeebba89f07be25e8
parent f7af0f9a
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -22,11 +22,16 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.os.Bundle;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsCallSession;
import android.telephony.ims.ImsStreamMediaProfile;
import android.test.suitebuilder.annotation.SmallTest;

import com.android.ims.ImsCall;
@@ -35,6 +40,7 @@ import com.android.internal.telephony.TelephonyTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;

public class ImsCallTest extends TelephonyTest {

@@ -53,6 +59,36 @@ public class ImsCallTest extends TelephonyTest {
        super.tearDown();
    }

    @Test
    @SmallTest
    public void testCallSessionProgressingAppliedMediaCaps() 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());
        ImsCallSession.Listener listener = listenerCaptor.getValue();
        assertNotNull(listener);

        // 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);
        listener.callSessionProgressing(mockSession, newProfile);

        ImsStreamMediaProfile testProfile = testImsCall.getCallProfile().getMediaProfile();
        assertNotNull(testProfile);
        // Assert that the new direction was applied to the profile
        assertEquals(ImsStreamMediaProfile.DIRECTION_INACTIVE, testProfile.getAudioDirection());
    }

    @Test
    @SmallTest
    public void testSetWifiDeprecated() {
+1 −0
Original line number Diff line number Diff line
@@ -176,6 +176,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {

        imsCall.attachSession(mImsCallSession);
        doReturn("1").when(mImsCallSession).getCallId();
        doReturn(mImsCallProfile).when(mImsCallSession).getCallProfile();
    }

    @Before