CloseableLayout extends FrameLayout { @Override public boolean onInterceptTouchEvent(@NonNull final MotionEvent event) { if (event.getAction() != MotionEvent.ACTION_DOWN) { return false; } final int x = (int) event.getX(); final int y = (int) event.getY(); return pointInCloseBounds(x, y, 0); } CloseableLayout(@NonNull Context context); void setOnCloseListener(@Nullable OnCloseListener onCloseListener); void setClosePosition(@NonNull ClosePosition closePosition); void setCloseVisible(boolean visible); @Override void draw(@NonNull final Canvas canvas); void applyCloseRegionBounds(ClosePosition closePosition, Rect bounds, Rect closeBounds); @Override boolean onInterceptTouchEvent(@NonNull final MotionEvent event); @Override boolean onTouchEvent(@NonNull MotionEvent event); @VisibleForTesting boolean isCloseVisible();  }
@Test public void onInterceptTouchEvent_closeRegionDown_shouldReturnTrue() { boolean intercepted = subject.onInterceptTouchEvent(closeRegionDown); assertThat(intercepted).isTrue(); }
@Test public void onInterceptTouchEvent_contentRegionDown_returnsTrue() { boolean intercepted = subject.onInterceptTouchEvent(contentRegionDown); assertThat(intercepted).isFalse(); }