1 package com.xtremelabs.robolectric.res; 2 3 import static com.xtremelabs.robolectric.util.TestUtil.resourceFile; 4 import static org.hamcrest.CoreMatchers.equalTo; 5 import static org.junit.Assert.assertThat; 6 7 import org.junit.Before; 8 import org.junit.Test; 9 10 import com.xtremelabs.robolectric.R; 11 12 public class IntegerResourceLoaderTest { 13 14 protected IntegerResourceLoader resourceLoader; 15 16 @Before 17 public void setup() throws Exception { 18 ResourceExtractor extractor = new ResourceExtractor(); 19 extractor.addLocalRClass( R.class ); 20 extractor.addSystemRClass( android.R.class ); 21 22 resourceLoader = new IntegerResourceLoader( extractor ); 23 DocumentLoader documentLoader = new DocumentLoader(resourceLoader); 24 25 documentLoader.loadResourceXmlDir(resourceFile("res", "values")); 26 } 27 28 @Test 29 public void testIntegersAreResolved() { 30 assertThat( resourceLoader.getValue( R.integer.test_integer1 ), equalTo( 2000 ) ); 31 assertThat( resourceLoader.getValue( R.integer.test_integer2 ), equalTo( 9 ) ); 32 assertThat( resourceLoader.getValue( R.integer.test_large_hex), equalTo( 0xFFFF0000 ) ); 33 } 34 35 } 36