Code example for TextView

Methods: appendgetTextsetText

0
    assertThat(mockTextWatcher.afterTextChangeArgument.toString()).isEqualTo(NEW_TEXT);
  } 
 
  @Test 
  public void whenAppendingText_ShouldAppendNewTextAfterOldOne() { 
    textView.setText(INITIAL_TEXT);
    textView.append(NEW_TEXT);
 
    assertThat(textView.getText().toString()).isEqualTo(INITIAL_TEXT + NEW_TEXT);
  } 
 
  @Test 
  public void whenAppendingText_ShouldFireBeforeTextChangedWithCorrectArguments() { 
    textView.setText(INITIAL_TEXT);
    TextWatcher mockTextWatcher = mock(TextWatcher.class);
    textView.addTextChangedListener(mockTextWatcher);
 
    textView.append(NEW_TEXT);
 
    verify(mockTextWatcher).beforeTextChanged(new SpannableStringBuilder(INITIAL_TEXT), 0, INITIAL_TEXT.length(), INITIAL_TEXT.length());
  }