use of android.testing.TestableLooper in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp("GsmInboundSmsHandlerTest");
doReturn(true).when(mTelephonyManager).getSmsReceiveCapableForPhone(anyInt(), anyBoolean());
doReturn(true).when(mSmsStorageMonitor).isStorageAvailable();
UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
doReturn(true).when(userManager).isUserUnlocked();
doReturn(true).when(userManager).isUserRunning(any(UserHandle.class));
List<UserHandle> userHandles = new ArrayList();
userHandles.add(UserHandle.SYSTEM);
doReturn(userHandles).when(userManager).getUserHandles(anyBoolean());
mSmsMessage.mWrappedSmsMessage = mGsmSmsMessage;
mInboundSmsTracker = new InboundSmsTracker(mContext, mSmsPdu, /* pdu */
System.currentTimeMillis(), /* timestamp */
-1, /* destPort */
false, /* is3gpp2 */
false, /* is3gpp2WapPdu */
"1234567890", /* address */
"1234567890", /* displayAddress */
mMessageBody, /* 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());
createMockInboundSmsTracker();
mContentProvider = new FakeSmsContentProvider();
((MockContentResolver) mContext.getContentResolver()).addProvider(Telephony.Sms.CONTENT_URI.getAuthority(), mContentProvider);
mGsmInboundSmsHandler = GsmInboundSmsHandler.makeInboundSmsHandler(mContext, mSmsStorageMonitor, mPhone);
mSmsFilters = new ArrayList<>();
mSmsFilters.add(mSmsFilter);
mSmsFilters.add(mSmsFilter2);
mGsmInboundSmsHandler.setSmsFiltersForTesting(mSmsFilters);
monitorTestableLooper(new TestableLooper(mGsmInboundSmsHandler.getHandler().getLooper()));
processAllMessages();
}
Aggregations