Esempio n. 1
0
 @Test
 public void dispatchTouchEvent_sendsMotionEventToOnTouchEvent() throws Exception {
   TouchableView touchableView = new TouchableView(null);
   MotionEvent event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 12f, 34f, 0);
   touchableView.dispatchTouchEvent(event);
   assertThat(touchableView.event, sameInstance(event));
   view.dispatchTouchEvent(event);
   assertThat(shadowOf(view).getLastTouchEvent(), sameInstance(event));
 }
Esempio n. 2
0
 @Test
 public void dispatchTouchEvent_listensToFalseFromListener() throws Exception {
   view.setOnTouchListener(
       new View.OnTouchListener() {
         @Override
         public boolean onTouch(View view, MotionEvent motionEvent) {
           return false;
         }
       });
   MotionEvent event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 12f, 34f, 0);
   view.dispatchTouchEvent(event);
   assertThat(shadowOf(view).getLastTouchEvent(), sameInstance(event));
 }