use of android.support.test.filters.MediumTest in project material-components-android by material-components.
the class BottomSheetBehaviorTest method testInvisible.
@Test
@MediumTest
public void testInvisible() throws Throwable {
// Make the bottomsheet invisible
activityTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
getBottomSheet().setVisibility(View.INVISIBLE);
assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_COLLAPSED));
}
});
// Swipe up as if to expand it
Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet)).perform(DesignViewActions.withCustomConstraints(new GeneralSwipeAction(Swipe.FAST, GeneralLocation.VISIBLE_CENTER, new CoordinatesProvider() {
@Override
public float[] calculateCoordinates(View view) {
return new float[] { view.getWidth() / 2, 0 };
}
}, Press.FINGER), not(ViewMatchers.isDisplayed())));
// Check that the bottom sheet stays the same collapsed state
activityTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_COLLAPSED));
}
});
}
use of android.support.test.filters.MediumTest in project material-components-android by material-components.
the class CustomSnackbarTest method testDismissViaAnotherSnackbar.
@Test
@MediumTest
public void testDismissViaAnotherSnackbar() throws Throwable {
final CustomSnackbar anotherSnackbar = makeCustomSnackbar().setTitle("Different title").setSubtitle("Different subtitle").setDuration(Snackbar.LENGTH_SHORT);
// Our dismiss action is to show another snackbar (and verify that the original snackbar
// is now dismissed with CONSECUTIVE event)
verifyDismissCallback(onView(isAssignableFrom(Snackbar.SnackbarLayout.class)), null, new DismissAction() {
@Override
public void dismiss(CustomSnackbar snackbar) {
anotherSnackbar.show();
}
}, Snackbar.LENGTH_LONG, Snackbar.Callback.DISMISS_EVENT_CONSECUTIVE);
// And dismiss the second snackbar to get back to clean state
SnackbarUtils.dismissTransientBottomBarAndWaitUntilFullyDismissed(anotherSnackbar);
}
use of android.support.test.filters.MediumTest in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method testMultiPartIncompleteSms.
@Test
@MediumTest
public void testMultiPartIncompleteSms() {
/**
* Test scenario: 2 messages are received with same address, ref number, count, and
* seqNumber, with count = 2 and seqNumber = 1. We should not try to merge these.
*/
transitionFromStartupToIdle();
// prepare SMS part 1 and part 2
prepareMultiPartSms(false);
// change seqNumber in part 2 to 1
mInboundSmsTrackerCVPart2.put("sequence", 1);
doReturn(1).when(mInboundSmsTrackerPart2).getSequenceNumber();
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 no broadcasts sent
verify(mContext, never()).sendBroadcast(any(Intent.class));
// verify there's only 1 of the segments in the db (other should be discarded as dup)
assertEquals(1, mContentProvider.getNumRows());
// State machine should go back to idle
assertEquals("IdleState", getCurrentState().getName());
}
use of android.support.test.filters.MediumTest in project android_frameworks_opt_telephony by LineageOS.
the class GsmInboundSmsHandlerTest method testMultiPartSms.
@FlakyTest
@Ignore
@Test
@MediumTest
public void testMultiPartSms() {
transitionFromStartupToIdle();
// prepare SMS part 1 and part 2
prepareMultiPartSms(false);
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 broadcast intents
verifySmsIntentBroadcasts(0);
// if an additional copy of one of the segments above is received, it should not be kept in
// the db and should not be combined with any subsequent messages received from the same
// sender
// additional copy of part 2 of message
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 no additional broadcasts sent
verify(mContext, times(2)).sendBroadcast(any(Intent.class));
// part 1 of new sms recieved from same sender with same parameters, just different
// timestamps, should not be combined with the additional part 2 received above
// call prepareMultiPartSms() to update timestamps
prepareMultiPartSms(false);
// part 1 of new sms
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);
// verify no additional broadcasts sent
verify(mContext, times(2)).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 testBroadcastUndeliveredUserLocked.
@Test
@MediumTest
public void testBroadcastUndeliveredUserLocked() throws Exception {
replaceInstance(SmsBroadcastUndelivered.class, "instance", null, null);
doReturn(0).when(mInboundSmsTracker).getDestPort();
// add a fake entry to db
mContentProvider.insert(sRawUri, mInboundSmsTrackerCV);
// make it a single-part message
doReturn(1).when(mInboundSmsTracker).getMessageCount();
// user locked
UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
doReturn(false).when(userManager).isUserUnlocked();
SmsBroadcastUndelivered.initialize(mContext, mGsmInboundSmsHandler, mCdmaInboundSmsHandler);
// verify that a broadcast receiver is registered for current user (user == null) based on
// implementation in ContextFixture
verify(mContext).registerReceiverAsUser(any(BroadcastReceiver.class), eq((UserHandle) null), any(IntentFilter.class), eq((String) null), eq((Handler) null));
waitForMs(100);
// verify no broadcasts sent because due to !isUserUnlocked
verify(mContext, never()).sendBroadcast(any(Intent.class));
// when user unlocks the device, the message in db should be broadcast
doReturn(true).when(userManager).isUserUnlocked();
mContext.sendBroadcast(new Intent(Intent.ACTION_USER_UNLOCKED));
waitForMs(100);
verifyDataSmsIntentBroadcasts(1);
}
Aggregations