BaseHtmlWebView extends BaseWebView implements UserClickListener { void initializeOnTouchListener(final boolean isScrollable) { setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { mViewGestureDetector.sendTouchEvent(event); return (event.getAction() == MotionEvent.ACTION_MOVE) && !isScrollable; } }); } BaseHtmlWebView(Context context, AdConfiguration adConfiguration); void init(boolean isScrollable); @Override void loadUrl(String url); @Override void onUserClick(); @Override void onResetUserClick(); @Override boolean wasClicked();  }
@Test public void setWebViewScrollingEnabled_whenScrollableIsTrue_onTouchListenerShouldAlwaysReturnFalse() throws Exception { subject.initializeOnTouchListener(true); View.OnTouchListener onTouchListener = shadowOf(subject).getOnTouchListener(); onTouchListener.onTouch(subject, createMotionEvent(MotionEvent.ACTION_DOWN)); boolean shouldConsumeTouch = onTouchListener.onTouch(subject, createMotionEvent(MotionEvent.ACTION_MOVE)); assertThat(shouldConsumeTouch).isFalse(); }
@Test public void setWebViewScrollingEnabled_whenScrollableIsFalse_whenActionMove_onTouchListenerShouldReturnTrue() throws Exception { subject.initializeOnTouchListener(false); View.OnTouchListener onTouchListener = shadowOf(subject).getOnTouchListener(); boolean shouldConsumeTouch = onTouchListener.onTouch(subject, createMotionEvent(MotionEvent.ACTION_MOVE)); assertThat(shouldConsumeTouch).isTrue(); }
@Test public void setWebViewScrollingEnabled_whenScrollableIsFalse_whenMotionEventIsNotActionMove_onTouchListenerShouldReturnFalse() throws Exception { subject.initializeOnTouchListener(false); View.OnTouchListener onTouchListener = shadowOf(subject).getOnTouchListener(); boolean shouldConsumeTouch = onTouchListener.onTouch(subject, touchUp); assertThat(shouldConsumeTouch).isFalse(); shouldConsumeTouch = onTouchListener.onTouch(subject, touchDown); assertThat(shouldConsumeTouch).isFalse(); shouldConsumeTouch = onTouchListener.onTouch(subject, createMotionEvent(MotionEvent.ACTION_CANCEL)); assertThat(shouldConsumeTouch).isFalse(); }