use of org.robolectric.res.android.ResTable_config in project robolectric by robolectric.
the class ResourceParserTest method setUp.
@Before
public void setUp() {
ResourceTableFactory resourceTableFactory = new ResourceTableFactory();
resourceTable = resourceTableFactory.newResourceTable("org.robolectric", testResources());
config = new ResTable_config();
}
use of org.robolectric.res.android.ResTable_config in project robolectric by robolectric.
the class StyleResourceLoaderTest method testStyleDataIsLoadedCorrectly.
@Test
public void testStyleDataIsLoadedCorrectly() throws Exception {
TypedResource typedResource = resourceTable.getValue(new ResName("android", "style", "Theme_Holo"), new ResTable_config());
StyleData styleData = (StyleData) typedResource.getData();
assertThat(styleData.getName()).isEqualTo("Theme_Holo");
assertThat(styleData.getParent()).isEqualTo("Theme");
assertThat(styleData.getPackageName()).isEqualTo("android");
assertThat(styleData.getAttrValue(new ResName("android", "attr", "colorForeground")).value).isEqualTo("@android:color/bright_foreground_holo_dark");
}
use of org.robolectric.res.android.ResTable_config in project robolectric by robolectric.
the class DrawableResourceLoaderNoRunnerTest method shouldFindDrawableResources.
@Test
public void shouldFindDrawableResources() throws Exception {
Path testBaseDir = temporaryFolder.newFolder("res").toPath();
temporaryFolder.newFolder("res", "drawable");
temporaryFolder.newFile("res/drawable/foo.png");
ResourcePath resourcePath = new ResourcePath(null, testBaseDir, null);
DrawableResourceLoader testLoader = new DrawableResourceLoader(resourceTable);
testLoader.findDrawableResources(resourcePath);
assertThat(resourceTable.getValue(new ResName("org.robolectric", "drawable", "foo"), new ResTable_config()).isFile()).isTrue();
}
use of org.robolectric.res.android.ResTable_config in project robolectric by robolectric.
the class RawResourceLoaderTest method shouldReturnRawResourcesWithExtensions.
@Test
public void shouldReturnRawResourcesWithExtensions() throws Exception {
String f = (String) resourceTable.getValue(R.raw.raw_resource, new ResTable_config()).getData();
assertThat(f).isEqualTo(TestUtil.testResources().getResourceBase().resolve("raw").resolve("raw_resource.txt").toString());
}
use of org.robolectric.res.android.ResTable_config in project robolectric by robolectric.
the class ResBundleTest method shouldNotOverwriteValuesWithMatchingQualifiers.
@Test
public void shouldNotOverwriteValuesWithMatchingQualifiers() {
ResBundle bundle = new ResBundle();
XmlContext xmlContext = mock(XmlContext.class);
when(xmlContext.getQualifiers()).thenReturn(Qualifiers.parse("--"));
when(xmlContext.getConfig()).thenReturn(new ResTable_config());
when(xmlContext.getPackageName()).thenReturn("org.robolectric");
TypedResource firstValue = new TypedResource<>("first_value", ResType.CHAR_SEQUENCE, xmlContext);
TypedResource secondValue = new TypedResource<>("second_value", ResType.CHAR_SEQUENCE, xmlContext);
bundle.put(new ResName("org.robolectric", "string", "resource_name"), firstValue);
bundle.put(new ResName("org.robolectric", "string", "resource_name"), secondValue);
assertThat(bundle.get(new ResName("org.robolectric", "string", "resource_name"), from("")).getData()).isEqualTo("first_value");
}
Aggregations