Code example for TextView

Methods: getTextsetText

0
        context = new Activity();
    } 
 
    @Test 
    public void shouldBeAbleToGetTextFromTextViewAfterUsingSetTextWithHtmlDotFromHtml() throws Exception { 
        TextView textView = new TextView(context);
        textView.setText(Html.fromHtml("<b>some</b> html text"));
        assertThat(textView.getText().toString()).isEqualTo("<b>some</b> html text");
    } 
 
    @Test 
    public void shouldBeAbleToGetTextFromEditTextAfterUsingSetTextWithHtmlDotFromHtml() throws Exception { 
        EditText editText = new EditText(context);
        editText.setText(Html.fromHtml("<b>some</b> html text"));
        assertThat(editText.getText().toString()).isEqualTo("<b>some</b> html text");
    } 
 
    @Test(expected = NullPointerException.class) 
    public void shouldThrowNullPointerExceptionWhenNullStringEncountered() throws Exception { 
        Html.fromHtml(null);
    }