package com.xtremelabs.robolectric.shadows;


import android.app.Activity;
import android.content.Context;
import android.text.Html;
import android.widget.EditText;
import android.widget.TextView;
import com.xtremelabs.robolectric.WithTestDefaultsRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;

@RunWith(WithTestDefaultsRunner.class)
public class HtmlTest {
    private Context context;

    @Before
    public void setUp() throws Exception {
        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(), equalTo("<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(), equalTo("<b>some</b> html text"));
    }
    
    @Test
    public void shouldThrowNullPointerExceptionWhenNullStringEncountered() throws Exception {
    	NullPointerException npe = null;
    	try {
    		Html.fromHtml(null);
    	} catch (NullPointerException e) {
    		npe = e;
    	}
    	assertThat(npe, notNullValue());
    }

}

@@ -383,62 +383,8 @@
 To;%0A
-import static org.hamcrest.CoreMatchers.notNullValue;%0A
 impo
@@ -1263,20 +1263,16 @@
 ;%0A    %7D%0A
-    
 %0A    @Te
@@ -1265,32 +1265,71 @@
     %7D%0A%0A    @Test
+(expected = NullPointerException.class)
 %0A    public void
@@ -1415,185 +1415,37 @@
     
-%09NullPointerException npe = null;%0A    %09try %7B%0A    %09%09Html.fromHtml(null);%0A    %09%7D catch (NullPointerException e) %7B%0A    %09%09npe = e;%0A    %09%7D%0A    %09assertThat(npe, notNullValue());%0A    %7D%0A
+    Html.fromHtml(null);%0A    %7D
 %0A%7D%0A

simplify HtmlTest