1package com.xtremelabs.robolectric.res;
2
3import com.xtremelabs.robolectric.R;
4import org.junit.Before;
5import org.junit.Test;
6
7import static com.xtremelabs.robolectric.util.TestUtil.resourceFile;
8import static org.hamcrest.CoreMatchers.equalTo;
9import static org.junit.Assert.assertThat;
10
11public class StringResourceLoaderTest {
12    private StringResourceLoader stringResourceLoader;
13
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
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
28    public void testHtmlTagsAreRemovedFromStrings() throws Exception {
29        assertThat(stringResourceLoader.getValue(R.string.some_html), equalTo("Hello, world"));
30    }
31
32    @Test
33    public void shouldResolveStringReferences() throws Exception {
34        assertThat(stringResourceLoader.getValue(R.string.greeting), equalTo("Howdy"));
35    }
36}
37