@Test public void onTouchUpAction_eventWhenNotOverscrolled_ignoreTouchEvent() throws Exception { // Arrange MotionEvent event = createDefaultUpActionEvent(); when(mViewAdapter.isInAbsoluteStart()).thenReturn(true); when(mViewAdapter.isInAbsoluteEnd()).thenReturn(true); HorizontalOverScrollBounceEffectDecorator uut = getUUT(); // Act boolean ret = uut.onTouch(mView, event); // Assert verify(mView, never()).setTranslationX(anyFloat()); verify(mView, never()).setTranslationY(anyFloat()); assertFalse(ret); assertEquals(STATE_IDLE, uut.getCurrentState()); verify(mStateListener, never()).onOverScrollStateChange(eq(uut), anyInt(), anyInt()); verify(mUpdateListener, never()).onOverScrollUpdate(eq(uut), anyInt(), anyFloat()); }
/** * TODO: Make this work using a decent animation shadows / newer Robolectric * @throws Exception */ @Ignore @Test public void onTouchUpAction_eventWhenLeftOverscrolling_smoothScrollBackToRightEnd() throws Exception { // Arrange // Bring UUT to a left-overscroll state MotionEvent moveEvent = createShortLeftMoveEvent(); when(mViewAdapter.isInAbsoluteStart()).thenReturn(false); when(mViewAdapter.isInAbsoluteEnd()).thenReturn(true); HorizontalOverScrollBounceEffectDecorator uut = getUUT(); uut.onTouch(mView, moveEvent); reset(mView); // Make the view as though it's been moved by the move event float viewX = moveEvent.getX(); when(mView.getTranslationX()).thenReturn(viewX); MotionEvent upEvent = createDefaultUpActionEvent(); // Act boolean ret = uut.onTouch(mView, upEvent); // Assert assertTrue(ret); verify(mView, atLeastOnce()).setTranslationX(anyFloat()); }