use of android.support.test.filters.MediumTest in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method testMultipartSmsFromBlockedEmail_noBroadcastsSent.
@Test
@MediumTest
public void testMultipartSmsFromBlockedEmail_noBroadcastsSent() {
mFakeBlockedNumberContentProvider.mBlockedNumbers.add("1234567890@test.com");
transitionFromStartupToIdle();
// prepare SMS part 1 and part 2
prepareMultiPartSms(false);
// only the first SMS is configured with the display originating email address
mInboundSmsTrackerCVPart1.put("display_originating_addr", "1234567890@test.com");
mSmsHeader.concatRef = new SmsHeader.ConcatRef();
doReturn(mSmsHeader).when(mGsmSmsMessage).getUserDataHeader();
doReturn(mInboundSmsTrackerPart1).when(mTelephonyComponentFactory).makeInboundSmsTracker(nullable(byte[].class), anyLong(), anyInt(), anyBoolean(), nullable(String.class), nullable(String.class), anyInt(), anyInt(), anyInt(), anyBoolean(), nullable(String.class));
mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null));
waitForMs(100);
// State machine should go back to idle and wait for second part
assertEquals("IdleState", getCurrentState().getName());
doReturn(mInboundSmsTrackerPart2).when(mTelephonyComponentFactory).makeInboundSmsTracker(nullable(byte[].class), anyLong(), anyInt(), anyBoolean(), nullable(String.class), nullable(String.class), anyInt(), anyInt(), anyInt(), anyBoolean(), nullable(String.class));
mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null));
waitForMs(100);
verify(mContext, never()).sendBroadcast(any(Intent.class));
assertEquals("IdleState", getCurrentState().getName());
}
use of android.support.test.filters.MediumTest in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method testBroadcastUndeliveredDeleted.
@Test
@MediumTest
public void testBroadcastUndeliveredDeleted() throws Exception {
replaceInstance(SmsBroadcastUndelivered.class, "instance", null, null);
SmsBroadcastUndelivered.initialize(mContext, mGsmInboundSmsHandler, mCdmaInboundSmsHandler);
doReturn(0).when(mInboundSmsTracker).getDestPort();
// add a fake entry to db
ContentValues rawSms = new ContentValues();
rawSms.put("deleted", 1);
mContentProvider.insert(sRawUri, rawSms);
// make it a single-part message
doReturn(1).when(mInboundSmsTracker).getMessageCount();
// when user unlocks the device, broadcast should not be sent for new message
mContext.sendBroadcast(new Intent(Intent.ACTION_USER_UNLOCKED));
waitForMs(100);
verify(mContext, times(1)).sendBroadcast(any(Intent.class));
assertEquals("IdleState", getCurrentState().getName());
}
use of android.support.test.filters.MediumTest in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method testMultiPartSmsWithIncompleteWAP.
@Test
@MediumTest
public void testMultiPartSmsWithIncompleteWAP() {
/**
* Test scenario: 3 messages are received with same address, ref number, count. two of the
* messages are belonging to the same multi-part SMS and the other one is a 3GPP2WAP.
* we should not try to merge 3gpp2wap with the multi-part SMS.
*/
transitionFromStartupToIdle();
// prepare SMS part 1 and part 2
prepareMultiPartSms(false);
mSmsHeader.concatRef = new SmsHeader.ConcatRef();
doReturn(mSmsHeader).when(mGsmSmsMessage).getUserDataHeader();
// part 2 of non-3gpp2wap arrives first
doReturn(mInboundSmsTrackerPart2).when(mTelephonyComponentFactory).makeInboundSmsTracker(nullable(byte[].class), anyLong(), anyInt(), anyBoolean(), nullable(String.class), nullable(String.class), anyInt(), anyInt(), anyInt(), anyBoolean(), nullable(String.class));
mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null));
waitForMs(200);
// State machine should go back to idle and wait for second part
assertEquals("IdleState", getCurrentState().getName());
// mock a 3gpp2wap push
prepareMultiPartSms(true);
doReturn(mInboundSmsTrackerPart2).when(mTelephonyComponentFactory).makeInboundSmsTracker(nullable(byte[].class), anyLong(), anyInt(), anyBoolean(), nullable(String.class), nullable(String.class), anyInt(), anyInt(), anyInt(), anyBoolean(), nullable(String.class));
mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null));
waitForMs(200);
// State machine should go back to idle and wait for second part
assertEquals("IdleState", getCurrentState().getName());
// verify no broadcast sent.
verify(mContext, times(0)).sendBroadcast(any(Intent.class));
// additional copy of part 1 of non-3gpp2wap
prepareMultiPartSms(false);
doReturn(mInboundSmsTrackerPart1).when(mTelephonyComponentFactory).makeInboundSmsTracker(nullable(byte[].class), anyLong(), anyInt(), anyBoolean(), nullable(String.class), nullable(String.class), anyInt(), anyInt(), anyInt(), anyBoolean(), nullable(String.class));
mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null));
waitForMs(200);
// verify broadcast intents
verifySmsIntentBroadcasts(0);
assertEquals("IdleState", getCurrentState().getName());
// verify there are three segments in the db and only one of them is not marked as deleted.
assertEquals(3, mContentProvider.getNumRows());
assertEquals(1, mContentProvider.query(sRawUri, null, "deleted=0", null, null).getCount());
}
use of android.support.test.filters.MediumTest in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method testNewSmsFromBlockedNumber_noBroadcastsSent.
@Test
@MediumTest
public void testNewSmsFromBlockedNumber_noBroadcastsSent() {
String blockedNumber = "1234567890";
doReturn(blockedNumber).when(mInboundSmsTracker).getDisplayAddress();
mFakeBlockedNumberContentProvider.mBlockedNumbers.add(blockedNumber);
transitionFromStartupToIdle();
mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null));
waitForMs(100);
verify(mContext, never()).sendBroadcast(any(Intent.class));
assertEquals("IdleState", getCurrentState().getName());
}
use of android.support.test.filters.MediumTest in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method testInjectSms.
@FlakyTest
@Ignore
@Test
@MediumTest
public void testInjectSms() {
transitionFromStartupToIdle();
mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_INJECT_SMS, new AsyncResult(null, mSmsMessage, null));
waitForMs(200);
verifySmsIntentBroadcasts(0);
// inject same SMS again, verify no broadcasts are sent
mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_INJECT_SMS, new AsyncResult(null, mSmsMessage, null));
waitForMs(100);
verify(mContext, times(2)).sendBroadcast(any(Intent.class));
assertEquals("IdleState", getCurrentState().getName());
}
Aggregations