@Before public void setUp() { button = new NavFloatingActionButton(new ContextThemeWrapper(RuntimeEnvironment.application, R.style.AppTheme)); shadowOf(button).getOnTouchListener().onTouch(button, MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0)); gestureListener = (GestureDetector.SimpleOnGestureListener) shadowOf(ShadowGestureDetector.getLastActiveDetector()).getListener(); navigable = mock(Navigable.class); button.setNavigable(navigable); assertTrue(gestureListener.onDown(null)); }
@Test public void constructor_shouldDisableLongPressAndSetGestureListener() throws Exception { subject = new ViewGestureDetector(context, view, mockAdReport); ShadowGestureDetector shadowGestureDetector = shadowOf(subject); assertThat(subject.isLongpressEnabled()).isFalse(); assertThat(shadowGestureDetector.getListener()).isNotNull(); assertThat(shadowGestureDetector.getListener()).isInstanceOf(AdAlertGestureListener.class); }
private ShadowGestureDetector getDetector(View view) { shadowOf(view).getOnTouchListener() .onTouch(view, MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0)); return shadowOf(ShadowGestureDetector.getLastActiveDetector()); }
public static ShadowGestureDetector shadowOf(GestureDetector instance) { return (ShadowGestureDetector) shadowOf_(instance); }