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

Commit d16769a7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "New ImsCallTest to ensure that changes to MediaProfile are applied"

parents 859329a1 91d39fdd
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
@@ -183,6 +183,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {

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

    @Before