Update ImsCallTest to ensure NPE isnt hit after ImsCall#close is called.
Bug: 236279778
Test: atest FrameworksTelephonyTests:ImsCallTest
Change-Id: I098e09b32a143ec4a98ca6e3eedb451fcbfacbc8
diff --git a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsCallTest.java b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsCallTest.java
index d665264..aa07125 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsCallTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsCallTest.java
@@ -22,6 +22,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -146,6 +147,39 @@
@Test
@SmallTest
+ public void testCloseImsCallRtt() throws Exception {
+ ImsCallSession mockSession = mock(ImsCallSession.class);
+ ImsStreamMediaProfile streamProfile = new ImsStreamMediaProfile(
+ ImsStreamMediaProfile.AUDIO_QUALITY_AMR_WB,
+ ImsStreamMediaProfile.DIRECTION_SEND_RECEIVE,
+ ImsStreamMediaProfile.VIDEO_QUALITY_NONE,
+ ImsStreamMediaProfile.DIRECTION_INACTIVE,
+ // Full RTT mode
+ ImsStreamMediaProfile.RTT_MODE_FULL);
+ ImsCallProfile profile = new ImsCallProfile(ImsCallProfile.SERVICE_TYPE_NORMAL,
+ ImsCallProfile.CALL_TYPE_VOICE, null /*extras*/, streamProfile);
+ profile.mCallType = ImsCallProfile.CALL_TYPE_VOICE;
+ ImsCall imsCall = new ImsCall(mContext, profile);
+ imsCall.attachSession(mockSession);
+
+ imsCall.sendRttMessage("test");
+ verify(mockSession).sendRttMessage("test");
+
+ //called by ImsPhoneCallTracker when the call is terminated
+ imsCall.close();
+
+ try {
+ // Ensure RTT cases are handled gracefully.
+ imsCall.sendRttMessage("test");
+ imsCall.sendRttModifyRequest(true);
+ imsCall.sendRttModifyResponse(true);
+ } catch (Exception e) {
+ fail("Unexpected exception: " + e);
+ }
+ }
+
+ @Test
+ @SmallTest
public void testSetWifi() {
ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile);
assertFalse(mTestImsCall.isWifiCall());