Code example for TextView

Methods: setMovementMethod, dispatchTouchEvent, measure, setLayoutParams

0
  } 
 
  @Test 
  public void onTouchEvent_shouldCallMovementMethodOnTouchEventWithSetMotionEvent() throws Exception { 
    TestMovementMethod testMovementMethod = new TestMovementMethod();
    textView.setMovementMethod(testMovementMethod);
    textView.setLayoutParams(new ViewGroup.LayoutParams(100, 100));
    textView.measure(100, 100);
 
    MotionEvent event = MotionEvent.obtain(0, 0, 0, 0, 0, 0);
    textView.dispatchTouchEvent(event);
 
    assertEquals(testMovementMethod.event, event);
  } 
 
  @Test 
  public void testGetError() { 
    assertNull(textView.getError());
    CharSequence error = "myError";
    textView.setError(error);
    assertEquals(error, textView.getError());