Code example for TextView

Methods: appendgetSelectionEndgetSelectionStartsetText, getEditableText

0
    assertEquals(3, textView.getSelectionStart());
  } 
 
  @Test 
  public void append_whenSelectionReachesToEnd_shouldExtendSelectionToTheEnd() throws Exception { 
    textView.setText("12", TextView.BufferType.EDITABLE);
    Selection.setSelection(textView.getEditableText(), 0, 2);
    textView.append("3");
    assertEquals(3, textView.getSelectionEnd());
    assertEquals(0, textView.getSelectionStart());
  } 
 
  @Test 
  public void testSetCompountDrawablesWithIntrinsicBounds_int_shouldCreateDrawablesWithResourceIds() throws Exception { 
    textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.an_image, R.drawable.an_other_image, R.drawable.third_image, R.drawable.fourth_image);
 
    assertEquals(R.drawable.an_image, shadowOf(textView.getCompoundDrawables()[0]).getCreatedFromResId());
    assertEquals(R.drawable.an_other_image, shadowOf(textView.getCompoundDrawables()[1]).getCreatedFromResId());
    assertEquals(R.drawable.third_image, shadowOf(textView.getCompoundDrawables()[2]).getCreatedFromResId());
    assertEquals(R.drawable.fourth_image, shadowOf(textView.getCompoundDrawables()[3]).getCreatedFromResId());
  }