### Question:
SliderPanel extends FrameLayout { @Override public boolean onTouchEvent(MotionEvent event) { if(isLocked){ return false; } try { dragHelper.processTouchEvent(event); }catch (IllegalArgumentException e){ return false; } return true; } SliderPanel(Context context);  SliderPanel(Context context, View decorView, SlidrConfig config); @Override boolean onInterceptTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent event); @Override void computeScroll(); void setOnPanelSlideListener(OnPanelSlideListener listener); SlidrInterface getDefaultInterface();  }### Answer:
@Test public void testOnTouchEvent_whenLocked() throws Exception { SliderPanel sliderPanel = Mockito.spy(new SliderPanel(context)); setInternalState(sliderPanel, "isLocked", true); boolean result = sliderPanel.onTouchEvent(motionEvent); assertFalse("Result must be false when locked", result); }
@Test public void testOnTouchEvent_whenNotLocked() throws Exception { SliderPanel sliderPanel = Mockito.spy(new SliderPanel(context)); setInternalState(sliderPanel, "isLocked", false); ViewDragHelper viewDragHelper = Mockito.mock(ViewDragHelper.class); setInternalState(sliderPanel, "dragHelper", viewDragHelper); boolean result = sliderPanel.onTouchEvent(motionEvent); assertTrue("Result must be true when not locked", result); }
@Test public void testOnTouchEvent_whenNotLocked_butExceptionInProcessTouchEvent() throws Exception { SliderPanel sliderPanel = Mockito.spy(new SliderPanel(context)); setInternalState(sliderPanel, "isLocked", false); ViewDragHelper viewDragHelper = Mockito.mock(ViewDragHelper.class); PowerMockito.doThrow(new IllegalArgumentException()).when(viewDragHelper).processTouchEvent(motionEvent); setInternalState(sliderPanel, "dragHelper", viewDragHelper); boolean result = sliderPanel.onTouchEvent(motionEvent); assertFalse("Result must be false when not locked but exception occured during processTouchEvent()", result); }