Code example for TextView

Methods: addTextChangedListenersetText

0
  } 
 
  @Test 
  public void givenATextViewWithATextWatcherAdded_WhenSettingTextWithCharSequence_ShouldNotifyTextWatcher() { 
    MockTextWatcher mockTextWatcher = new MockTextWatcher();
    textView.addTextChangedListener(mockTextWatcher);
 
    textView.setText("text");
 
    assertEachTextWatcherEventWasInvoked(mockTextWatcher);
  } 
 
  @Test 
  public void givenATextViewWithATextWatcherAdded_WhenSettingNullText_ShouldNotifyTextWatcher() { 
    MockTextWatcher mockTextWatcher = new MockTextWatcher();
    textView.addTextChangedListener(mockTextWatcher);
 
    textView.setText(null);
 
    assertEachTextWatcherEventWasInvoked(mockTextWatcher);
  }