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());
}
}
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);
}
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));
}
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());
}
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());
}
Aggregations