FileDocCategorySizeDatePackage
HtmlTest.javaAPI DocAndroid 1.5 API2600Wed May 06 22:42:02 BST 2009com.android.frameworktest.text

HtmlTest

public class HtmlTest extends android.test.InstrumentationTestCase

Fields Summary
Constructors Summary
Methods Summary
public voidtestBadHtml()
Tests that the parser can handle mal-formed HTML.

        Spanned spanned = Html.fromHtml("Hello <b>b<i>bi</b>i</i>");
        Object[] spans = spanned.getSpans(0, 100, Object.class);
        assertEquals(Typeface.ITALIC, ((StyleSpan) spans[0]).getStyle());
        assertEquals(7, spanned.getSpanStart(spans[0]));
        assertEquals(9, spanned.getSpanEnd(spans[0]));
        assertEquals(Typeface.BOLD, ((StyleSpan) spans[1]).getStyle());
        assertEquals(6, spanned.getSpanStart(spans[1]));
        assertEquals(9, spanned.getSpanEnd(spans[1]));
        assertEquals(Typeface.ITALIC, ((StyleSpan) spans[2]).getStyle());
        assertEquals(9, spanned.getSpanStart(spans[2]));
        assertEquals(10, spanned.getSpanEnd(spans[2]));
    
public voidtestEmptyFontTag()

        Spanned spanned = Html.fromHtml("Hello <font color=\"#ff00ff00\"></font>");
        Object[] spans = spanned.getSpans(0, 100, Object.class);
        // TODO: figure out what the spans should be after the crashes are fixed and assert them.
    
public voidtestSingleTagOnWhileString()

        Spanned spanned = Html.fromHtml("<b>hello</b>");
        Object[] spans = spanned.getSpans(-1, 100, Object.class);
        assertEquals(1, spans.length);
        Object span = spans[0];
        assertEquals(0, spanned.getSpanStart(span));
        assertEquals(5, spanned.getSpanEnd(span));
    
public voidtestSymbols()

        String spanned = Html.fromHtml("© > <").toString();
        assertEquals("\u00a9 > <", spanned);