Search in sources :

Example 16 with FlakyTest

use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.

the class ImsRttTextHandlerTest method testSendAfterEnoughChars.

/**
 * Test that the text handler sends after enough characters have been sent from in-call
 * @throws Exception
 */
@FlakyTest
@Test
public void testSendAfterEnoughChars() throws Exception {
    // Register a read notifier
    CountDownLatch readNotifier = new CountDownLatch(1);
    mRttTextHandler.setReadNotifier(readNotifier);
    // Send four characters
    mPipeToHandler.write("abcd");
    mPipeToHandler.flush();
    // Wait for the stream to consume the characters
    readNotifier.await(TEST_TIMEOUT, TimeUnit.MILLISECONDS);
    waitForHandlerAction(mRttTextHandler, TEST_TIMEOUT);
    waitForHandlerAction(mRttTextHandler, TEST_TIMEOUT);
    // make sure at it hasn't been sent.
    Assert.assertEquals("", mNetworkWriter.getContents());
    // Send the second part
    waitForMs(10);
    // Register a read notifier
    readNotifier = new CountDownLatch(1);
    mRttTextHandler.setReadNotifier(readNotifier);
    // Send four more characters
    mPipeToHandler.write("efgh");
    mPipeToHandler.flush();
    // Wait for the stream to consume the characters
    boolean res = readNotifier.await(TEST_TIMEOUT, TimeUnit.MILLISECONDS);
    // Wait for the handler to write to the mock network writer
    waitForHandlerAction(mRttTextHandler, TEST_TIMEOUT);
    waitForHandlerAction(mRttTextHandler, TEST_TIMEOUT);
    // make sure that all characters were sent.
    try {
        Assert.assertEquals("abcdefgh", mNetworkWriter.getContents());
    } catch (ComparisonFailure e) {
        throw new ComparisonFailure(e.getMessage() + ", network buffer=" + mRttTextHandler.getNetworkBufferText() + ", res=" + res, e.getExpected(), e.getActual());
    }
}
Also used : ComparisonFailure(org.junit.ComparisonFailure) CountDownLatch(java.util.concurrent.CountDownLatch) FlakyTest(androidx.test.filters.FlakyTest) FlakyTest(androidx.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test)

Example 17 with FlakyTest

use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.

the class ImsExternalCallTrackerTest method testAddExternalCall.

@FlakyTest
@Test
@Ignore
public void testAddExternalCall() {
    List<ImsExternalCallState> dep = new ArrayList<>();
    dep.add(new ImsExternalCallState(CALL_ID, TEST_ADDRESS, false, /* isPullable */
    ImsExternalCallState.CALL_STATE_CONFIRMED, ImsCallProfile.CALL_TYPE_VOICE, false));
    mTracker.refreshExternalCallState(dep);
    ArgumentCaptor<Connection> connectionArgumentCaptor = ArgumentCaptor.forClass(Connection.class);
    verify(mCallNotifier).notifyUnknownConnection(connectionArgumentCaptor.capture());
    Connection connection = connectionArgumentCaptor.getValue();
    assert (connection instanceof ImsExternalConnection);
}
Also used : ArrayList(java.util.ArrayList) Connection(com.android.internal.telephony.Connection) ImsExternalCallState(android.telephony.ims.ImsExternalCallState) FlakyTest(androidx.test.filters.FlakyTest) Ignore(org.junit.Ignore) FlakyTest(androidx.test.filters.FlakyTest) Test(org.junit.Test)

Example 18 with FlakyTest

use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhoneCallTrackerTest method testTTYImsServiceUnavailable.

