1 package com.xtremelabs.robolectric.res; 2 3 import com.xtremelabs.robolectric.R; 4 import org.junit.Before; 5 import org.junit.Test; 6 7 import static com.xtremelabs.robolectric.util.TestUtil.resourceFile; 8 import static org.hamcrest.CoreMatchers.equalTo; 9 import static org.junit.Assert.assertThat; 10 11 public class StringResourceLoaderTest { 12 private StringResourceLoader stringResourceLoader; 13 setUp()14 @Before public void setUp() throws Exception { 15 ResourceExtractor resourceExtractor = new ResourceExtractor(); 16 resourceExtractor.addLocalRClass(R.class); 17 stringResourceLoader = new StringResourceLoader(resourceExtractor); 18 new DocumentLoader(stringResourceLoader).loadResourceXmlDir(resourceFile("res", "values")); 19 } 20 21 @Test testStringsAreResolved()22 public void testStringsAreResolved() throws Exception { 23 assertThat(stringResourceLoader.getValue(R.string.hello), equalTo("Hello")); 24 assertThat(stringResourceLoader.getValue(R.string.howdy), equalTo("Howdy")); 25 } 26 27 @Test testHtmlTagsAreRemovedFromStrings()28 public void testHtmlTagsAreRemovedFromStrings() throws Exception { 29 assertThat(stringResourceLoader.getValue(R.string.some_html), equalTo("Hello, world")); 30 } 31 32 @Test shouldResolveStringReferences()33 public void shouldResolveStringReferences() throws Exception { 34 assertThat(stringResourceLoader.getValue(R.string.greeting), equalTo("Howdy")); 35 } 36 } 37