Search in sources :

Example 16 with ResTable_config

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();
}
Also used : ResTable_config(org.robolectric.res.android.ResTable_config) Before(org.junit.Before)

Example 17 with 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");
}
Also used : ResTable_config(org.robolectric.res.android.ResTable_config) Test(org.junit.Test)

Example 18 with ResTable_config

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();
}
Also used : Path(java.nio.file.Path) ResTable_config(org.robolectric.res.android.ResTable_config) Test(org.junit.Test)

Example 19 with ResTable_config

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());
}
Also used : ResTable_config(org.robolectric.res.android.ResTable_config) Test(org.junit.Test)

Example 20 with ResTable_config

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");
}
Also used : ResTable_config(org.robolectric.res.android.ResTable_config) Test(org.junit.Test)

Aggregations

ResTable_config (org.robolectric.res.android.ResTable_config)31 Implementation (org.robolectric.annotation.Implementation)22 CppAssetManager2 (org.robolectric.res.android.CppAssetManager2)18 Ref (org.robolectric.res.android.Ref)17 Res_value (org.robolectric.res.android.ResourceTypes.Res_value)16 ApkAssetsCookie (org.robolectric.res.android.ApkAssetsCookie)14 ResolvedBag (org.robolectric.res.android.CppAssetManager2.ResolvedBag)10 Nullable (android.annotation.Nullable)8 Test (org.junit.Test)5 HiddenApi (org.robolectric.annotation.HiddenApi)4 CppAssetManager (org.robolectric.res.android.CppAssetManager)3 Configuration (android.content.res.Configuration)2 Path (java.nio.file.Path)2 CppApkAssets (org.robolectric.res.android.CppApkAssets)2 Theme (org.robolectric.res.android.CppAssetManager2.Theme)2 ResStringPool (org.robolectric.res.android.ResStringPool)2 ResTable (org.robolectric.res.android.ResTable)2 SuppressLint (android.annotation.SuppressLint)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Locale (java.util.Locale)1