Code example for TextView

Methods: getVisibilitygetText

0
 
    /** Checks that the given id corresponds to a visible text view with the expected text. */ 
    private void assertHasText(View parent, int textViewId, String expectedText) {
        TextView textView = (TextView) parent.findViewById(textViewId);
        assertNotNull(textView);
        assertEquals(View.VISIBLE, textView.getVisibility());
        assertEquals(expectedText, textView.getText().toString());
    } 
 
    /** Checks that the given id corresponds to a visible text view with the expected HTML. */ 
    private void assertHasHtmlText(View parent, int textViewId, String expectedHtml) {
        TextView textView = (TextView) parent.findViewById(textViewId);
        assertNotNull(textView);
        assertEquals(View.VISIBLE, textView.getVisibility());
        assertSpannableEquals(Html.fromHtml(expectedHtml), textView.getText());
    } 
 
    /** 
     * Asserts that a char sequence is actually a {@link Spanned} matching the one expected. 
     */ 
    private void assertSpannableEquals(Spanned expected, CharSequence actualCharSequence) {