@FlakyTest
@Ignore
@Test
@SmallTest
public void testTTYImsServiceUnavailable() throws ImsException {
    doThrow(new ImsException("Test Exception", ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN)).when(mImsManager).setUiTTYMode(nullable(Context.class), anyInt(), nullable(Message.class));
    // Remove retry timeout delay
    // ms
    mCTUT.setRetryTimeout(() -> 0);
    mCTUT.setUiTTYMode(0, new Message());
    processAllMessages();
    // Make sure that open is called in ImsPhoneCallTracker to re-establish connection to
    // ImsService
    verify(mImsManager, times(2)).open(nullable(MmTelFeature.Listener.class));
}
Also used : Context(android.content.Context) Message(android.os.Message) ImsException(com.android.ims.ImsException) FlakyTest(androidx.test.filters.FlakyTest) Ignore(org.junit.Ignore) FlakyTest(androidx.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 19 with FlakyTest

use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.

the class CdmaInboundSmsHandlerTest method testNewSms.

@FlakyTest
@Test
@MediumTest
@Ignore
public void testNewSms() {
    transitionFromStartupToIdle();
    // send new SMS to state machine and verify that triggers SMS_DELIVER_ACTION
    doReturn(SmsEnvelope.TELESERVICE_WMT).when(mCdmaSmsMessage).getTeleService();
    mCdmaInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null));
    processAllMessages();
    ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
    verify(mContext).sendBroadcast(intentArgumentCaptor.capture());
    assertEquals(Telephony.Sms.Intents.SMS_DELIVER_ACTION, intentArgumentCaptor.getValue().getAction());
    // verify a message id was created on receive.
    assertNotEquals(0L, intentArgumentCaptor.getValue().getLongExtra("messageId", 0L));
    assertEquals("WaitingState", getCurrentState().getName());
    mContextFixture.sendBroadcastToOrderedBroadcastReceivers();
    intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
    verify(mContext, times(2)).sendBroadcast(intentArgumentCaptor.capture());
    assertEquals(Telephony.Sms.Intents.SMS_RECEIVED_ACTION, intentArgumentCaptor.getAllValues().get(1).getAction());
    assertEquals("WaitingState", getCurrentState().getName());
    mContextFixture.sendBroadcastToOrderedBroadcastReceivers();
    processAllMessages();
    assertEquals("IdleState", getCurrentState().getName());
}
Also used : Intent(android.content.Intent) AsyncResult(android.os.AsyncResult) FlakyTest(androidx.test.filters.FlakyTest) Ignore(org.junit.Ignore) FlakyTest(androidx.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) Test(org.junit.Test) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 20 with FlakyTest

use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.

the class CdmaInboundSmsHandlerTest method testNewSmsFromBlockedNumber_noBroadcastsSent.

@FlakyTest
/* flakes 0.43% of the time */
@Test
@MediumTest
public void testNewSmsFromBlockedNumber_noBroadcastsSent() {
    String blockedNumber = "123456789";
    mInboundSmsTracker = new InboundSmsTracker(mContext, mSmsPdu, /* pdu */
    System.currentTimeMillis(), /* timestamp */
    -1, /* destPort */
    true, /* is3gpp2 */
    false, /* is3gpp2WapPdu */
    "1234567890", /* address */
    blockedNumber, /* displayAddress */
    "This is the message body of a single-part message", /* messageBody */
    false, /* isClass0 */
    mSubId0);
    doReturn(mInboundSmsTracker).when(mTelephonyComponentFactory).makeInboundSmsTracker(any(Context.class), nullable(byte[].class), anyLong(), anyInt(), anyBoolean(), anyBoolean(), nullable(String.class), nullable(String.class), nullable(String.class), anyBoolean(), anyInt());
    mFakeBlockedNumberContentProvider.mBlockedNumbers.add(blockedNumber);
    transitionFromStartupToIdle();
    doReturn(SmsEnvelope.TELESERVICE_WMT).when(mCdmaSmsMessage).getTeleService();
    mCdmaInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null));
    processAllMessages();
    verify(mContext, never()).sendBroadcast(any(Intent.class));
    assertEquals("IdleState", getCurrentState().getName());
}
Also used : Context(android.content.Context) Intent(android.content.Intent) AsyncResult(android.os.AsyncResult) InboundSmsTracker(com.android.internal.telephony.InboundSmsTracker) FlakyTest(androidx.test.filters.FlakyTest) FlakyTest(androidx.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) Test(org.junit.Test) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Aggregations

FlakyTest (androidx.test.filters.FlakyTest)32 Test (org.junit.Test)32 SmallTest (android.test.suitebuilder.annotation.SmallTest)13 TelephonyTest (com.android.internal.telephony.TelephonyTest)13 Ignore (org.junit.Ignore)11 MediumTest (android.test.suitebuilder.annotation.MediumTest)10 Message (android.os.Message)9 WorkSource (android.os.WorkSource)9 AsyncResult (android.os.AsyncResult)6 Intent (android.content.Intent)5 DataProfile (android.telephony.data.DataProfile)5 Context (android.content.Context)4 GsmSmsMessage (android.hardware.radio.V1_0.GsmSmsMessage)4 CdmaSmsMessage (android.hardware.radio.V1_0.CdmaSmsMessage)3 ImsSmsMessage (android.hardware.radio.V1_0.ImsSmsMessage)3 ContentResolver (android.content.ContentResolver)2 DataProfileInfo (android.hardware.radio.V1_0.DataProfileInfo)2 NvWriteItem (android.hardware.radio.V1_0.NvWriteItem)2 SmsWriteArgs (android.hardware.radio.V1_0.SmsWriteArgs)2 CellIdentityCdma (android.telephony.CellIdentityCdma)2